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