Skip to content

Draft: Fix update-alternatives-based policy-rc.d handling

At the moment, the chroot_sysv-rc script attempts to use dpkg-divert to move a /usr/sbin/policy-rc.d script out of the way so that live-build can install its own "deny everything" script to keep services from trying to start during the build process. This probably works well with policy-rc.d files that are shipped directly by deb packages, but if the file is being managed by update-alternatives, this doesn't work at all - the /usr/sbin/policy-rc.d symlink to /etc/alternatives/policy-rc.d ends up deleted during the ISO build process and is not restored.

The case where /usr/sbin/policy-rc.d is managed by update-alternatives needs to be taken into account, because /usr/share/doc/init-system-helpers/README.policy-rc.d.gz states:

The /usr/sbin/policy-rc.d file *must* be managed through the alternatives
system (/usr/sbin/update-alternatives) by any packages providing it.

Both policyrcd-script-zg2 and policy-rcd-declarative follow this directive, thus both of these packages are broken by live-build during the build process.

This PR fixes the issue by making live-build able to detect when update-alternatives is being used for policy-rc.d handling. When it is, live-build will install its policy-rc.d script as a very high-priority alternative. It will also remove the alternative (and corresponding script) when it is time to deconfigure it. The previous dpkg-divert solution is retained, so that whatever use case it was intended to serve continues to be served properly.

Merge request reports

Loading