Skip to content
Permalink
Browse files

Merge pull request #9628 from daniviga/fix-rpm-2

[RPM] Make buildrpm.sh more robust and fast
  • Loading branch information
m-kuhn committed Mar 26, 2019
2 parents 4f9d002 + 08c095e commit 74e8207bf25d3d57d8d63f8cda2c3def2624c4c7
Showing with 59 additions and 36 deletions.
  1. +55 −32 rpm/buildrpms.sh
  2. +3 −1 rpm/default.cfg
  3. +1 −3 rpm/qgis.spec.template
@@ -3,8 +3,12 @@
# buildrpms.sh
# ---------------------
# Date : March 2014
# Copyright : (C) 2014 by Matthias Kuhn
# Copyright : (C) 2014-2019 by Matthias Kuhn
# Email : matthias at opengis dot ch
# ---------------------
# Date : October 2017
# Copyright : (C) 2017-2019 by Daniele Viganò
# Email : daniele at vigano dot me
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
@@ -14,6 +18,11 @@
# #
###########################################################################

if [ $_BUILDRPMS_DEBUG ]
then
set -x
fi

function print_info
{
echo -e "\e[0;32m$1\033[0m"
@@ -40,7 +49,14 @@ Usage:

if [ $_MOCK_OLD_CHROOT ]
then
mock_args="--old-chroot"
mock_args="--old-chroot"
fi

if command -v pbzip2 &> /dev/null
then
bzip2_cmd="pbzip2"
else
bzip2_cmd="bzip2"
fi

relver=1
@@ -98,13 +114,6 @@ else
timestamp=$(date +'%s')
fi

# Clean logfiles
if [ -f $OUTDIR/build.log ]
then
print_info "Cleaning log file"
rm $OUTDIR/build.log
fi

# Get the version string
major=$(grep -e 'SET(CPACK_PACKAGE_VERSION_MAJOR' ../CMakeLists.txt |
sed -r 's/.*\"([0-9]+)\".*/\1/g')
@@ -118,6 +127,12 @@ version=$major.$minor.$patch
print_info "Building version $version-$relver"
if [ "$build_only" -ne "1" ]
then
# Clean logfiles
if [ -f $OUTDIR/build.log ]
then
print_info "Cleaning log file"
rm $OUTDIR/build.log
fi
print_info "Creating spec file from template"
# Create spec file
cat qgis.spec.template \
@@ -133,7 +148,7 @@ then

print_info "Creating source tarball"
# Create source tarball
git -C .. archive --format=tar --prefix=qgis-$version/ HEAD | bzip2 > sources/qgis-$version.tar.bz2
git -C .. archive --format=tar --prefix=qgis-$version/ HEAD | $bzip2_cmd > sources/qgis-$version.tar.bz2

print_info "Creating source package"
# Build source package
@@ -146,13 +161,12 @@ then
print_error "Creating source package failed"
exit 1
fi

srpm=$(grep -e 'Wrote: .*\.src\.rpm' $OUTDIR/build.log |
sed 's_Wrote: /builddir/build/SRPMS/\(.*\)_\1_')

print_info "Source package created: $srpm"
print_info "Source package created"
fi

srpm=$(grep -e 'Wrote: .*\.src\.rpm' $OUTDIR/build.log 2>/dev/null |
sed 's_Wrote: /builddir/build/SRPMS/\(.*\)_\1_')

if [ "$srpm_only" -eq "1" ]
then
exit 0
@@ -161,25 +175,34 @@ fi
# Create packages for every ARCH defined in the config file
for arch in "${ARCHS[@]}"
do :
print_info "Building packages for $arch"
if [ -f $OUTDIR/$arch/build.log ]
if [ -f $OUTDIR/$srpm ]
then
print_info "Cleaning log file"
rm $OUTDIR/$arch/build.log
fi
mkdir $OUTDIR/$arch

if ! mock -r $arch --rebuild $OUTDIR/$srpm \
--define "_relver $relver" \
--define "_version $version" \
--define "_timestamp $timestamp" \
--resultdir=$OUTDIR/$arch $mock_args
then
print_error "Package creation for $arch failed. Abort"
exit 1
print_info "Building $srpm for $arch"
if [ -d $OUTDIR/$arch ]
then
if [ -f $OUTDIR/$arch/build.log ]
then
print_info "Cleaning log file"
rm $OUTDIR/$arch/build.log
fi
else
mkdir $OUTDIR/$arch
fi
if ! mock -r $arch --rebuild $OUTDIR/$srpm \
--define "_relver $relver" \
--define "_version $version" \
--define "_timestamp $timestamp" \
--resultdir=$OUTDIR/$arch $mock_args
then
print_error "Package creation for $arch failed. Abort"
exit 1
else
# Add to package list
packages="$packages $(ls $OUTDIR/$arch/*-$version-$relver.*.rpm)"
fi
else
# Add to package list
packages="$packages $(ls $OUTDIR/$arch/*-$version-$relver.*.rpm)"
print_error "Source package unavailable. Abort"
exit 1
fi
done

@@ -6,14 +6,16 @@
# maintainer.

# Where should the results go
OUTDIR="result/"
OUTDIR="result"

# Which arches to build for. Check /etc/mock for possible options
ARCHS=(
"fedora-28-i386"
"fedora-28-x86_64"
"fedora-29-i386"
"fedora-29-x86_64"
"fedora-30-i386"
"fedora-30-x86_64"
)

# Which git branch to export. Normally take the current
@@ -253,7 +253,7 @@ rm -f %{buildroot}%{_datadir}/%{name}/doc/INSTALL*

%find_lang %{name} --with-qt

# TODO: Remove after F28 EoL
# TODO: Remove all %%post, %%posttrans and %%postun after F28 EoL
# Ref: https://fedoraproject.org/wiki/Changes/RemoveObsoleteScriptlets
%post
/sbin/ldconfig
@@ -281,8 +281,6 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :

%postun -n python3-qgis -p /sbin/ldconfig

# END TODO #

%files -f %{name}.lang
%doc BUGS NEWS Exception_to_GPL_for_Qt.txt ChangeLog.gz
# QGIS shows the following files in the GUI, including the license text

0 comments on commit 74e8207

Please sign in to comment.
You can’t perform that action at this time.