package update
build-and-publish / build (Raccoon, ubuntu:26.04, NEXUS_PASS_RACCOON, NEXUS_REPO_RACCOON, NEXUS_USER_RACCOON, raccoon) (push) Successful in 3m33s
build-and-publish / build (Trixie, debian:13, NEXUS_PASS_TRIXIE, NEXUS_REPO_TRIXIE, NEXUS_USER_TRIXIE, trixie) (push) Successful in 3m19s

This commit is contained in:
theraw
2026-06-09 05:11:17 +00:00
parent 6dfd126a85
commit f77d853118
3 changed files with 63 additions and 27 deletions
+19 -11
View File
@@ -66,16 +66,20 @@ jobs:
"${pkg_dir}/usr/lib" \ "${pkg_dir}/usr/lib" \
"${pkg_dir}/usr/nginx_lua" \ "${pkg_dir}/usr/nginx_lua" \
"${pkg_dir}/usr/share/twiy/defaults/nginx" \ "${pkg_dir}/usr/share/twiy/defaults/nginx" \
"${pkg_dir}/usr/share/twiy/defaults/hostdata" "${pkg_dir}/nginx/live" "${pkg_dir}/nginx/conf.d" \
"${pkg_dir}/nginx/config" "${pkg_dir}/nginx/modsec" \
"${pkg_dir}/nginx/modules"
cp /usr/sbin/nginx "${pkg_dir}/usr/sbin/" cp /usr/sbin/nginx "${pkg_dir}/usr/sbin/"
# Pristine configs + default site go into a defaults stash, NOT the # /nginx ships as an EMPTY, dpkg-owned skeleton (above): the dirs
# live /nginx and /hostdata trees. postinst seeds them from here # are tracked so upgrades from the old layout don't warn about
# without clobbering local edits (writes <file>.new when a target # "unable to delete old directory /nginx", but NO config file under
# already exists). The live files stay untracked by dpkg, so an # it is tracked. The pristine configs go into a defaults stash;
# upgrade never overwrites a customised config. # postinst places them into /nginx only when missing and never
cp -R /nginx/. "${pkg_dir}/usr/share/twiy/defaults/nginx/" || true # overwrites an admin-edited file (drops <file>.new instead).
cp -R /hostdata/default "${pkg_dir}/usr/share/twiy/defaults/hostdata/" || true # /hostdata is intentionally NOT packaged or seeded — postinst only
# ensures the directory exists and never removes it.
cp -R /nginx/. "${pkg_dir}/usr/share/twiy/defaults/nginx/" || true
cp "${unit_src}" "${pkg_dir}/etc/systemd/system/nginx.service" cp "${unit_src}" "${pkg_dir}/etc/systemd/system/nginx.service"
cp -R /usr/nginx_lua "${pkg_dir}/usr/" || true cp -R /usr/nginx_lua "${pkg_dir}/usr/" || true
@@ -95,10 +99,14 @@ jobs:
"${pkg_name}" "${VERSION}" "${ARCH}" "${conflicts}" "${conflicts}" "${pkg_name}" "${TARGET}" \ "${pkg_name}" "${VERSION}" "${ARCH}" "${conflicts}" "${conflicts}" "${pkg_name}" "${TARGET}" \
> "${deb_dir}/control" > "${deb_dir}/control"
# Shared maintainer script: seeds /nginx + /hostdata from the # Shared maintainer scripts:
# defaults stash without overwriting files the admin already has. # preinst — backs up /nginx before an upgrade unpacks (so admin
# configs survive the migration off dpkg tracking).
# postinst — restores that backup, then seeds /nginx defaults
# without overwriting any file already there.
cp "${REPO_ROOT}/build/deb/preinst" "${deb_dir}/preinst"
cp "${REPO_ROOT}/build/deb/postinst" "${deb_dir}/postinst" cp "${REPO_ROOT}/build/deb/postinst" "${deb_dir}/postinst"
chmod 755 "${deb_dir}/postinst" chmod 755 "${deb_dir}/preinst" "${deb_dir}/postinst"
dpkg-deb --build "${pkg_dir}" dpkg-deb --build "${pkg_dir}"
} }
+26 -16
View File
@@ -1,20 +1,35 @@
#!/bin/sh #!/bin/sh
# postinst — shared by the twiy and twiy-raweb packages. # postinst — shared by the twiy and twiy-raweb packages.
# #
# Pristine configs and the default site ship under /usr/share/twiy/defaults # Config files live under /nginx but are NOT tracked by dpkg. The package
# (owned/tracked by dpkg), NOT under the live /nginx and /hostdata trees. We # ships an empty /nginx skeleton (so dpkg keeps the dirs across upgrades) plus
# seed the live trees from the stash here: # a pristine copy of every config under /usr/share/twiy/defaults/nginx. We
# - target missing -> install the packaged copy # place configs from that stash here and NEVER overwrite a file that already
# - target present -> leave it untouched; drop our copy as <file>.new # exists — our copy is dropped beside it as <file>.new instead (e.g.
# Because dpkg does not track the live files, an install or upgrade never # nginx.conf.new). An upgrade therefore never changes an admin-edited config.
# overwrites a config the admin has edited (e.g. you get nginx.conf.new, not a #
# clobbered nginx.conf). # /hostdata is left entirely to the admin: we only make sure the dir exists,
# and we never touch or remove its contents.
set -e set -e
# nginx runtime user (idempotent).
useradd -r -s /bin/false nginx 2>/dev/null || true useradd -r -s /bin/false nginx 2>/dev/null || true
# Existing dirs are left exactly as they are (mkdir -p is a no-op then).
mkdir -p /nginx /hostdata
# Migration: older releases shipped /nginx/* as dpkg-tracked files, so the
# upgrade unpack deletes them before this script runs. preinst stashed a copy
# first — restore it now, without clobbering anything already present.
if [ -d /var/backups/twiy-nginx ]; then
cp -an /var/backups/twiy-nginx/. /nginx/ 2>/dev/null || true
rm -rf /var/backups/twiy-nginx
fi
# Seed packaged defaults:
# - target absent -> install it
# - target present, differs -> keep theirs, drop ours as <file>.new
# - target present, same -> do nothing
seed_tree() { seed_tree() {
stash="$1" stash="$1"
target="$2" target="$2"
@@ -24,21 +39,16 @@ seed_tree() {
dst="$target/$rel" dst="$target/$rel"
install -d "$(dirname "$dst")" install -d "$(dirname "$dst")"
if [ -e "$dst" ]; then if [ -e "$dst" ]; then
cp -p "$src" "$dst.new" # keep admin's file; offer ours as .new cmp -s "$src" "$dst" || cp -p "$src" "$dst.new"
else else
cp -p "$src" "$dst" cp -p "$src" "$dst"
fi fi
done done
} }
seed_tree /usr/share/twiy/defaults/nginx /nginx
seed_tree /usr/share/twiy/defaults/nginx /nginx
seed_tree /usr/share/twiy/defaults/hostdata /hostdata
# Empty include dirs referenced by nginx.conf (`include conf.d/*;`) that ship
# with no files of their own.
install -d /nginx/conf.d /nginx/config install -d /nginx/conf.d /nginx/config
install -d -o nginx -g nginx -m 0755 /var/log/nginx install -d -o nginx -g nginx -m 0755 /var/log/nginx
chown -R nginx:nginx /var/log/nginx /nginx 2>/dev/null || true chown -R nginx:nginx /var/log/nginx /nginx 2>/dev/null || true
systemctl daemon-reload 2>/dev/null || true systemctl daemon-reload 2>/dev/null || true
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# preinst — shared by the twiy and twiy-raweb packages.
#
# Older releases shipped /nginx as dpkg-tracked files. When upgrading from one
# of those, dpkg deletes the old /nginx/* files during unpack (they are no
# longer part of the package) BEFORE postinst runs. Stash a copy of the live
# config tree first so postinst can restore any admin-edited config and it
# survives the migration. Never touched on a fresh install.
set -e
if [ "$1" = upgrade ] && [ -d /nginx ]; then
rm -rf /var/backups/twiy-nginx
mkdir -p /var/backups
cp -a /nginx /var/backups/twiy-nginx
fi
exit 0