Skip to content

Commit 4857a06

Browse files
committedMar 26, 2019
[RPM] Make buildrpm.sh more robust and fix -b flag usage
1 parent 13f9424 commit 4857a06

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed
 

‎rpm/buildrpms.sh

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
# buildrpms.sh
44
# ---------------------
55
# Date : March 2014
6-
# Copyright : (C) 2014 by Matthias Kuhn
6+
# Copyright : (C) 2014-2019 by Matthias Kuhn
77
# Email : matthias at opengis dot ch
8+
# ---------------------
9+
# Date : October 2017
10+
# Copyright : (C) 2017-2019 by Daniele Viganò
11+
# Email : daniele at vigano dot me
812
###########################################################################
913
# #
1014
# This program is free software; you can redistribute it and/or modify #
@@ -14,6 +18,11 @@
1418
# #
1519
###########################################################################
1620

21+
if [ $_BUILDRPMS_DEBUG ]
22+
then
23+
set -x
24+
fi
25+
1726
function print_info
1827
{
1928
echo -e "\e[0;32m$1\033[0m"
@@ -40,7 +49,8 @@ Usage:
4049

4150
function compress
4251
{
43-
if command -v pbzip2 &> /dev/null; then
52+
if command -v pbzip2 &> /dev/null
53+
then
4454
echo 'pbzip2'
4555
else
4656
echo 'bzip2'
@@ -142,7 +152,7 @@ then
142152

143153
print_info "Creating source tarball"
144154
# Create source tarball
145-
git -C .. archive --format=tar --prefix=qgis-$version/ HEAD | compress > sources/qgis-$version.tar.bz2
155+
git -C .. archive --format=tar --prefix=qgis-$version/ HEAD | $(compress) > sources/qgis-$version.tar.bz2
146156

147157
print_info "Creating source package"
148158
# Build source package
@@ -156,12 +166,12 @@ then
156166
exit 1
157167
fi
158168

159-
srpm=$(grep -e 'Wrote: .*\.src\.rpm' $OUTDIR/build.log |
160-
sed 's_Wrote: /builddir/build/SRPMS/\(.*\)_\1_')
161-
162169
print_info "Source package created: $srpm"
163170
fi
164171

172+
srpm="$(ls -t $OUTDIR/qgis-$version-$relver.*.src.rpm | head -n 1 ||
173+
(print_error "Source package unavailable. Abort"; exit 1))"
174+
165175
if [ "$srpm_only" -eq "1" ]
166176
then
167177
exit 0
@@ -171,14 +181,18 @@ fi
171181
for arch in "${ARCHS[@]}"
172182
do :
173183
print_info "Building packages for $arch"
174-
if [ -f $OUTDIR/$arch/build.log ]
184+
if [ -d $OUTDIR/$arch ]
175185
then
176-
print_info "Cleaning log file"
177-
rm $OUTDIR/$arch/build.log
186+
if [ -f $OUTDIR/$arch/build.log ]
187+
then
188+
print_info "Cleaning log file"
189+
rm $OUTDIR/$arch/build.log
190+
fi
191+
else
192+
mkdir $OUTDIR/$arch
178193
fi
179-
mkdir $OUTDIR/$arch
180194

181-
if ! mock -r $arch --rebuild $OUTDIR/$srpm \
195+
if ! mock -r $arch --rebuild $srpm \
182196
--define "_relver $relver" \
183197
--define "_version $version" \
184198
--define "_timestamp $timestamp" \

‎rpm/default.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# maintainer.
77

88
# Where should the results go
9-
OUTDIR="result/"
9+
OUTDIR="result"
1010

1111
# Which arches to build for. Check /etc/mock for possible options
1212
ARCHS=(

0 commit comments

Comments
 (0)
Please sign in to comment.