zulip/tools/build-deb

47 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# build-deb -- Build a pacakge on a remote system with sbuild, then copy it back.
#
# Inspired by https://www.cs.unb.ca/~bremner/blog/posts/remote_sbuild/ which
# was itself adapted from cowpoke(1) from the "devscripts" package.
BUILDD_USERNAME=zulip
BUILDD_HOST=build0.zulip.net
BUILDD_BASE_PATH=/home/zulip/ubuntu/build/
dist=$1
file=$2
if [ -z "$dist" ] || [ -z "$file" ]; then
echo "$(echo $0 | rev | cut -d "/" -f 1-1 | rev) -- build Debian packages on a Zulip buildslave"
echo
echo "USAGE: $0 dist path/to/package.dsc"
exit 1
fi
set -xe
ret=0
path=$(ssh -q -l $BUILDD_USERNAME $BUILDD_HOST -- mktemp -d $BUILDD_BASE_PATH/$USER.`date -u +%F.%R`.XXXXXXX)/
dcmd rsync -vz --copy-links $file $BUILDD_USERNAME@$BUILDD_HOST:$path/
file=$(basename $file)
# -A specifies to build arch-all packages (non-arch dependent) in addition to
# binary packages
#
# -s specifies the resultant .changes should also include a rebuilt source package
#
# --force-orig-source means the .changes will have a .orig.tar.* with it, which
# otherwise we might omit. We need the orig source when including in our
# repository even though dpkg-buildpackage might think otherwise, because the
# original version of the package was usually not included in our repository.
#
# We always build for amd64. There is no 32-bit.
ssh -t -l $BUILDD_USERNAME $BUILDD_HOST -- "cd $path && sbuild -A -s --force-orig-source --dist=$dist --arch=amd64 $file"
rsync -Lvz --copy-links $BUILDD_USERNAME@$BUILDD_HOST:$path/* .
ssh -l $BUILDD_USERNAME $BUILDD_HOST rm -r $path
exit $ret