2013-11-19 21:31:19 +01:00
|
|
|
#!/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
|
2015-09-26 03:47:30 +02:00
|
|
|
echo "$(echo "$0" | rev | cut -d "/" -f 1-1 | rev) -- build Debian packages on a Zulip buildslave"
|
2013-11-19 21:31:19 +01:00
|
|
|
echo
|
|
|
|
echo "USAGE: $0 dist path/to/package.dsc"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -xe
|
|
|
|
|
|
|
|
ret=0
|
2015-09-26 03:47:30 +02:00
|
|
|
path=$(ssh -q -l "$BUILDD_USERNAME" "$BUILDD_HOST" -- "mktemp -d '$BUILDD_BASE_PATH/$USER.`date -u +%F.%R`.XXXXXXX'")/
|
2013-11-19 21:31:19 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
dcmd rsync -vz --copy-links "$file" "$BUILDD_USERNAME@$BUILDD_HOST:$path/"
|
|
|
|
file=$(basename "$file")
|
2013-11-19 21:31:19 +01:00
|
|
|
|
|
|
|
# -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.
|
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
ssh -t -l "$BUILDD_USERNAME" "$BUILDD_HOST" -- "cd '$path' && sbuild -A -s --force-orig-source '--dist=$dist' --arch=amd64 '$file'"
|
2013-11-19 21:31:19 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
rsync -Lvz --copy-links "$BUILDD_USERNAME@$BUILDD_HOST:$path/*" .
|
|
|
|
ssh -l "$BUILDD_USERNAME" "$BUILDD_HOST" rm -r "$path"
|
2013-11-19 21:31:19 +01:00
|
|
|
|
2015-09-26 03:47:30 +02:00
|
|
|
exit "$ret"
|