summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2020-09-27 11:08:13 +0200
committerOndřej Surý <ondrej@sury.org>2020-11-19 21:30:02 +0100
commit63c0c8ed89e1564294ff174b819e520d5977f499 (patch)
tree2691c1a7382235b1ba235e0b150434c3e6fe9e00
parentdebian: Adjust tarsource.sh to use native debian/changelog (diff)
downloadfrr-63c0c8ed89e1564294ff174b819e520d5977f499.tar.xz
frr-63c0c8ed89e1564294ff174b819e520d5977f499.zip
debian: Update tools/build-debian-package.sh to use git-buildpackage
Signed-off-by: Ondřej Surý <ondrej@sury.org>
-rw-r--r--debian/changelog6
-rwxr-xr-xtools/build-debian-package.sh53
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ý <ondrej@debian.org> 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"