]> git.proxmox.com Git - mirror_frr.git/blame - tools/build-debian-package.sh
lib: skiplist: clean up level counter implementation
[mirror_frr.git] / tools / build-debian-package.sh
CommitLineData
836ad9fb
DB
1#!/bin/sh
2#
3# Written by Daniil Baturin, 2018
aa1e17f5 4# Rewritten by Ondřej Surý, 2020
836ad9fb 5# This file is public domain
3e662ed3 6set -e
836ad9fb 7
c54e2a81 8cd "$(dirname "$0")/.."
223766ea
OS
9
10#
11# Checking requirements
12#
836ad9fb 13
bcd053ee 14if [ "$(id -u)" = 0 ]; then
3e662ed3 15 echo "Running as root - installing dependencies"
223766ea 16 apt-get install fakeroot debhelper devscripts git-buildpackage lsb-release
3e662ed3
DL
17 mk-build-deps --install debian/control
18 exit 0
836ad9fb
DB
19fi
20
c54e2a81 21git diff-index --quiet HEAD || echo "Warning: git working directory is not clean!"
836ad9fb 22
c54e2a81
IR
23############################
24# Build the Debian package #
25############################
223766ea
OS
26
27#
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)
33#
bcd053ee
OS
34
35UPSTREAM_VERSION=$(sed -ne 's/AC_INIT(\[frr\],\s\[\([^]]*\)\],.*/\1/p' configure.ac | sed -e 's/-\(\(dev\|alpha\|beta\)\d*\)/~\1/')
223766ea
OS
36LAST_TIMESTAMP=$(git log --format=format:%ad --date=format:%s -1 "HEAD")
37DEBIAN_VERSION="$UPSTREAM_VERSION-$LAST_TIMESTAMP-1"
c54e2a81 38DEBIAN_BRANCH=$(git rev-parse --abbrev-ref HEAD)
bcd053ee 39
223766ea
OS
40#
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.
43#
44# The --snapshot option appends ~1.<shorthash> to the debian version, so for the
45# release build, this needs to be replaces with --release
46#
47
48echo "Adding new snapshot debian/changelog entry for $DEBIAN_VERSION..."
bcd053ee
OS
49
50gbp dch \
9ea548cf
OS
51 --debian-branch="$DEBIAN_BRANCH" \
52 --new-version="$DEBIAN_VERSION" \
223766ea
OS
53 --dch-opt="--force-bad-version" \
54 --since="HEAD~" \
bcd053ee 55 --snapshot \
c54e2a81
IR
56 --commit \
57 --git-author
bcd053ee 58
223766ea
OS
59echo "Building package..."
60
61#
c54e2a81 62# git-buildpackage will use $BUILDER command to just build new binary package
223766ea
OS
63#
64
c54e2a81 65BUILDER="dpkg-buildpackage -uc -us --build=binary --no-check-builddeps --no-pre-clean -sa"
223766ea 66UPSTREAM_COMPRESSION=xz
bcd053ee
OS
67
68gbp buildpackage \
223766ea
OS
69 --git-export-dir="$WORKDIR" \
70 --git-builder="$BUILDER" \
9ea548cf 71 --git-debian-branch="$DEBIAN_BRANCH" \
bcd053ee 72 --git-force-create \
223766ea 73 --git-compression=$UPSTREAM_COMPRESSION \
c54e2a81
IR
74 --git-no-pristine-tar \
75 --git-ignore-new