From: Niels Thykier Date: Mon, 30 Dec 2024 19:23:27 +0000 (+0000) Subject: Rewrite part of the packaging to use `debhelper` classic X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=60a1dab706b6bcb18a557f57821b49257009f07f;p=chiark-utils.git Rewrite part of the packaging to use `debhelper` classic This rewrites `debian/rules` to use `debhelper` more. With this, 1) The package now builds without requiring root. 2) The package now produces dbgsym packages 3) The package now includes the md5sums control member. 4) The package now uses dh_clean to properly clean up after the debhelper commands. There are no loess of functionality or features in any of the debs. The only delta to the original debs is that the original debs uses "non-standard" mode for symlinks (like we saw with authbind). However, that mode is ignored on unpack, so the delta is irrelevant. The `debian/chiark-backup/conffiles` file was made obsolete by using `dh_installdeb`, which generates that content automatically (admittedly, with a slightly different order, but the order is semantically irrelevant). One downside with this approach is that the `binary-one` target has to restore the setuid mode of `really`, which is a bit awkward in the current design. Long term is to remove the `binary-one` target, but that will when the `debian/tmp/$PKG` is rewritten to be `debian/$PKG`, so the debhelper tools work better out of the box with those directories. Closes: #1089303 Signed-off-by: Ian Jackson --- diff --git a/.gitignore b/.gitignore index 6eeaa10..077d6ec 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ debian/sv-* debian/files debian/*.debhelper.log debian/*.debhelper +debian/.debhelper +debian/*.substvars diff --git a/cprogs/Makefile b/cprogs/Makefile index 127c1fc..77c970f 100644 --- a/cprogs/Makefile +++ b/cprogs/Makefile @@ -93,7 +93,7 @@ install: all $(INSTALL_DIRECTORY) $(bindir) $(sbindir) $(INSTALL_PROGRAM) $(PROGRAMS) $(bindir) $(INSTALL_PROGRAM) $(DAEMONS) $(sbindir) - $(INSTALL) -m 4774 -o root -g $(SYSTEM_GROUP) \ + $(INSTALL) -m 4774 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) \ $(SUIDSBINPROGRAMS) $(sbindir) install-docs: $(TXTDOCS) diff --git a/debian/chiark-backup/conffiles b/debian/chiark-backup/conffiles deleted file mode 100644 index c38afbf..0000000 --- a/debian/chiark-backup/conffiles +++ /dev/null @@ -1,5 +0,0 @@ -/etc/chiark-backup/settings.sh -/etc/chiark-backup/snap/lvm -/etc/chiark-backup/snap/remount -/etc/chiark-backup/snap/remountrocp -/etc/chiark-backup/snap/nosnap diff --git a/debian/control b/debian/control index 38c178f..ea1618b 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,7 @@ Priority: optional Maintainer: Ian Jackson Build-Depends: libx11-dev, libxmu-dev, nettle-dev, debhelper (>= 13), libxdmcp-dev, libxau-dev, libice-dev, libsm-dev, libuv1-dev +Rules-Requires-Root: no Standards-Version: 4.6.1.1 Vcs-Browser: https://www.chiark.greenend.org.uk/ucgi/~ian/git/chiark-utils.git/ Vcs-Git: https://www.chiark.greenend.org.uk/ucgi/~ian/githttp/chiark-utils.git diff --git a/debian/rules b/debian/rules index 28e5b55..dd17451 100755 --- a/debian/rules +++ b/debian/rules @@ -37,19 +37,26 @@ clean: $(MAKE) -C $$s -i distclean || \ $(MAKE) -C $$s -f Makefile.in distclean; \ done - rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars* - rm -rf debian/sv-* debian/*.debhelper.log + rm -rf debian/sv-* + dh_clean binary-prep: $(checkdir) rm -rf debian/tmp* + # The ownership information will be reset later to root:root in + # the `dpkg-deb` call, so the actual ownership here is of no + # consequence as long as we are allowed to perform the action. # + # Chown'ing from your own user/group to itself is always allowed, + # so we pass that via id -u/-g. set -e; for s in $(subdirs_build_arch) $(subdirs_nobuild); do \ $(MAKE) -C $$s install install-docs install-examples \ prefix=$t/$$s/usr \ etcdir=$t/$$s/etc \ varlib=$t/$$s/var/lib \ - mandir=$t/$$s/usr/share/man; \ + mandir=$t/$$s/usr/share/man \ + SYSTEM_USER=$$(id -u) \ + SYSTEM_GROUP=$$(id -g); \ done # mv $t/cprogs $t/chiark-utils-bin @@ -98,39 +105,28 @@ binary-prep: # gzip -9fn $t/*/usr/share/man/man*/* -binary-hook-chiark-backup: -binary-hook-chiark-rwbuffer: -binary-hook-sync-accounts: -binary-hook-chiark-scripts: -binary-hook-chiark-really: -binary-hook-chiark-utils-bin: - binary-one: - set -e; for f in preinst postinst prerm postrm conffiles; do \ - test -f debian/$p/$$f || continue; \ - cp debian/$p/$$f $t/$p/DEBIAN/$$f; \ - chmod u=rwX,go=rX $t/$p/DEBIAN/$$f; \ - done - dh_lintian -p$p -Pdebian/tmp/$p - dh_link -p$p -Pdebian/tmp/$p - dpkg-gencontrol -p$p -P$t/$p -Tdebian/sv-$p - chown -R root.root debian/tmp - chmod -R g-ws debian/tmp - debian/rules binary-hook-$p - dpkg --build $t/$p .. - -binary-indep: checkroot build binary-prep + dh_lintian -p$p -P$t/$p + dh_link -p$p -P$t/$p + dh_fixperms -p$p -P$t/$p + chmod u+s,o-x $t/chiark-really/usr/sbin/really + dh_installdeb -p$p -P$t/$p + dh_gencontrol -p$p -P$t/$p + dh_md5sums -p$p -Pdebian/tmp/$p + dh_builddeb -p$p -Pdebian/tmp/$p + + +binary-indep: build binary-prep set -e; for p in $(packages_indep); do \ debian/rules binary-one p=$$p; done -binary-arch: checkroot build binary-prep +binary-arch: build binary-prep $(checkdir) set -ex; for p in chiark-really chiark-utils-bin chiark-rwbuffer; do \ dh_strip -p$$p -Pdebian/tmp/$$p; done - dpkg-shlibdeps -Tdebian/sv-chiark-rwbuffer \ - $t/chiark-rwbuffer/usr/bin/* - dpkg-shlibdeps -Tdebian/sv-chiark-really \ - $t/chiark-really/usr/sbin/* + dh_shlibdeps -p chiark-rwbuffer -P$t/chiark-rwbuffer + dh_shlibdeps -p chiark-really -P$t/chiark-really + set -e; for f in $t/chiark-utils-bin/usr/bin/*; do \ case "$$f" in \ */xbatmon-simple|*/xduplic-copier) \ @@ -141,7 +137,7 @@ binary-arch: checkroot build binary-prep esac; \ a="$$a -d$$d $$f"; \ done; set -x; \ - dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin $$a + dh_shlibdeps -p chiark-utils-bin -P$t/chiark-utils-bin -- $$a set -e; for p in $(packages_arch); \ do debian/rules binary-one p=$$p; done @@ -156,8 +152,4 @@ binary: binary-indep binary-arch source diff: @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false -checkroot: - $(checkdir) - test root = "`whoami`" - -.PHONY: binary binary-arch binary-indep clean checkroot +.PHONY: binary binary-arch binary-indep clean diff --git a/settings.make b/settings.make index 27969c1..21092d6 100644 --- a/settings.make +++ b/settings.make @@ -33,6 +33,7 @@ WARNINGS= -Wall -Wwrite-strings -Wmissing-prototypes \ OPTIMISE= -O2 DEBUG= -g +SYSTEM_USER= root SYSTEM_GROUP= root prefix=/usr/local @@ -56,7 +57,7 @@ man8dir=${mandir}/man8 # INSTALL_PROGRAM_STRIP_OPT=-s INSTALL= install -c -INSTALL_SHARE= $(INSTALL) -m 644 -o root -g $(SYSTEM_GROUP) -INSTALL_SCRIPT= $(INSTALL) -m 755 -o root -g $(SYSTEM_GROUP) +INSTALL_SHARE= $(INSTALL) -m 644 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) +INSTALL_SCRIPT= $(INSTALL) -m 755 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) INSTALL_PROGRAM= $(INSTALL_SCRIPT) $(INSTALL_PROGRAM_STRIP_OPT) -INSTALL_DIRECTORY= $(INSTALL) -m 2755 -o root -g $(SYSTEM_GROUP) -d +INSTALL_DIRECTORY= $(INSTALL) -m 2755 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) -d diff --git a/sync-accounts/Makefile b/sync-accounts/Makefile index f9279e2..c4170f4 100644 --- a/sync-accounts/Makefile +++ b/sync-accounts/Makefile @@ -19,12 +19,13 @@ # with this program; if not, consult the Free Software Foundation's # website at www.fsf.org, or the GNU Project website at www.gnu.org. +SYSTEM_USER= root SYSTEM_GROUP= root INSTALL= install -c -INSTALL_SHARE= $(INSTALL) -m 644 -o root -g $(SYSTEM_GROUP) -INSTALL_SCRIPT= $(INSTALL) -m 755 -o root -g $(SYSTEM_GROUP) -INSTALL_DIRECTORY= $(INSTALL) -m 2755 -o root -g $(SYSTEM_GROUP) -d +INSTALL_SHARE= $(INSTALL) -m 644 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) +INSTALL_SCRIPT= $(INSTALL) -m 755 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) +INSTALL_DIRECTORY= $(INSTALL) -m 2755 -o $(SYSTEM_USER) -g $(SYSTEM_GROUP) -d prefix=/usr/local bindir=$(prefix)/bin