build-system: update Ubuntu/Debian package script

This cleans up a lot of the ancient mess in that file.

It's still confusingly usable to push sources to OBS as well (but that's now
hidden behind an option) and it is still somewhat custom-made for me, but it
should be much easier to reuse for others now.

In addition to Subsurface and libdivecomputer we are inclooding the googlemaps
sources and libgit2 1.0.0 sources. Bionic is the only remaining distro that we
support that doesn't have a new enough version of libgit2 (0.26 is the minimum
we expect), but since we are linking statically against it, maybe it's best to
simply force all of these builds to include libgit2 1.0.0.

Handling of the debian/* files in the script has been changed quite a bit to
make it easier for others to create a working setup. It now updates all of the
files with the exception of the changelog files from the sources we are
building from. I am hoping that this will be a not-so-subtle incentive for me
to keep the bundled versions up to date.

Since we no longer do beta releases, I removed that part from the file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-04-18 14:50:53 -07:00
parent 29884ba307
commit b38138fd0d

View file

@ -1,17 +1,38 @@
#!/bin/bash -e #!/bin/bash -e
# start from the directory above the combined subsurface & subsurface/libdivecomputer directory # start from the directory above the subsurface directory
# #
# in order to be able to make changes to the debian/* files without changing the source # we need to build the google maps plugin which is not part of our sources, so let's make sure
# this script assumes that the debian/* files plus a separate debian.changelog are in # it is included in our source tar file
# this directory as well - this makes testing builds on launchpad easier
# for most people all it should take is to run
# cp -a packaging/ubuntu/debian .
# #
if [[ $(pwd | grep "subsurface$") || ! -d subsurface || ! -d subsurface/libdivecomputer || ! -d subsurface/libgit2 ]] ; then # also, for bionic we need newer versions of libgit2 than what ships with the
# distro, so let's just use libgit2 1.0 everywhere
if [[ $(pwd | grep "subsurface$") || ! -d subsurface || ! -d subsurface/libdivecomputer ]] ; then
echo "Please start this script from the folder ABOVE the subsurface source directory" echo "Please start this script from the folder ABOVE the subsurface source directory"
echo "which includes libdivecomputer and libgit2 as subdirectories)."
exit 1; exit 1;
fi fi
if [[ ! -d googlemaps ]] ; then
echo "Please make sure you have the current master of git://github.com/Subsurface-divelog/googlemaps"
echo "checked out in parallel to the Subsurface directory"
exit 1;
fi
if [[ ! -d libgit2 ]] ; then
echo "Please make sure you have libgit2 1.0 from git://github.com/libgit2/libgit2"
echo "checked out in parallel to the Subsurface directory"
exit 1;
fi
if [[ "$1" = "-obs" ]] ; then
echo "Also pushing update to OBS"
OBS="1"
fi
# ensure that the libdivecomputer module is there and current
cd subsurface
git submodule init
git submodule update
cd -
GITVERSION=$(cd subsurface ; git describe --abbrev=12 | sed -e 's/-g.*$// ; s/^v//') GITVERSION=$(cd subsurface ; git describe --abbrev=12 | sed -e 's/-g.*$// ; s/^v//')
GITREVISION=$(echo $GITVERSION | sed -e 's/.*-// ; s/.*\..*//') GITREVISION=$(echo $GITVERSION | sed -e 's/.*-// ; s/.*\..*//')
@ -19,56 +40,79 @@ VERSION=$(echo $GITVERSION | sed -e 's/-/./')
GITDATE=$(cd subsurface ; git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d) GITDATE=$(cd subsurface ; git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d)
LIBDCREVISION=$(cd subsurface/libdivecomputer ; git rev-parse --verify HEAD) LIBDCREVISION=$(cd subsurface/libdivecomputer ; git rev-parse --verify HEAD)
# if [[ "$GITVERSION" = "" ]] ; then
# SUFFIX=".release"
else
SUFFIX=".daily"
fi
echo "building Subsurface" $VERSION "with libdivecomputer" $LIBDCREVISION echo "building Subsurface" $VERSION "with libdivecomputer" $LIBDCREVISION
#
# we put all of the files into the distrobuilds directory in order not to clutter the 'src' directory
mkdir -p distrobuilds
cd distrobuilds
if [[ ! -d subsurface_$VERSION ]]; then if [[ ! -d subsurface_$VERSION ]]; then
mkdir subsurface_$VERSION mkdir subsurface_$VERSION
if [[ "x$GITREVISION" != "x" ]] ; then if [[ "$GITREVISION" != "" ]] ; then
rm -f subsurfacedaily-$VERSION rm -f subsurfacedaily-$VERSION
ln -s subsurface_$VERSION subsurfacedaily-$VERSION ln -s subsurface_$VERSION subsurfacedaily-$VERSION
else else
rm -f subsurfacebeta-$VERSION rm -f subsurface-$VERSION
ln -s subsurface_$VERSION subsurfacebeta-$VERSION ln -s subsurface_$VERSION subsurface-$VERSION
fi fi
#
#
echo "copying sources" echo "copying sources"
#
(cd subsurface ; tar cf - . ) | (cd subsurface_$VERSION ; tar xf - ) (cd ../subsurface ; tar cf - . ) | (cd subsurface_$VERSION ; tar xf - )
cd subsurface_$VERSION; cd subsurface_$VERSION;
rm -rf .git libdivecomputer/.git libgit2/.git cp -a ../../googlemaps .
cp -a ../../libgit2 .
# now make sure we have libgit2 1.0
cd libgit2
git fetch
git checkout v1.0.0
cd ..
rm -rf .git libdivecomputer/.git googlemaps/.git build build-mobile libdivecomputer/build googlemaps/build libgit2/.git libgit2/build
echo $GITVERSION > .gitversion echo $GITVERSION > .gitversion
echo $GITDATE > .gitdate echo $GITDATE > .gitdate
echo $LIBDCREVISION > libdivecomputer/revision echo $LIBDCREVISION > libdivecomputer/revision
# dh_make --email dirk@hohndel.org -c gpl2 --createorig --single --yes -p subsurface_$VERSION
# rm debian/*.ex debian/*.EX debian/README.* if [[ "$OBS" = "1" ]]; then
# # oops, this isn't really for Debian/Ubuntu... it just creates corresponding source tar files for
# # the Open Build Service to create SUSE and Fedora packages while we are at it
echo "creating source tar file for OBS and Ununtu PPA" if [[ "$GITREVISION" != "" ]] ; then
#
if [[ "x$GITREVISION" != "x" ]] ; then
(cd .. ; tar ch subsurfacedaily-$VERSION | xz > home:Subsurface-Divelog/Subsurface-daily/subsurface-$VERSION.orig.tar.xz) & (cd .. ; tar ch subsurfacedaily-$VERSION | xz > home:Subsurface-Divelog/Subsurface-daily/subsurface-$VERSION.orig.tar.xz) &
else else
(cd .. ; tar ch subsurfacebeta-$VERSION | xz > home:Subsurface-Divelog/Subsurface-beta/subsurface-$VERSION.orig.tar.xz) & (cd .. ; tar ch subsurface-$VERSION | xz > home:Subsurface-Divelog/Subsurface/subsurface-$VERSION.orig.tar.xz) &
fi fi
fi
echo "creating source tar file for OBS and Ununtu PPA"
tar cf - . | xz > ../subsurface_$VERSION.orig.tar.xz tar cf - . | xz > ../subsurface_$VERSION.orig.tar.xz
else else
echo "using existing source tree" echo "using existing source tree"
cd subsurface_$VERSION cd subsurface_$VERSION
fi fi
#
#
echo "preparint the debian directory" echo "preparing the debian directory"
#
export DEBEMAIL=dirk@hohndel.org # this uses my (Dirk's) email address by default... simply set that variable in your
# environment prior to starting the script
test -z $DEBEMAIL && export DEBEMAIL=dirk@hohndel.org
# copy over the debian files and allow maintaining a release and daily changelog files
rm -rf debian rm -rf debian
mkdir -p debian mkdir -p debian
cp -a ../debian . cp -a ../../subsurface/packaging/ubuntu/debian .
cp ../debian.changelog debian/changelog
# start with the bundled dummy changelog, but use our last one if it exists
test -f ../changelog$SUFFIX && cp ../changelog$SUFFIX debian/changelog
# pick a new revision number
rev=0 rev=0
while [ $rev -le "99" ] while [ $rev -le "99" ]
do do
@ -77,19 +121,21 @@ rev=$(($rev+1))
break break
fi fi
done done
if [[ "$RELEASE" = "1" ]] ; then
dch -v $VERSION-$rev~xenial -D xenial -M -m "Next release build - please check https://subsurface-divelog.org/category/news/ for details" # we need to do this for each Ubuntu release we support - right now the oldest is 16.04/Xenial
if [[ "$GITREVISION" = "" ]] ; then
dch -v $VERSION-$rev~bionic -D bionic -M -m "Next release build - please check https://subsurface-divelog.org/category/news/ for details"
else else
dch -v $VERSION-$rev~xenial -D xenial -M -m "next daily build" dch -v $VERSION-$rev~bionic -D bionic -M -m "next daily build"
fi fi
mv ~/src/debian.changelog ~/src/debian.changelog.previous
cp debian/changelog ~/src/debian.changelog cp debian/changelog ../changelog$SUFFIX
debuild -S debuild -S
#create builds for the newer Ubuntu releases that Launchpad supports #create builds for the newer Ubuntu releases that Launchpad supports
rel=xenial rel=bionic
others="artful bionic" others="eoan focal"
for next in $others for next in $others
do do
sed -i "s/${rel}/${next}/g" debian/changelog sed -i "s/${rel}/${next}/g" debian/changelog
@ -99,19 +145,26 @@ done
cd .. cd ..
if [[ "$1x" = "postx" ]] ; then if [[ "$1" = "post" ]] ; then
# daily vs. beta vs. release # daily vs. release
if [[ "x$GITREVISION" == "x" ]] ; then if [[ "$GITREVISION" == "" ]] ; then
# this is a beta or a release; assume beta for now and deal with release later :-) # this is a release
dput ppa:subsurface/subsurface-beta subsurface_$VERSION-$rev~*.changes dput ppa:subsurface/subsurface subsurface_$VERSION-$rev~*.changes
cd home:Subsurface-Divelog/Subsurface-beta
if [[ "$OBS" = "1" ]]; then
# more stuff for OBS / SUSE / Fedora
cd home:Subsurface-Divelog/Subsurface
osc rm $(ls subsurface*.tar.xz | grep -v $VERSION) osc rm $(ls subsurface*.tar.xz | grep -v $VERSION)
osc add subsurface-$VERSION.orig.tar.xz osc add subsurface-$VERSION.orig.tar.xz
sed -i "s/%define latestVersion.*/%define latestVersion $VERSION/" subsurfacebeta.spec sed -i "s/%define latestVersion.*/%define latestVersion $VERSION/" subsurface.spec
sed -i "s/%define gitVersion .*/%define gitVersion 0/" subsurfacebeta.spec sed -i "s/%define gitVersion .*/%define gitVersion 0/" subsurface.spec
osc commit -m "next beta build" osc commit -m "next release build"
fi
else else
dput ppa:subsurface/subsurface-daily subsurface_$VERSION-$rev~*.changes dput ppa:subsurface/subsurface-daily subsurface_$VERSION-$rev~*.changes
if [[ "$OBS" = "1" ]]; then
# more stuff for OBS / SUSE / Fedora
cd home:Subsurface-Divelog/Subsurface-daily cd home:Subsurface-Divelog/Subsurface-daily
osc rm $(ls subsurface*.tar.xz | grep -v $VERSION) osc rm $(ls subsurface*.tar.xz | grep -v $VERSION)
osc add subsurface-$VERSION.orig.tar.xz osc add subsurface-$VERSION.orig.tar.xz
@ -119,4 +172,5 @@ if [[ "$1x" = "postx" ]] ; then
sed -i "s/%define gitVersion .*/%define gitVersion $GITREVISION/" subsurfacedaily.spec sed -i "s/%define gitVersion .*/%define gitVersion $GITREVISION/" subsurfacedaily.spec
osc commit -m "next daily build" osc commit -m "next daily build"
fi fi
fi
fi fi