blob: dd7803fa7f9e21515b4020267a1d441765b717bb (
plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
#!/bin/sh
# Launch sbuild from jenkins
# Input:
# .dsc source package in current directory
# JOB_NAME=$pkg-binaries or PACKAGE=pkg
# architecture=amd64/arm64/...
# distribution=foo (caveat: sbuild -d foo-pgdg will be called)
# optionally: DEB_BUILD_OPTIONS
# optionally: PG_SUPPORTED_VERSIONS (defaults to pgdg)
# optionally: autopkgtest=skip
# optionally: BACKPORTS=true
# optionally: wrap= (disables newpid-netns)
# optionally: binnmu_reason=text binnmu_version=version
# Output:
# .changes and .deb in current directory
# autopkgtest.xml in current directory
# Requirements:
# schroot $foo-pgdg-$arch-sbuild
# gid sbuild (for sbuild as such and for /var/lock/sbuild-package)
# adt-sbuild available in chroot (in pgdg-buildenv package)
# /var/tmp bind mount in schroot fstab for retrieving adt-run summary
# sbuild needs to pass through DEB_* variables (default)
# "deb" resolves to some debian mirror
# newpid (and newpid-netns) is installed on host and netns-setup was run
set -eu
error () {
echo "Error: $@" >&2
exit 1
}
# read pgapt config
for dir in . .. $HOME/apt.postgresql.org; do
test -f $dir/pgapt.conf || continue
. $dir/pgapt.conf
break
done
chroot="chroot:${distribution:=sid}$REPO_DIST_SUFFIX-${architecture:=amd64}-sbuild"
set_dist_vars $distribution
# find dsc to build
if [ -z "${PACKAGE:-}" ]; then
PACKAGE="${JOB_NAME%%-binaries*}"
fi
set -- ${PACKAGE}_*.dsc
DSC="$1"
[ "${2:-}" ] && error "There is more than one \${PACKAGE}_*.dsc in $PWD"
# exit early if package is arch:all only and we are not on amd64
if [ "$architecture" != "amd64" ] && grep -Eq '^Architecture: all$' $DSC; then
echo "Package is arch:all only and we are not on amd64" # needs https://issues.jenkins-ci.org/browse/JENKINS-59730 fixed first: "###" "NOT BUILT" "###"
adtsummary2junit /dev/null > autopkgtest.xml
exit
fi
# check if chroot exists
schroot -l | grep -q $chroot || \
error "There is no schroot definition for $chroot"
# decide if we should build arch:all packages
case $architecture in
amd64)
ARCH_ALL="--arch-all" ;; # always build arch:all binaries here
*)
ARCH_ALL="--no-arch-all"
if [ "${autopkgtest:-}" != "skip" ] && grep -Eq '^Testsuite: .*autopkgtest' $DSC; then
echo "Package has Testsuite: autopkgtest, will build arch:all binaries even on $architecture. We'll throw them away at the end."
ARCH_ALL="--arch-all"
FILTER_ARCH_ALL="true"
fi ;;
esac
# build profiles
export DEB_BUILD_PROFILES="pgdg $distribution${DEB_BUILD_PROFILES:+ $DEB_BUILD_PROFILES}"
case $PACKAGE in
postgresql-?.?|postgresql-[1-9]?|postgresql-[1-9]???) # 9.x, 15, 15ee
case $distribution in
# enable cassert on sid
sid) DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES pkg.postgresql.cassert" ;;
# disable zstd on stretch, buster and bionic (PG15+)
stretch|buster|bionic) DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES pkg.postgresql.nozstd" ;;
esac
;;
esac
case $PACKAGE in
postgresql-9.[1-6])
case $distribution in
# Python 3.12 removed distutils
noble) DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES nopython" ;;
esac
;;
postgresql-11)
case $distribution in
# trixie removed llvm 15
sid|trixie) DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES pkg.postgresql.nollvm" ;;
esac
;;
postgresql-18)
case $distribution in
# PG18 needs llvm 13+, but focal has only 10 and 12
focal) DEB_BUILD_PROFILES="$DEB_BUILD_PROFILES pkg.postgresql.nollvm" ;;
esac
;;
vip-manager)
case $distribution in
buster|jammy|focal)
echo "Not building vip-manager on $distribution, the bullseye-pgdg package will be copied to $distribution-pgdg"
adtsummary2junit /dev/null > autopkgtest.xml
exit 0
;;
esac
;;
esac
# resolve alternative build-dependencies on dists other than sid
case $distribution in
sid) ;;
squeeze) RESOLVE_ALTERNATIVES="--resolve-alternatives" ;; # sbuild+aptitude would want multi-arch
*) RESOLVE_ALTERNATIVES="--resolve-alternatives --build-dep-resolver=aptitude" ;;
esac
# enable backports
if [ "$HAS_BACKPORTS" ] && [ "${BACKPORTS:-}" ] && [ "$BACKPORTS" != "false" ]; then
BPOREPO="$mirror_backports"
fi
# set build options
export DEB_BUILD_OPTIONS="$PG_BUILD_OPTIONS${DEB_BUILD_OPTIONS:+ $DEB_BUILD_OPTIONS}"
# set PG_SUPPORTED_VERSIONS
: ${PG_SUPPORTED_VERSIONS:=pgdg}
export PG_SUPPORTED_VERSIONS
export PG_UPDATECONTROL=yes
for version in $PG_SUPPORTED_VERSIONS; do
if [ "$version" != "pgdg" ]; then
# extra build dependencies
ADD_DEPENDS="${ADD_DEPENDS:-} --add-depends=postgresql-server-dev-$version"
if grep -q 'Build-Depends: .*postgresql-all' $DSC; then
ADD_DEPENDS="$ADD_DEPENDS --add-depends=postgresql-$version"
fi
fi
done
# prepare temp file for adt-run results
if [ "${autopkgtest:-}" != "skip" ]; then
ADT_TEMP_DIR=$(mktemp -d /var/tmp/$PACKAGE.XXXXXX)
chgrp sbuild "$ADT_TEMP_DIR"
chmod 3775 "$ADT_TEMP_DIR" # allow jenkins to create files
export DEB_ADT_SUMMARY="$ADT_TEMP_DIR/adt_summary"
trap "rm -rf $ADT_TEMP_DIR" EXIT
FINISHED_BUILD_COMMAND='adt-sbuild %SBUILD_BUILD_DIR %SBUILD_PKGBUILD_DIR'
fi
# lock against concurrent apt-get update/upgrade operations on the source chroot
LOCKDIR="/var/lock/sbuild-package"
if ! test -d $LOCKDIR; then
mkdir -p $LOCKDIR
chgrp sbuild $LOCKDIR
chmod 3775 $LOCKDIR
fi
umask 002
# build package and run autopkgtests inside the chroot
(
echo "Building $PACKAGE (PG_SUPPORTED_VERSIONS=$PG_SUPPORTED_VERSIONS)"
set -x
flock --shared 9 # lock against concurrent source chroot upgrades
${wrap-newpid-netns} \
sbuild --nolog --batch \
-d $distribution$REPO_DIST_SUFFIX --arch $architecture ${ARCH_ALL:-} ${RESOLVE_ALTERNATIVES:-} \
${BPOREPO:+--extra-repository="$BPOREPO"} \
${EXTRA_REPOSITORY:+--extra-repository="$EXTRA_REPOSITORY"} \
${EXTRA_REPOSITORY_KEY:+--extra-repository-key="$EXTRA_REPOSITORY_KEY"} \
${binnmu_reason:+--make-binNMU="$binnmu_reason" --binNMU="$binnmu_version" -m "$MAILING_LIST"} \
${FINISHED_BUILD_COMMAND:+--finished-build-commands="$FINISHED_BUILD_COMMAND"} \
--no-run-lintian \
${ADD_DEPENDS:-} \
${ADD_DEPENDS:+--chroot-setup-commands="/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -h$PGDG_MIRROR -st -v'$PG_SUPPORTED_VERSIONS' $distribution"} \
$DSC
) 9> $LOCKDIR/$distribution-$architecture.lock
# remove arch:all packages that were only built for autopkgtests
if [ "${FILTER_ARCH_ALL:-}" ]; then
sed -i -e '/_all\.deb$/d' *.changes
fi
# when building for PG devel, remove buildinfo so we don't overwrite the one
# from the main "pgdg" build
if [ "$PG_SUPPORTED_VERSIONS" != "pgdg" ]; then
sed -i -e '/\.buildinfo$/d' *.changes
fi
# rename Ubuntu bionic's .ddebs to .deb
if grep -q '\.ddeb$' *.changes; then
for ddeb in $(grep -ho '[^ ]*\.ddeb$' *.changes | sort -u); do
mv -v $ddeb ${ddeb%.ddeb}.deb
done
sed -i -e 's/\.ddeb$/.deb/' *.changes
fi
# convert autopkgtest results to junit xml format
if [ "${DEB_ADT_SUMMARY:-}" ]; then
if [ -s "$DEB_ADT_SUMMARY" ]; then
adtsummary2junit $DEB_ADT_SUMMARY > autopkgtest.xml
else
echo "$DEB_ADT_SUMMARY was not created, something went wrong with the autopkgtest run"
exit 1
fi
else
adtsummary2junit /dev/null > autopkgtest.xml
fi
|