From 491f47f9ad93e65f1f0107bd56b50d6b3f12a50d Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 20 Sep 2024 19:04:14 -0700 Subject: [PATCH 1/2] Add a script to help debug the debian package builder --- scripts/test-build-debian-package.sh | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 scripts/test-build-debian-package.sh diff --git a/scripts/test-build-debian-package.sh b/scripts/test-build-debian-package.sh new file mode 100755 index 0000000000..73481bfc9c --- /dev/null +++ b/scripts/test-build-debian-package.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +# This is a file for testing the github.com/stellar/package +# debian packaging of stellar-core without running it through +# the full build pipeline. It's for debugging. + +if [ ! -e stellar-core/autogen.sh ] +then + echo run this from one level above the stellar-core/ directory + exit 1 +fi + +if [ ! -e packages/stellar-core/debian ] +then + echo run this with the packages/ directory checked out as well + exit 1 +fi + +echo "info: installing script dependencies" +sudo apt install ubuntu-dev-tools pbuilder dh-make debootstrap devscripts dpkg-dev debhelper build-essential + +export BUILD_VERSION=999 +export DEBEMAIL=packages@stellar.org +export DEBFULLNAME='Package Maintainer' +export DISTRO=jammy + +cd stellar-core +GIT_VERS=$(git describe --tag) +CORE_VERSION=${GIT_VERS%%-*} +CORE_VERSION=${CORE_VERSION#v} +cd .. + +export FULL_VERSION=${CORE_VERSION}-${BUILD_VERSION} + +echo "info: core version: ${CORE_VERSION} build version: ${BUILD_VERSION}" +echo "info: preparing code directory stellar-core-${CORE_VERSION}" +rm -rf stellar-core-${CORE_VERSION} +cp -r stellar-core stellar-core-${CORE_VERSION} + +echo "info: creating upstream tarball stellar-core-${CORE_VERSION}.tar.gz" +tar czf stellar-core-${CORE_VERSION}.tar.gz stellar-core-${CORE_VERSION} + +echo 'info: copying packaging files to the code directory' +cp -rv packages/stellar-core/debian stellar-core-${CORE_VERSION}/ + +if [ ! -e stellar-core-${CORE_VERSION}/debian ] +then + echo copy of debian files into stellar-core-${CORE_VERSION}/debian failed + exit 1 +fi + +# These variables are used in src/Makefile.am +export LOCAL_PACKAGE=stellar-core +export LOCAL_VERSION=${CORE_VERSION} +export GIT_COMMIT=$(cd stellar-core-$CORE_VERSION && git rev-parse HEAD) + +echo "info: updating changelog to match $FULL_VERSION" +dch --changelog stellar-core-$CORE_VERSION/debian/changelog --distribution ${DISTRO} --newversion="${FULL_VERSION}" "New stellar-core build" +cd stellar-core-$CORE_VERSION/ +echo "info: creating upstream tarball, etc" +dh_make -ysf ../stellar-core-$CORE_VERSION.tar.gz + +if [ -f /var/cache/pbuilder/base-${DISTRO}.tgz ]; then + echo "info: updating base-${DISTRO}.tgz" + sudo /usr/bin/pbuilder-dist ${DISTRO} update --updates-only --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --debootstrapopts --variant=buildd +else + echo "info: creating base-${DISTRO}.tgz" + sudo /usr/bin/pbuilder-dist ${DISTRO} create --updates-only --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --debootstrapopts --variant=buildd +fi + +# build the package +echo 'info: Starting package build' +/usr/bin/pdebuild --debbuildopts -b -- --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --distribution ${DISTRO} --use-network yes From 49cc02bb0585d65fa757010e53073d143922c0b0 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 20 Sep 2024 20:59:49 -0700 Subject: [PATCH 2/2] improve script --- scripts/test-build-debian-package.sh | 39 ++++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/scripts/test-build-debian-package.sh b/scripts/test-build-debian-package.sh index 73481bfc9c..c33bba3d10 100755 --- a/scripts/test-build-debian-package.sh +++ b/scripts/test-build-debian-package.sh @@ -22,7 +22,11 @@ sudo apt install ubuntu-dev-tools pbuilder dh-make debootstrap devscripts dpkg-d export BUILD_VERSION=999 export DEBEMAIL=packages@stellar.org export DEBFULLNAME='Package Maintainer' -export DISTRO=jammy +export DISTRO=${DISTRO:-jammy} + +export DEB_CXXFLAGS_SET=${DEB_CXXFLAGS_SET:-'-ggdb -O3 -fstack-protector-strong -Wformat -Werror=format-security'} +export DEB_CFGLAGS_SET=${DEB_CFLAGS_SET:-'-ggdb -O3 -fstack-protector-strong -Wformat -Werror=format-security'} +export DEB_CONFIGURE_OPTS=${DEB_CONFIGURE_OPTS:-'--enable-tracy --enable-asan'} cd stellar-core GIT_VERS=$(git describe --tag) @@ -33,7 +37,7 @@ cd .. export FULL_VERSION=${CORE_VERSION}-${BUILD_VERSION} echo "info: core version: ${CORE_VERSION} build version: ${BUILD_VERSION}" -echo "info: preparing code directory stellar-core-${CORE_VERSION}" +echo "info: preparing code directory stellar-core-${CORE_VERSION}" rm -rf stellar-core-${CORE_VERSION} cp -r stellar-core stellar-core-${CORE_VERSION} @@ -52,22 +56,29 @@ fi # These variables are used in src/Makefile.am export LOCAL_PACKAGE=stellar-core export LOCAL_VERSION=${CORE_VERSION} -export GIT_COMMIT=$(cd stellar-core-$CORE_VERSION && git rev-parse HEAD) +export GIT_COMMIT=$(cd stellar-core-${CORE_VERSION} && git rev-parse HEAD) echo "info: updating changelog to match $FULL_VERSION" dch --changelog stellar-core-$CORE_VERSION/debian/changelog --distribution ${DISTRO} --newversion="${FULL_VERSION}" "New stellar-core build" -cd stellar-core-$CORE_VERSION/ +cd stellar-core-${CORE_VERSION}/ echo "info: creating upstream tarball, etc" -dh_make -ysf ../stellar-core-$CORE_VERSION.tar.gz +dh_make -ysf ../stellar-core-${CORE_VERSION}.tar.gz -if [ -f /var/cache/pbuilder/base-${DISTRO}.tgz ]; then - echo "info: updating base-${DISTRO}.tgz" - sudo /usr/bin/pbuilder-dist ${DISTRO} update --updates-only --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --debootstrapopts --variant=buildd +if [ -z "${USE_PBUILDER}" ] +then + echo 'info: Doing simple package build with dpkg-buildpackage in stellar-core-${CORE_VERSION}' + dpkg-buildpackage -us -uc -nc else - echo "info: creating base-${DISTRO}.tgz" - sudo /usr/bin/pbuilder-dist ${DISTRO} create --updates-only --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --debootstrapopts --variant=buildd -fi + echo 'info: Doing hermetic package build using pbuilder' + if [ -f /var/cache/pbuilder/base-${DISTRO}.tgz ]; then + echo "info: updating base-${DISTRO}.tgz" + sudo /usr/bin/pbuilder-dist ${DISTRO} update --updates-only --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --debootstrapopts --variant=buildd + else + echo "info: creating base-${DISTRO}.tgz" + sudo /usr/bin/pbuilder-dist ${DISTRO} create --updates-only --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --debootstrapopts --variant=buildd + fi -# build the package -echo 'info: Starting package build' -/usr/bin/pdebuild --debbuildopts -b -- --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --distribution ${DISTRO} --use-network yes + # build the package + echo 'info: Starting package build' + /usr/bin/pdebuild --debbuildopts -b -- --basetgz /var/cache/pbuilder/base-${DISTRO}.tgz --distribution ${DISTRO} --use-network yes +fi