On Sat, Apr 20, 2024 at 4:40 PM Mike Castle <dalg...@gmail.com> wrote:
> Thanks for all of the commentary so far.
>
> Once I get something working, I will *try* to remember to follow up
> here with what I've managed to cobble together.

I have done quite a bit of research and experimentation and finally
settled on a solution that seems like it will work for me:

Plain old debian/* control files along with config-package-dev.

Effectively, I've abandoned `equivs` and now just using plain old
`debhelper` with a small wrapper script.

One thing I've learned along the way is that debian/control files can
build multiple .deb files.  But the "control" files that `equivs` uses
are not really the same as regular control files, so need one per
package.  Since I created a hierarchy of packages, I needed several
configs for equivs.  Now, I can use just one, and it is MUCH faster
(about 8 seconds total).

I'm still working on replacing my old equivs stuff, but, I do have
some things I'm installing now.  Essentially my setup looks like this:
debian/control:
Maintainer: Mike Castle <dalgoda+...@gmail.com>
Source: mrc
Build-Depends: debhelper-compat (= 12), config-package-dev
Rules-Requires-Root: no
Standards-Version: 4.5.1
Section: metapackages
Priority: optional

Package: mrc-base
Architecture: all
Depends: ${misc:Depends},
 bc,
 cron,
 ...
 zip,

Package: mrc-mozilla
Architecture: all
Description: MRC's Mozilla apt configuration
 Lots of files under /etc/apt.
Depends: ${misc:Depends},

Package: mrc-desktop
Architecture: all
Description: MRC's desktop installation
 Graphical stuff.
Depends: ${misc:Depends},
 mrc-base,
 mrc-games,
 mrc-python,
 mrc-mozilla,

... more meta packages ...

Package: mrc-mars
Architecture: all
Description: MRC's host mars
 Host specific deps.
Provides: ${diverted-files}
Conflicts: ${diverted-files}
Depends: ${misc:Depends},
 mrc-desktop,
 mrc-development,
 mrc-virtual-machines,

... most host packages ...

A few other debian control files:
$ find debian/ -type f
debian/source/format
debian/mrc-mars.install
debian/mrc-mars.displace
debian/mrc-mozilla.install
debian/copyright
debian/changelog
debian/rules
debian/control

$ cat debian/rules
#!/usr/bin/make -f

%:
    dh $@ --with=config-package

The files that match <package-name>.* are the magic.  For example:
$ cat debian/mrc-mozilla.install
files/mozilla/* /

$ find files/mozilla -type f
files/mozilla/usr/share/lintian/overrides/mrc-mozilla
files/mozilla/etc/apt/sources.list.d/mozilla.list
files/mozilla/etc/apt/preferences.d/mozilla
files/mozilla/etc/apt/keyrings/packages.mozilla.org.asc

The etc/apt files come from
https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-distributions
and the lintian overrides is:
$ cat files/mozilla/usr/share/lintian/overrides/mrc-mozilla
mrc-mozilla: package-installs-apt-sources
mrc-mozilla: package-installs-apt-preferences

For the host packages, it is slightly more complicated, but not much
once I figured it out.  Again, a basic "copy in everything under this
directory" install file:
$ cat debian/mrc-mars.install
files/mars/* /

which is currently this:
$ find files/mars -type f
files/mars/etc/hostname.mrc

Then the interesting bit:
$ cat debian/mrc-mars.displace
/etc/hostname.mrc

This "dispace" file is something that the `config-package` addon takes
care of.  It sets up backing up the existing file name (/etc/hostname)
and symlinks in my version:
$ ls -l /etc/hostname*
lrwxrwxrwx 1 root root 12 May 27 08:57 /etc/hostname -> hostname.mrc
-rw-r--r-- 1 root root  5 May 27 06:52 /etc/hostname.mrc
-rw-r--r-- 1 root root  6 May 27 07:37 /etc/hostname.mrc-orig

If I purge mrc-mars, then /etc/hostname.mrc-orig is moved back to /etc/hostname.

(The way config-package-dev works is, it takes the first portion of
the package names, in this case "mrc", to identify what file names to
use.)

To drive it all, I currently use a simple wrapper script:
$ cat doit.sh
#!/bin/bash

set -e

work_dir=$(mktemp -d)
find -depth | cpio -pdm ${work_dir}/work
cd ${work_dir}/work
debuild --no-conf --no-sign --lintian-opts --info

OUTPUT=/srv/deb/packages
rm -rf $OUTPUT
mkdir -p $OUTPUT
cp ${work_dir}/*.deb $OUTPUT
cd $OUTPUT

dpkg-scanpackages . > Packages

echo "work_dir was ${work_dir}"

Not the fanciest, but "works for me" (so far).  Essentially it builds
things in /tmp because the debian packaging tool chain always drops
the files into the parent directory and leaves things that *I*
currently do not care about littering my disk.  Also, it drops
intermediate files into the debian/* directory, making it more
difficult to know what needs to go under SCM.  With this approach,
"git status" will be easier to read.

The only drawback so far, over my previous approach of one `equivs`
config per package, is that now, all built debs share the same version
number.  With the individual approach, I could add one package to a
metapackage, and when I do "apt update && apt upgrade", only the
single package (and its new deps) are processed.  Now, every mrc-*
package is updated.  But, considering the substantial speed up I get
by only running `debhelper` once, it is worth it.  Again, for *me*.

Anyway, I can now finish this stuff up and move onto other projects.

Many thanks!
mrc

Reply via email to