]> git.proxmox.com Git - mirror_frr.git/blobdiff - tools/build-debian-package.sh
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tools / build-debian-package.sh
index 6791325e75723858f87e40a0a223f7e2b746a5eb..d614ba01d9271750bdf1325b323101afefe18f5e 100755 (executable)
@@ -1,55 +1,76 @@
 #!/bin/sh
+# SPDX-License-Identifier: NONE
 #
 # Written by Daniil Baturin, 2018
 # Rewritten by Ondřej Surý, 2020
 # This file is public domain
 set -e
 
-cd "$(dirname "$(dirname "$0")")"
+cd "$(dirname "$0")/.."
+
+#
+# Checking requirements
+#
 
 if [ "$(id -u)" = 0 ]; then
        echo "Running as root - installing dependencies"
-       apt-get install fakeroot debhelper devscripts git-buildpackage
+       apt-get install fakeroot debhelper devscripts git-buildpackage lsb-release
        mk-build-deps --install debian/control
        exit 0
 fi
 
-git diff-index --quiet HEAD || { echo "ERROR: git working directory is not clean!" ; exit 1; }
+git diff-index --quiet HEAD || echo "Warning: git working directory is not clean!"
 
-HEAD_COMMIT=$(git rev-parse --short HEAD)
-HEAD_BRANCH=$(git rev-parse --abbrev-ref HEAD)
-BUILD_BRANCH="debian/$HEAD_BRANCH-$(date +%s)"
+############################
+# Build the Debian package #
+############################
 
-echo "Switching to a '$BUILD_BRANCH' build branch"
-
-git checkout -b "$BUILD_BRANCH" "$HEAD_BRANCH"
+#
+# Now we will construct an "upstream" version out of:
+# 1. version in AC_INIT
+# 2. the unix time from the last commit (HEAD)
+#    (alternatively %Y%m%d%H%M%S could be used here)
+# 4. Debian version (always -1)
+#
 
 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"
+LAST_TIMESTAMP=$(git log --format=format:%ad --date=format:%s -1 "HEAD")
+DEBIAN_VERSION="$UPSTREAM_VERSION-$LAST_TIMESTAMP-1"
+DEBIAN_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+#
+# We add a Debian changelog entry, and use artifical "since commit"
+# so there's not a whole git history in the debian/changelog.
+#
+# The --snapshot option appends ~1.<shorthash> to the debian version, so for the
+# release build, this needs to be replaces with --release
+#
 
-echo "Adding new snapshot debian/changelog entry for $DEBIAN_VERSION"
+echo "Adding new snapshot debian/changelog entry for $DEBIAN_VERSION..."
 
 gbp dch \
-    --debian-branch="$BUILD_BRANCH" \
-    --new-version "$DEBIAN_VERSION" \
-    --since="$SINCE_COMMIT~" \
+    --debian-branch="$DEBIAN_BRANCH" \
+    --new-version="$DEBIAN_VERSION" \
+    --dch-opt="--force-bad-version" \
+    --since="HEAD~" \
     --snapshot \
-    --commit
-
-echo "Building package"
-
-gbp buildpackage \
-    --git-builder=debuild \
-    --git-debian-branch="$BUILD_BRANCH" \
-    --git-force-create \
-    --git-no-pristine-tar
+    --commit \
+    --git-author
 
-echo "Switching back to '$HEAD_BRANCH' branch"
+echo "Building package..."
 
-git checkout "$HEAD_BRANCH"
+#
+# git-buildpackage will use $BUILDER command to just build new binary package
+#
 
-echo "Deleting the '$BUILD_BRANCH' build branch"
+BUILDER="dpkg-buildpackage -uc -us --build=binary --no-check-builddeps --no-pre-clean -sa"
+UPSTREAM_COMPRESSION=xz
 
-git branch -D "$BUILD_BRANCH"
+gbp buildpackage \
+    --git-export-dir="$WORKDIR" \
+    --git-builder="$BUILDER" \
+    --git-debian-branch="$DEBIAN_BRANCH" \
+    --git-force-create \
+    --git-compression=$UPSTREAM_COMPRESSION \
+    --git-no-pristine-tar \
+    --git-ignore-new