-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-debian-package
executable file
·40 lines (27 loc) · 1.12 KB
/
build-debian-package
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Usage ./build-debian-package TARGET_SUITE BUILD_NUMBER
set -euvo pipefail
TARGET_SUITE="$1"
BUILD_NUMBER="$2"
commit_date="$(git show --pretty='Date: %cD' | sed -n '/^Date: */s///p')"
formatted_commit_date="$(date -u --date="$commit_date" "+%Y%m%dT%H%M")"
commit="$(git log --pretty=oneline HEAD^..HEAD | awk '{print $1}')"
srcpkg="$(awk '/^Source:/ { print $2 }' debian/control)"
upstream_version="$(dpkg-parsechangelog --show-field Version | sed 's/-[^-]*$//').$formatted_commit_date"
# Full version is upstream_version - build_number
full_version="$upstream_version-$BUILD_NUMBER"
echo "srcpkg: $srcpkg"
echo "upstream_version: $upstream_version"
echo "full_version: $full_version"
# Clean up parent directory
rm -f "../${srcpkg}"*_*
# Create upstream tarball
git archive HEAD | xz -9 > "../${srcpkg}_${upstream_version}.orig.tar.xz"
# Setup changelog
dch -v "$full_version" -D "$TARGET_SUITE" --force-distribution "New build from commit $commit"
dch -r ''
# Build
export VERSION="$upstream_version"
debuild -e VERSION -us -uc
# Store changes file name
echo "${srcpkg}_${full_version}_amd64.changes" > ../changes_file