From 77f97f22eb300d6972dde9ed1054fced58d7c5c9 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Mon, 17 May 2021 20:18:01 +0200 Subject: [PATCH] tools: Simplify the script to build Debian binary package MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Ondřej Surý (cherry picked from commit c54e2a8144074f36f185f6a21fe57896488c3bf5) --- tools/build-debian-package.sh | 97 +++++------------------------------ 1 file changed, 12 insertions(+), 85 deletions(-) diff --git a/tools/build-debian-package.sh b/tools/build-debian-package.sh index 7d8c41fd17..3c922c355c 100755 --- a/tools/build-debian-package.sh +++ b/tools/build-debian-package.sh @@ -5,14 +5,7 @@ # This file is public domain set -e -BASEDIR="$(realpath -e "$(dirname "$(dirname "$0")")")" -cd "$BASEDIR" - -# -# Directory where the git-buildpackage does the work -# -WORKDIR=$(mktemp -d /tmp/debwork-XXXXXXXX) || exit 1 -trap '( rm -rf "$WORKDIR" )' EXIT +cd "$(dirname "$0")/.." # # Checking requirements @@ -25,23 +18,11 @@ if [ "$(id -u)" = 0 ]; then exit 0 fi -git diff-index --quiet HEAD || { echo "ERROR: git working directory is not clean!" ; exit 1; } - -# -# We switch to a separate branch to not mangle the actual branch, this is -# not needed in the CI -# - -CLONEDIR="$WORKDIR/$(basename "$BASEDIR")" - -echo "Creating shallow clone from $BASEDIR to $CLONEDIR..." +git diff-index --quiet HEAD || echo "Warning: git working directory is not clean!" -git clone --depth=2 "file://$BASEDIR" "$CLONEDIR" -cd "$CLONEDIR" - -#################################### -# Build the Debian package sources # -#################################### +############################ +# Build the Debian package # +############################ # # Now we will construct an "upstream" version out of: @@ -54,7 +35,7 @@ cd "$CLONEDIR" 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:%s -1 "HEAD") DEBIAN_VERSION="$UPSTREAM_VERSION-$LAST_TIMESTAMP-1" -DEBIAN_BRANCH=$(git branch --show-current) +DEBIAN_BRANCH=$(git rev-parse --abbrev-ref HEAD) # # We add a Debian changelog entry, and use artifical "since commit" @@ -72,15 +53,16 @@ gbp dch \ --dch-opt="--force-bad-version" \ --since="HEAD~" \ --snapshot \ - --commit + --commit \ + --git-author echo "Building package..." # -# git-buildpackage will use $BUILDER command to just build new source package +# git-buildpackage will use $BUILDER command to just build new binary package # -BUILDER="dpkg-buildpackage -uc -us --build=source --no-check-builddeps --no-pre-clean -sa" +BUILDER="dpkg-buildpackage -uc -us --build=binary --no-check-builddeps --no-pre-clean -sa" UPSTREAM_COMPRESSION=xz gbp buildpackage \ @@ -89,60 +71,5 @@ gbp buildpackage \ --git-debian-branch="$DEBIAN_BRANCH" \ --git-force-create \ --git-compression=$UPSTREAM_COMPRESSION \ - --git-no-pristine-tar - -DEB_SOURCE="$(dpkg-parsechangelog -SSource)" -DEB_VERSION="$(dpkg-parsechangelog -SVersion)" -DEB_VERSION_UPSTREAM_REVISION="$(echo "${DEB_VERSION}" | sed -e 's/^[0-9]*://')" -DEB_VERSION_UPSTREAM="$(echo "${DEB_VERSION_UPSTREAM_REVISION}" | sed -e 's/-[^-]*$//')" - -# -# Now the source package has been built and it is stored in following files: -# - -echo "Running lintian on the source package" - -lintian "${WORKDIR}/${DEB_SOURCE}_${DEB_VERSION_UPSTREAM_REVISION}_source.changes" - -#################### -# Backporting part # -#################### - -# -# Now we determine what should be the suffix for the system we are backporting -# for. -# - -DIST=$(lsb_release --codename --short) -PATCH=${PATCH:-1} - -case "$DIST" in - jessie) EXTRA_VERSION="deb8u${PATCH}" ;; - stretch) EXTRA_VERSION="deb9u${PATCH}" ;; - buster) EXTRA_VERSION="deb10u${PATCH}" ;; - bullseye) EXTRA_VERSION="deb11u${PATCH}" ;; - sid) EXTRA_VERSION="sid+${PATCH}" ;; - xenial) EXTRA_VERSION="ubuntu16.04+${PATCH}" ;; - bionic) EXTRA_VERSION="ubuntu16.04+${PATCH}" ;; - focal) EXTRA_VERSION="ubuntu20.04+${PATCH}" ;; - groovy) EXTRA_VERSION="ubuntu20.10+${PATCH}" ;; - *) echo "Unknown distribution '$DIST'" ; exit 1 ;; -esac - -# -# Now the actual backport, we: -# -# 1. Unpack the sources -# 2. Append the EXTRA_VERSION -# 3. Use debuild to build the package (don't sign -# - -(cd "$WORKDIR" && dpkg-source -x "${DEB_SOURCE}_${DEB_VERSION_UPSTREAM_REVISION}.dsc") -(cd "$WORKDIR/${DEB_SOURCE}-${DEB_VERSION_UPSTREAM}/" && dch -b -m -t -l "~$EXTRA_VERSION" "No change backport build for $DIST") -(cd "$WORKDIR/${DEB_SOURCE}-${DEB_VERSION_UPSTREAM}/" && debuild -uc -us) - -# -# Copy back the result -# - -cp -a "$WORKDIR"/*.build "$WORKDIR"/*.buildinfo "$WORKDIR"/*.changes "$WORKDIR"/*.dsc "$WORKDIR"/*.deb "$WORKDIR"/*.debian.* "$WORKDIR"/*.orig.tar.* "${BASEDIR}/" + --git-no-pristine-tar \ + --git-ignore-new -- 2.39.5