summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2020-09-27 11:08:13 +0200
committerOndřej Surý <ondrej@sury.org>2021-07-03 17:02:37 +0200
commitbcd053ee8d75968f03f77c7975c0bbc85de3a4e1 (patch)
tree36dd41f7aa15dc7645c10c571701bbd992daf159 /tools
parentdebian: Adjust tarsource.sh to use native debian/changelog (diff)
downloadfrr-bcd053ee8d75968f03f77c7975c0bbc85de3a4e1.tar.xz
frr-bcd053ee8d75968f03f77c7975c0bbc85de3a4e1.zip
debian: Update tools/build-debian-package.sh to use git-buildpackage
Signed-off-by: Ondřej Surý <ondrej@sury.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/build-debian-package.sh53
1 files changed, 40 insertions, 13 deletions
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"