987288b
1057693
9cc53ba
1057693
9cc53ba
1057693
987288b
1057693
9cc53ba
43b8c90
1869918
43b8c90
1869918
43b8c90
1869918
43b8c90
1057693
9cc53ba
2f1d8dc
551c3a8
2f1d8dc
a0c73b1
551c3a8
2f1d8dc
551c3a8
1057693
9cc53ba
1057693
60864af
1057693
89617f5
9cc53ba
89617f5
1057693
c7386c9
1057693
581335d
1057693
95bfde4
9cc53ba
95bfde4
e3985de
4a5c588
95bfde4
4a5c588
987288b
95bfde4
e3985de
4a5c588
9cc53ba
95bfde4
9cc53ba
1057693
9cc53ba
1057693
|
| #!/bin/bash
set -e
SCRIPTDIR="$(dirname $(readlink -f "$0"))"
abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
report() { for i in "$@"; do echo >&2 "debcargo-conf builder: $i"; done; }
if [ "$(basename "$PWD")" != "build" ]; then
abort 1 "This script is only meant to be run from the build/ directory."
fi
if [ -n "$DEBCARGO" ]; then
true
elif which debcargo >/dev/null; then
DEBCARGO=$(which debcargo)
elif [ -f "$HOME/.cargo/bin/debcargo" ]; then
DEBCARGO="$HOME/.cargo/bin/debcargo"
else
abort 1 "debcargo not found, run \`cargo install debcargo\` or set DEBCARGO to point to it"
fi
CRATE="$1"
VER="$2"
if test -z "$VER" -o -f "$VER"; then
VER=""
shift
else
shift 2
fi
DISTRIBUTION="${DISTRIBUTION:-unstable}"
PKGNAME=$($DEBCARGO deb-src-name "$CRATE" $VER || abort 1 "couldn't find crate $CRATE")
DEBVER=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SVersion)
DEBSRC=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SSource)
DEBDIST=$(dpkg-parsechangelog -l $PKGNAME/debian/changelog -SDistribution)
DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH)
SRCNAME="${DEBSRC}_${DEBVER}"
BUILDNAME="${DEBSRC}_${DEBVER}_${DEB_HOST_ARCH}"
if [ -z "$CHROOT" ]; then
if schroot -i -c "debcargo-unstable-${DEB_HOST_ARCH}-sbuild" >/dev/null 2>&1; then
CHROOT="debcargo-unstable-${DEB_HOST_ARCH}-sbuild"
elif schroot -i -c "unstable-${DEB_HOST_ARCH}-sbuild" >/dev/null 2>&1; then
CHROOT="unstable-${DEB_HOST_ARCH}-sbuild"
echo >&2 "Automatically using sbuild chroot unstable-${DEB_HOST_ARCH}-sbuild; however it's"
echo >&2 "strongly recommended to create a separate chroot debcargo-unstable-${DEB_HOST_ARCH}-sbuild"
echo >&2 "so your builds won't have to re-download & re-install cargo, rustc, and llvm every time."
echo >&2 "See README.rst section \"Build environment\" for details."
sleep 1
elif [ "$SOURCEONLY" != 1 ]; then
abort 1 "could not automatically find a suitable chroot; set CHROOT"
fi
fi
shouldbuild() {
local dst="$1"
local src="$2"
test ! -e "$dst" -o "$src" -nt "$dst"
}
if shouldbuild "$SRCNAME.dsc" "$PKGNAME/debian/changelog" ]; then
if [ "$REUSE_EXISTING_ORIG_TARBALL" = 1 ]; then
UPSVER="${DEBVER%-*}"
mv "${DEBSRC}_${UPSVER}.orig.tar.gz" "${DEBSRC}_${UPSVER}.orig.tar.gz.new"
apt-get -t unstable source --download-only "${DEBSRC}" # "=${DEBVER}"
# check that old tarball contains same contents as new tarball
if ! diff -ru \
--label "${DEBSRC}_${UPSVER}.orig.tar.gz.new" \
<(zcat "${DEBSRC}_${UPSVER}.orig.tar.gz.new" | tar -tvvf-) \
--label "${DEBSRC}_${UPSVER}.orig.tar.gz" \
<(zcat "${DEBSRC}_${UPSVER}.orig.tar.gz" | tar -tvvf-); then
read -p "contents differ, continue with old tarball or abort? [y/N] " x
if [ "$x" != "y" ]; then exit 1; fi
fi
# extract old tarball into new directory, to avoid "modified files" problems with dpkg-source later
( cd "$PKGNAME" && dpkg-source --after-build . && tar --strip-components=1 -xf "../${DEBSRC}_${UPSVER}.orig.tar.gz" )
fi
( cd "$PKGNAME" && dpkg-buildpackage -d -S --no-sign )
# sign if not UNRELEASED
if echo "$DEBDIST" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
debsign "${SRCNAME}_source.changes"
fi
fi
check_build_deps() {
mkdir -p dpkg-dummy
if shouldbuild dpkg-dummy/status /var/cache/apt/pkgcache.bin; then
# pretend dpkg status file that marks all packages as installed
# this is because dpkg-checkbuilddeps only works on installed pkgs
apt-cache dumpavail -o APT::Default-Release=unstable | \
sed -e 's/Package: .*/\0\nStatus: install ok installed/g' > dpkg-dummy/status
if ! test -s dpkg-dummy/status; then
abort 1 "couldn't generate dpkg-dummy/status, is Debian unstable in your APT sources?"
fi
fi
( cd "$PKGNAME" && dpkg-checkbuilddeps --admindir=../dpkg-dummy )
}
if ! check_build_deps; then
if [ "$IGNORE_MISSING_BUILD_DEPS" != 1 ]; then
abort 1 "Missing build-dependencies, but maybe try '{apt,cargo} update'"
fi
fi
if [ "$SOURCEONLY" = 1 ]; then
exit
fi
EXTRA_DEBS=( "$@" )
if [ -n "${EXTRA_DEBS[*]}" ]; then
EXTRA_DEBS_SBUILD=("${EXTRA_DEBS[@]/#/--extra-package=}")
EXTRA_DEBS_REPO_TMP=$(mktemp -d "${SRCNAME}_REPO_XXXXXXXX")
# symlinks don't work here
ln -f "${EXTRA_DEBS[@]}" "$EXTRA_DEBS_REPO_TMP/"
( cd "$EXTRA_DEBS_REPO_TMP"; apt-ftparchive packages . > Packages )
EXTRA_DEBS_AUTOPKGTEST_OPTS=([0]=--autopkgtest-opt=--copy="$PWD/$EXTRA_DEBS_REPO_TMP/:/tmp/$EXTRA_DEBS_REPO_TMP/" [1]=--autopkgtest-opt=--add-apt-source="deb [trusted=yes] file:///tmp/$EXTRA_DEBS_REPO_TMP ./")
fi
AUTOPKGTEST_OPTS=("--run-autopkgtest" "--autopkgtest-root-arg=" "--autopkgtest-opts=-- schroot ${CHROOT}")
if [ "$SKIP_AUTOPKGTEST" = 1 ]; then
AUTOPKGTEST_OPTS=()
EXTRA_DEBS_AUTOPKGTEST_OPTS=()
fi
LINTIAN_OPTS=()
if echo "$DEBDIST" | grep -q UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
LINTIAN_OPTS=([0]="--lintian-opt=--suppress-tags" [1]="--lintian-opt=bad-distribution-in-changes-file")
fi
sbuild --no-source --arch-any --arch-all \
${CHROOT:+-c $CHROOT} \
${DISTRIBUTION:+-d $DISTRIBUTION} \
"${EXTRA_DEBS_SBUILD[@]}" \
"${EXTRA_DEBS_AUTOPKGTEST_OPTS[@]}" \
"${AUTOPKGTEST_OPTS[@]}" \
"${LINTIAN_OPTS[@]}" \
"$SRCNAME.dsc"
if [ "$SKIP_AUTOPKGTEST" != 1 ]; then
report "analyzing autopkgtest log: $BUILDNAME.test.log"
# this is a bit of a hack but works OK for now, until sbuild supports %SBUILD_BUILD_DIR in --autopkgtest-opt
sed -ne '/autopkgtest .*: testing package .* version .*/,$p' "$BUILDNAME.build" > "$BUILDNAME.test.log"
"$SCRIPTDIR/dev/rust-regressions.sh" "$BUILDNAME.test.log"
fi
if [ -d "$EXTRA_DEBS_REPO_TMP" ]; then
rm -rf "$EXTRA_DEBS_REPO_TMP";
fi
changestool "$BUILDNAME.changes" adddsc "$SRCNAME.dsc"
report "build complete: $BUILDNAME.changes"
# sign if not UNRELEASED
if echo "$DEBDIST" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then
debsign ${DEBSIGN_KEYID:+-k $DEBSIGN_KEYID }--no-re-sign "$BUILDNAME.changes"
fi
|
|