From 63c0c8ed89e1564294ff174b819e520d5977f499 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Sun, 27 Sep 2020 11:08:13 +0200 Subject: debian: Update tools/build-debian-package.sh to use git-buildpackage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ondřej Surý --- debian/changelog | 6 +++++ tools/build-debian-package.sh | 53 ++++++++++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index bf51c5cfb..a742cab4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +frr (7.6~dev-1) UNRELEASED; urgency=medium + + * Update tools/build-debian-package.sh to use git-buildpackage + + -- Ondřej Surý Sun, 27 Sep 2020 11:33:44 +0200 + frr (7.4-1) unstable; urgency=medium [ Ondřej Surý ] diff --git a/tools/build-debian-package.sh b/tools/build-debian-package.sh index d21f468bf..bd87ac057 100755 --- a/tools/build-debian-package.sh +++ b/tools/build-debian-package.sh @@ -4,24 +4,51 @@ # This file is public domain set -e -cd "`dirname $0`" -cd .. +cd "$(dirname "$(dirname "$0")")" -if [ "`id -u`" = 0 ]; then +if [ "$(id -u)" = 0 ]; then echo "Running as root - installing dependencies" - apt-get install fakeroot debhelper devscripts + apt-get install fakeroot debhelper devscripts git-buildpackage mk-build-deps --install debian/control exit 0 fi -git diff-index --quiet HEAD || echo "Warning: git working directory is not clean!" +git diff-index --quiet HEAD || { echo "ERROR: git working directory is not clean!" ; exit 1; } -echo "Preparing the build" -tools/tarsource.sh -V +HEAD_COMMIT=$(git rev-parse --short HEAD) +HEAD_BRANCH=$(git rev-parse --abbrev-ref HEAD) +BUILD_BRANCH="debian/$HEAD_BRANCH-$(date +%s)" -echo "Building the Debian package" -if test $# -eq 0; then - dpkg-buildpackage -b -uc -us -else - dpkg-buildpackage "$@" -fi +echo "Switching to a '$BUILD_BRANCH' build branch" + +git checkout -b "$BUILD_BRANCH" "$HEAD_BRANCH" + +UPSTREAM_VERSION=$(sed -ne 's/AC_INIT(\[frr\],\s\[\([^]]*\)\],.*/\1/p' configure.ac | sed -e 's/-\(\(dev\|alpha\|beta\)\d*\)/~\1/') +LAST_TIMESTAMP=$(git log --format=format:%ad --date=format:%Y%m%d -1 "$HEAD_COMMIT") +SINCE_COMMIT=$(git log --since="00:00:00" --format=format:%H | tail -1) +DEBIAN_VERSION="$UPSTREAM_VERSION-$LAST_TIMESTAMP-git.$HEAD_COMMIT-1" + +echo "Adding new snapshot debian/changelog entry for $DEBIAN_VERSION" + +gbp dch \ + --debian-branch="$BUILD_BRANCH" \ + --new-version "$DEBIAN_VERSION" \ + --since="$SINCE_COMMIT~" \ + --snapshot \ + --commit + +echo "Building package" + +gbp buildpackage \ + --git-builder=debuild \ + --git-debian-branch="$BUILD_BRANCH" \ + --git-force-create \ + --git-no-pristine-tar + +echo "Switching back to '$HEAD_BRANCH' branch" + +git checkout "$HEAD_BRANCH" + +echo "Deleting the '$BUILD_BRANCH' build branch" + +git branch -D "$BUILD_BRANCH" -- cgit v1.2.3