• Scriptable interface for "set package selection to this set"

    From Simon Richter@21:1/5 to All on Thu Feb 29 07:50:02 2024
    Hi,

    I'm trying to build a small script to synchronize the package
    installation sets of a bunch of machines. My current approach is to
    simply run

    dpkg --clear-selections
    dpkg --set-selections <packages.txt
    apt-get --yes dselect-upgrade

    I believe that this is the only interface that allows me to set the
    package selection without having to compare current and desired list. To
    get started, I first tried what would happen if I cleared the entire list:

    root@57ac7d42f84f:/# dpkg --clear-selections
    root@57ac7d42f84f:/# apt-get dselect-upgrade
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following packages will be REMOVED:
    adduser apt debian-archive-keyring e2fsprogs gpgv libapt-pkg6.0
    libcom-err2 libext2fs2 libffi8 libgnutls30 libhogweed6 libidn2-0
    libnettle8 libp11-kit0 libseccomp2 libsemanage-common libsemanage2
    libsepol2 libss2 libstdc++6 libtasn1-6 libunistring2 libxxhash0
    logsave mount passwd tzdata
    WARNING: The following essential packages will be removed.
    This should NOT be done unless you know exactly what you are doing!
    apt adduser (due to apt) gpgv (due to apt)
    libapt-pkg6.0 (due to apt) debian-archive-keyring (due to apt)
    libgnutls30 (due to apt) libseccomp2 (due to apt)
    libstdc++6 (due to apt) e2fsprogs libcom-err2 (due to e2fsprogs)
    libext2fs2 (due to e2fsprogs) libss2 (due to e2fsprogs)
    logsave (due to e2fsprogs)
    0 upgraded, 0 newly installed, 27 to remove and 0 not upgraded.
    After this operation, 30.4 MB disk space will be freed.
    E: Removing essential system-critical packages is not permitted.
    This might break the system.

    As far as I can see, there are two things apt and dpkg disagree on:

    - whether apt itself is Essential

    This is understandable, apt special-cases itself, and for a good reason.
    I have no problem hardcoding an "apt install" into my package selection,
    that solves this nicely.

    - whether e2fsprogs is Essential

    This is only Important, not Essential, so dpkg marks it "deinstall", and
    apt doesn't want to remove it.

    Outside of a container, obviously there will be more "Important"
    packages. I can hardcode a sensible package set to have something that
    works for me for now, but medium term I will probably have to explain
    this script to someone else.

    The obvious problem with this interface is that half of it is provided
    by one tool, and half of it by another, and these implementations have incompatible worldviews that the user of the interface needs to be aware
    of, because it was never designed to be cohesive. Also, the name "dselect-upgrade" suggests that this is really an atavism. A useful one,
    but nonetheless probably not meant to be officially supported.

    Since this functionality is useful, it would be nice to have a proper
    supported way to do this.

    Simon

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Niels Thykier@21:1/5 to All on Sun Mar 3 16:20:02 2024
    Simon Richter:
    Hi,

    [...]

    This is understandable, apt special-cases itself, and for a good reason.
    I have no problem hardcoding an "apt install" into my package selection,
    that solves this nicely.

     - whether e2fsprogs is Essential

    This is only Important, not Essential, so dpkg marks it "deinstall", and
    apt doesn't want to remove it.


    Hi,


    I think your problem here would be solved if `e2fsprogs` used the new `Protected` field rather than the legacy `XB-Important` field. As I
    recall, both apt and dpkg knows about the former while the later was an
    apt only thing. See
    https://lists.debian.org/debian-dpkg/2020/03/msg00002.html

    For the rest, I have no comments (not my field of expertise).

    Best regards,
    Niels

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to Simon Richter on Sun Mar 3 17:10:01 2024
    Hi!

    On Thu, 2024-02-29 at 15:34:48 +0900, Simon Richter wrote:
    As far as I can see, there are two things apt and dpkg disagree on:

    - whether apt itself is Essential

    This is understandable, apt special-cases itself, and for a good reason. I have no problem hardcoding an "apt install" into my package selection, that solves this nicely.

    Right. To me this seems to indicate apt should provide its own
    interface to set selections (perhaps through apt-mark or similar), so
    that then it can inject itself into dpkg worldview as it does when
    operating itself.

    - whether e2fsprogs is Essential

    This is only Important, not Essential, so dpkg marks it "deinstall", and apt doesn't want to remove it.

    As Niels has pointed out, this would work automatically (for dpkg), if e2fsprogs used Protected instead of Important.

    The obvious problem with this interface is that half of it is provided by
    one tool, and half of it by another, and these implementations have incompatible worldviews that the user of the interface needs to be aware of, because it was never designed to be cohesive. Also, the name "dselect-upgrade" suggests that this is really an atavism. A useful one, but nonetheless probably not meant to be officially supported.

    Since this functionality is useful, it would be nice to have a proper supported way to do this.

    I think the different worldviews are ok, but as mentioned above, and
    to avoid layer violations, to me this seems like the upper layer would
    need to provide a wrapper for it.

    If there's stuff to improve from the interface in the dpkg side I'm
    happy to also discuss that.

    Thanks,
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)