3 # Written by Daniil Baturin, 2018
4 # Rewritten by Ondřej Surý, 2020
5 # This file is public domain
8 cd "$(dirname "$0")/.."
11 # Checking requirements
14 if [ "$(id -u)" = 0 ]; then
15 echo "Running as root - installing dependencies"
16 apt-get
install fakeroot debhelper devscripts git-buildpackage lsb-release
17 mk-build-deps
--install debian
/control
21 git diff-index
--quiet HEAD ||
echo "Warning: git working directory is not clean!"
23 ############################
24 # Build the Debian package #
25 ############################
28 # Now we will construct an "upstream" version out of:
29 # 1. version in AC_INIT
30 # 2. the unix time from the last commit (HEAD)
31 # (alternatively %Y%m%d%H%M%S could be used here)
32 # 4. Debian version (always -1)
35 UPSTREAM_VERSION
=$
(sed -ne 's/AC_INIT(\[frr\],\s\[\([^]]*\)\],.*/\1/p' configure.ac |
sed -e 's/-\(\(dev\|alpha\|beta\)\d*\)/~\1/')
36 LAST_TIMESTAMP
=$
(git log
--format=format
:%ad
--date=format
:%s
-1 "HEAD")
37 DEBIAN_VERSION
="$UPSTREAM_VERSION-$LAST_TIMESTAMP-1"
38 DEBIAN_BRANCH
=$
(git rev-parse
--abbrev-ref HEAD
)
41 # We add a Debian changelog entry, and use artifical "since commit"
42 # so there's not a whole git history in the debian/changelog.
44 # The --snapshot option appends ~1.<shorthash> to the debian version, so for the
45 # release build, this needs to be replaces with --release
48 echo "Adding new snapshot debian/changelog entry for $DEBIAN_VERSION..."
51 --debian-branch="$DEBIAN_BRANCH" \
52 --new-version="$DEBIAN_VERSION" \
53 --dch-opt="--force-bad-version" \
59 echo "Building package..."
62 # git-buildpackage will use $BUILDER command to just build new binary package
65 BUILDER
="dpkg-buildpackage -uc -us --build=binary --no-check-builddeps --no-pre-clean -sa"
66 UPSTREAM_COMPRESSION
=xz
69 --git-export-dir="$WORKDIR" \
70 --git-builder="$BUILDER" \
71 --git-debian-branch="$DEBIAN_BRANCH" \
73 --git-compression=$UPSTREAM_COMPRESSION \
74 --git-no-pristine-tar \