Skip to content

Commit 7c7f843

Browse files
build-pg-focal: take the patch series from PGDG's packaging of the same minor
The build reused the frozen focal debian/ packaging wholesale, including its patch series, which stops at the last focal minor (13.21/14.18/15.13/16.9). So our newer minors drifted from what PGDG ships for them: * 14.24/15.19/16.15 lacked PGDG's psql fix for the COPY FROM STDIN regression in those minors: psql -c "SELECT 1; COPY t FROM STDIN" aborted with "unexpected COPY_IN result, aborting connection". * 16.x still carried v8-0001-Fix-recovery-conflict-SIGUSR1-handling (an unmerged core-server rework) and pgstat-report-conflicts- immediately, which PGDG dropped in 16.10 as s390x workarounds. PGDG's patch series is identical across distros for a given minor, so take debian/patches from their jammy packaging of the minor we build, verified against its .dsc. The rest of the frozen focal debian/ stays, keeping LLVM 10. PG_DROP_PATCHES no longer needs a default (hurd-iovec is not in the current series). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 675ed6b commit 7c7f843

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

‎dockerfiles/focal-pg-builder/Dockerfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# uses focal's *default* toolchain (clang/llvm-dev = LLVM 10), so the
1717
# resulting JIT depends on focal's libllvm10 (installable on focal), unlike
1818
# newer packaging which requires clang-19/llvm-19.
19+
# - Patch series: debian/patches from PGDG's jammy packaging of the same
20+
# minor (live pool), so we ship the fixes PGDG ships for it.
1921
# - Build tooling (debhelper 13, dh-exec, postgresql-common-dev) is restored
2022
# from the PGDG *archive* (apt-archive.postgresql.org), which keeps the
2123
# removed focal-pgdg suite.

‎scripts/build_pg_focal‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# Approach (see dockerfiles/focal-pg-builder/Dockerfile for the rationale):
1111
# newer upstream orig.tar.bz2 + the frozen focal-era debian/ packaging
1212
# (the last "<major>.<x>-N.pgdg20.04+1" PGDG published for focal)
13+
# + the debian/patches PGDG ships for that same minor (from jammy)
1314
# -> dpkg-buildpackage inside a focal environment that has the archived
1415
# focal-pgdg build tooling available.
1516
#
@@ -34,7 +35,7 @@
3435
# Examples:
3536
# PG_MAJOR=15 build_pg_focal # latest 15.x
3637
# PG_MAJOR=16 PG_UPSTREAM_VERSION=16.15 build_pg_focal
37-
# PG_MAJOR=17 PG_DROP_PATCHES="hurd-iovec foo" build_pg_focal
38+
# PG_MAJOR=17 PG_DROP_PATCHES="foo bar" build_pg_focal
3839

3940
set -euo pipefail
4041

@@ -92,13 +93,8 @@ TARGET_VERSION="${PG_TARGET_VERSION:-${UPSTREAM}-1.pgdg20.04+1}" # produced pack
9293
ORIG_SHA256="${PG_ORIG_SHA256:-}"
9394
DEBIAN_SHA256="${PG_DEBIAN_SHA256:-}"
9495

95-
# Patches in the frozen focal debian/ packaging that no longer apply to newer
96-
# upstream *at all* (e.g. merged upstream). Space-separated; each is dropped from
97-
# the quilt series only if present, so the default is safe for every major:
98-
# * hurd-iovec was merged upstream as of 16.14 (pg_iovec.h guards IOV_MAX),
99-
# so it fails to apply on 16.x/17.x but is absent from 13/14/15 packaging.
100-
# Context drift needs no entry here -- [4/6] refreshes the series instead.
101-
PG_DROP_PATCHES="${PG_DROP_PATCHES:-hurd-iovec}"
96+
# Patches to drop from the series, space-separated (each only if present).
97+
PG_DROP_PATCHES="${PG_DROP_PATCHES:-}"
10298

10399
# Set RUN_TESTS=1 to run the upstream regression suite (slower, needs more deps).
104100
RUN_TESTS="${RUN_TESTS:-0}"
@@ -172,8 +168,20 @@ tar -xf "${DEBIAN_TARBALL}" -C "${SRCDIR}" # unpacks debian/
172168

173169
cd "${SRCDIR}"
174170

175-
# Drop patches from the frozen focal packaging that no longer apply to the newer
176-
# upstream (each removed only if present, so this is a no-op where unneeded).
171+
# The frozen focal patch series stops at the last focal minor. Use the one PGDG
172+
# ships for this minor instead (identical across distros), from their jammy build.
173+
patches_tarball="$(curl -fsSL "${LIVE_POOL}/" \
174+
| grep -oE "postgresql-${PG_MAJOR}_${UPSTREAM//./\\.}-[0-9]+\.pgdg22\.04\+[0-9]+\.debian\.tar\.xz" \
175+
| sort -V | tail -1 || true)"
176+
[ -n "${patches_tarball}" ] || { echo "ERROR: no jammy packaging of ${UPSTREAM} in ${LIVE_POOL}." >&2; exit 1; }
177+
curl -fSL "${LIVE_POOL}/${patches_tarball}" -o "${WORK}/${patches_tarball}"
178+
echo "$(dsc_sha256 "${LIVE_POOL}/${patches_tarball%.debian.tar.xz}.dsc" "${patches_tarball}") ${WORK}/${patches_tarball}" \
179+
| sha256sum -c -
180+
rm -rf debian/patches
181+
tar -xf "${WORK}/${patches_tarball}" debian/patches
182+
echo " patch series taken from ${patches_tarball}"
183+
184+
# Drop patches listed in PG_DROP_PATCHES (each removed only if present).
177185
for p in ${PG_DROP_PATCHES}; do
178186
if grep -qx "${p}" debian/patches/series 2>/dev/null; then
179187
sed -i "/^${p}$/d" debian/patches/series
@@ -183,11 +191,9 @@ for p in ${PG_DROP_PATCHES}; do
183191
done
184192

185193
echo "==> [4/6] Apply & refresh the quilt patch series against ${UPSTREAM}"
186-
# Frozen debian/ + newer upstream means patch *context* drifts: 14.24/15.19/16.15
187-
# added output_plugin_libraries inside the extension_destdir hunk's trailing
188-
# context. quilt applies that with fuzz; dpkg-source replays the same series in
189-
# [6/6] with "patch -F 0" and refuses it. So refresh the series against this
190-
# upstream (context only, no +/- line changes) and gate on zero fuzz here.
194+
# dpkg-source replays the series in [6/6] with "patch -F 0" and refuses any
195+
# fuzz, so refresh it against this upstream (context only, no +/- line changes)
196+
# and gate on zero fuzz here, where the failure is clear.
191197
export QUILTRC=/dev/null # /etc/quilt.quiltrc is sourced after
192198
export QUILT_PATCHES=debian/patches # ... the environment and would win
193199
export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" # keep PGDG's patch style
@@ -222,7 +228,7 @@ fi
222228

223229
echo "==> [5/6] Set version to ${TARGET_VERSION} and install Build-Depends"
224230
dch --newversion "${TARGET_VERSION}" --distribution focal --force-distribution \
225-
"Rebuild of PostgreSQL ${UPSTREAM} for focal (upstream PGDG focal-pgdg discontinued)."
231+
"Rebuild of PostgreSQL ${UPSTREAM} for focal (upstream PGDG focal-pgdg discontinued). Patch series from ${patches_tarball%.debian.tar.xz}."
226232

227233
BUILD_PROFILES=""
228234
BUILD_OPTIONS="parallel=$(nproc)"

0 commit comments

Comments
 (0)