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