-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbuild-authd-deb
More file actions
executable file
·144 lines (125 loc) · 4.08 KB
/
build-authd-deb
File metadata and controls
executable file
·144 lines (125 loc) · 4.08 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
set -euo pipefail
usage(){
cat << EOF
Usage: $0 [options]
Build the authd source and binary deb packages. The build is done in a fresh
clone of the repository in a separate build directory, so that files that are
not tracked by git are not included in the package. Uncommitted changes in the
repository are applied to the build directory
Options:
--build-dir <dir>
Directory to use for building the package. Defaults to ../build/<repo>.
The build artifacts are created in the parent directory of the build
directory, so in ../build/ by default.
--no-lintian
Don't run lintian on the source and binary packages. Speeds up the build,
but the resulting package won't be checked for issues.
--only-source
Only build the source package, don't build the binary package in sbuild.
--only-binary
Only build the binary package in sbuild, don't build the source package.
Requires that the source package is already built and available in the
parent directory of the build directory.
--dist <distribution>
The target distribution to build the package for (default: noble).
EOF
}
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--build-dir)
BUILD_DIR="$2"
shift 2
;;
--no-lintian)
NO_LINTIAN=1
shift
;;
--only-source)
ONLY_SOURCE=1
shift
;;
--only-binary)
ONLY_BINARY=1
shift
;;
--dist)
DIST="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
done
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
GIT_ROOT_DIR=$(git rev-parse --show-toplevel)
BUILD_DIR=${BUILD_DIR:-../build/$(basename "${GIT_ROOT_DIR}")}
DIST=${DIST:-"noble"}
set -x
if [ -n "${NO_LINTIAN:-}" ]; then
SBUILD_ARGS="--no-run-lintian"
fi
if ! dpkg --status dh-cargo >/dev/null; then
echo "dh-cargo is not installed, installing it now..."
sudo apt install dh-cargo
fi
# Create the build directory
"${SCRIPT_DIR}/create-build-dir" --build-dir "${BUILD_DIR}"
cd "${BUILD_DIR}"
if [ -z "${ONLY_BINARY:-}" ]; then
# Build the source package
env \
DEB_BUILD_OPTIONS=nocheck \
debuild \
--no-lintian \
-d \
--prepend-path="${HOME}/.cargo/bin" \
--prepend-path=/usr/local/bin \
-S \
--unsigned-source \
--unsigned-changes
if [ -z "${NO_LINTIAN:-}" ]; then
# shellcheck disable=SC2012 # The .dsc file doesn't contain non-alphanumeric characters
DSC_FILE="$(ls -t1 ../*.dsc | head -n1)"
lintian --tag-display-limit 0 \
--pedantic \
--fail-on error,warning,info,pedantic \
"$DSC_FILE"
fi
fi
if [ -n "${ONLY_SOURCE:-}" ]; then
exit 0
fi
CHROOT_TARBALL="$HOME/.cache/sbuild/${DIST}-amd64.tar.zst"
if ! [ -f "$CHROOT_TARBALL" ]; then
# Create the sbuild chroot tarball if it doesn't exist
# shellcheck disable=SC2016 # We don't want the expression in --customize-hook to be expanded
mmdebstrap --variant=buildd --arch=amd64 \
--components=main,universe \
--include=software-properties-common \
--customize-hook='chroot "$1" add-apt-repository -y ppa:ubuntu-enterprise-desktop/golang' \
"${DIST}" \
"$CHROOT_TARBALL"
fi
# Build the amd64 binary package in sbuild
# shellcheck disable=SC2086 # Allow word splitting for SBUILD_ARGS
# shellcheck disable=SC2012 # The .dsc file doesn't contain non-alphanumeric characters
env \
DEB_BUILD_OPTIONS=nocheck \
sbuild ${SBUILD_ARGS:-} -A -v \
--build-dir="$(dirname "$(pwd)")" \
--build-dep-resolver=aptitude \
--dist="${DIST}" \
--chroot-mode=unshare \
--chroot="source:${CHROOT_TARBALL}" \
--enable-network \
--lintian-opts="--pedantic --fail-on error,warning,info,pedantic" \
"$(ls -t1 ../*.dsc | head -n1)"