fix: Always use `dpkg-divert` instead of altering files maintained by packages

Altering a file maintained by a package can lead to unexpected behaviou expecially in
this case where packages are being removed and added.

Instead use `dpkg-divert` to allow us to mock `lxd` to `true` to allow `unminimize` to work
without error and to avoid installing of the `lxd` snap.
allwinner-kernel-jammy
Philip Roche 11 months ago
parent 6ad70d64a5
commit 8f8415e1dc

@ -15,11 +15,16 @@ esac
# We can't do that at this stage so just neuter the lxd command (the snap
# will get properly seeded by generic machinery).
if [ -f "/usr/sbin/lxd" ]; then
rm --verbose --force /usr/sbin/lxd
dpkg-divert --add --divert /usr/sbin/lxd.REAL --rename /usr/sbin/lxd
ln -s /bin/true /usr/sbin/lxd
yes | /usr/local/sbin/unminimize
# unminimize also uninstalls lxd-installer package
# and also removed `/usr/sbin/lxd` as a result so we don't need to restore
# and also removed `/usr/sbin/lxd` as a result, so we don't need to restore, but
# we do need to remove the mock we used as part of dpkg-divert
# first we need to remove the diversion
dpkg-divert --remove --no-rename /usr/sbin/lxd
# now remove the renamed file that we originally diverted to
rm -v /usr/sbin/lxd.REAL
else
# if /usr/sbin/lxd doesn't exist then lxd-installer package isn't installed.
# Instead, we can mock the command to avoid the unminimize script failing

Loading…
Cancel
Save