chiark / gitweb /
Rewrite part of the packaging to use `debhelper` classic
authorNiels Thykier <niels@thykier.net>
Mon, 30 Dec 2024 19:23:27 +0000 (19:23 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jan 2025 18:37:50 +0000 (18:37 +0000)
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 <ijackson@chiark.greenend.org.uk>
.gitignore
cprogs/Makefile
debian/chiark-backup/conffiles [deleted file]
debian/control
debian/rules
settings.make
sync-accounts/Makefile

index 6eeaa10a7fbcb8772458454b08459d8fa76dab02..077d6ece09d48b9c3c73bea882ed852833555589 100644 (file)
@@ -30,3 +30,5 @@ debian/sv-*
 debian/files
 debian/*.debhelper.log
 debian/*.debhelper
+debian/.debhelper
+debian/*.substvars
index 127c1fcf4910aba9501748c9158349f1e46864ea..77c970f77f36cc5709945252de82bbc184da70f1 100644 (file)
@@ -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 (file)
index c38afbf..0000000
+++ /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
index 38c178f47438441cb218e870a465fb7391c14f30..ea1618b8708f0b8366c13d9b4d2f1f5a91083a53 100644 (file)
@@ -4,6 +4,7 @@ Priority: optional
 Maintainer: Ian Jackson <ijackson@chiark.greenend.org.uk>
 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
index 28e5b55874d9d2b6a7d0da662a5edc9d6a6eaf64..dd174510d043d6d05451c622c7312b3598e00c67 100755 (executable)
@@ -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
index 27969c14f319761ab1cf37b96cb43f9a4e55aff2..21092d6c50170431dc3a454c7777cbbd80d8f0b8 100644 (file)
@@ -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
index f9279e295ace20dd4ef612524017b0faea47ed6b..c4170f4a2c1be0c48653ba6409183a3e83c2ca14 100644 (file)
 # 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