[Merge] ~philroche/livecd-rootfs/+git/livecd-rootfs:bugfix/unminimize-no-lxd-installer-package-jammy into livecd-rootfs:ubuntu/jammy

Philip Roche mp+458910 at code.launchpad.net
Mon Jan 22 14:30:25 UTC 2024



Diff comments:

> diff --git a/live-build/ubuntu-server/hooks/01-unminimize.chroot_early b/live-build/ubuntu-server/hooks/01-unminimize.chroot_early
> index f70b59b..1265966 100755
> --- a/live-build/ubuntu-server/hooks/01-unminimize.chroot_early
> +++ b/live-build/ubuntu-server/hooks/01-unminimize.chroot_early
> @@ -10,11 +10,27 @@ case ${PASS} in
>          ;;
>  esac
>  
> -# The unminimize script will try to install the lxd snap. We can't
> -# do that at this stage so just neuter the snap command (the snap
> +# The unminimize script will try to install the lxd snap using the shim script
> +# /usr/sbin/lxd from the lxd-installer package.
> +# We can't do that at this stage so just neuter the lxd command (the snap
>  # will get properly seeded by generic machinery).
> -dpkg-divert --add --divert /usr/bin/snap.REAL --rename /usr/bin/snap
> -ln -s /bin/true /usr/bin/snap
> -yes | /usr/local/sbin/unminimize
> -rm /usr/bin/snap
> -dpkg-divert --remove --rename /usr/bin/snap
> +if [ -f "/usr/sbin/lxd" ]; then
> +    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, 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

I have run tests with `ls /usr/sbin` before and after. I had assumed as you describe too but `unminimize` and the resulting removal of `lxd-installer` removed `/usr/sbin/lxd` and `/usr/sbin/lxd.REAL` remained despite the diversion in place. 

snipped from build logs

```
purging configuration files for lxd-installer (1) ...
+ ls -al /usr/sbin/
... snip ...
-rwxr-xr-x 1 root root       228 Apr 12  2019 lxd.REAL
... snip ...
```

> +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
> +    ln -s /bin/true /usr/sbin/lxd
> +    yes | /usr/local/sbin/unminimize
> +    # as the lxd-installer package was not installed and thus not removed by `unminimize`
> +    # the mock /usr/sbin/lxd will still be present, so we need to remove it
> +    rm -v /usr/sbin/lxd
> +fi
> \ No newline at end of file


-- 
https://code.launchpad.net/~philroche/livecd-rootfs/+git/livecd-rootfs/+merge/458910
Your team Ubuntu Core Development Team is subscribed to branch livecd-rootfs:ubuntu/jammy.




More information about the Ubuntu-reviews mailing list