fix: build ooniprobe for linux using debian/amd64 (#552) (#553)

In https://github.com/ooni/probe/issues/1741, we observed that
every attempt to use `docker --platform` along with `debian` for
packaging ooniprobe fails with `SEGFAULT`, except when using
the `debian:oldstable` container.

To fix this issue, in this diff we fix Debian packaging to run on
any debian system (`debian:stable` in our case) provided that we
have `qemu-user-static` installed on the system and the system is
a Debian (or Debian-derived) system.

The trick here is to use `dpkg-buildpackage -a $deb_arch`. We
also need to disable a few `debian/rules` that we don't actually
need anyway.

Closes https://github.com/ooni/probe/issues/1741.

This cherry-picks 36a5bf34f99f382a081efd642dd472888a57602b
from the stable branch into the master branch.
This commit is contained in:
Simone Basso
2021-10-22 15:14:11 +02:00
committed by GitHub
parent 9848f3713e
commit 638acb0830
4 changed files with 48 additions and 30 deletions
+26 -22
View File
@@ -7,8 +7,9 @@
# 1. the `ooniprobe` we are packaging is available at
# this path `./CLI/linux/$GOARCH/ooniprobe`;
#
# 2. we are running on a debian system that has the same
# architecture of the `ooniprobe` we are packaging.
# 2. we are running on a debian system that is capable
# of running binaries for the architecture that we wanna
# package, either natively or via qemu-user-static.
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
echo "usage: $0 {arch} [run_number]" 1>&2
@@ -31,26 +32,6 @@ if [ -n "$run_number" ]; then
version="${version}~${run_number}"
fi
# The OONI_DEB_DRY_RUN is a semi-undocumented feature allowing
# us to see the commands that would be run by this script.
# install the dependencies required by the build process
$OONI_DEB_DRY_RUN apt-get update -q
$OONI_DEB_DRY_RUN apt-get build-dep -y --no-install-recommends .
# keep the original changelog file safe
$OONI_DEB_DRY_RUN cp ./debian/changelog ./debian/changelog.oocopy
$OONI_DEB_DRY_RUN dch -v "$version" "New version ${version}"
$OONI_DEB_DRY_RUN dpkg-buildpackage -us -uc -b
# restore the original changelog file
$OONI_DEB_DRY_RUN mv ./debian/changelog.oocopy ./debian/changelog
# move the package so that we don't loose track
# of it when using a build container
$OONI_DEB_DRY_RUN mv ../*.deb .
darch=""
case $goarch in
386)
@@ -66,6 +47,29 @@ arm64)
darch="arm64"
;;
esac
echo "Building for GOARCH=$goarch / DEBARCH=$darch"
# The OONI_DEB_DRY_RUN is a semi-undocumented feature allowing
# us to see the commands that would be run by this script.
$OONI_DEB_DRY_RUN dpkg --add-architecture $darch
# install the dependencies required by the build process
$OONI_DEB_DRY_RUN apt-get update -q
$OONI_DEB_DRY_RUN apt-get build-dep -y --no-install-recommends .
# keep the original changelog file safe
$OONI_DEB_DRY_RUN cp ./debian/changelog ./debian/changelog.oocopy
$OONI_DEB_DRY_RUN dch -v "$version" "New version ${version}"
$OONI_DEB_DRY_RUN dpkg-buildpackage -a $darch -us -uc -b
# restore the original changelog file
$OONI_DEB_DRY_RUN mv ./debian/changelog.oocopy ./debian/changelog
# move the package so that we don't loose track
# of it when using a build container
$OONI_DEB_DRY_RUN mv ../*.deb .
# install the package on the container as a smoke test to
# ensure that it is installable.