Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a script to help debug the debian package builder #4477

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions scripts/test-build-debian-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/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 [email protected]
export DEBFULLNAME='Package Maintainer'
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)
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 [ -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: 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
fi
Loading