From 4400dd37c6b5f0b80870e3a5cdd61fdcf4ffb128 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Wed, 6 Sep 2023 15:12:43 +0530 Subject: [PATCH 1/2] Enhance unminimize to transform into a base image for ubuntu-cpc The unminimize script previously just restored the system documentation and translations, man pages, and installed ubuntu-minimal and ubuntu-standard packages to provide the familiar Ubuntu minimal system. But such an image never became an equivalent of base image. Upon investigation and looking at how the base image is constructed - https://git.launchpad.net/livecd-rootfs/tree/live-build/auto/config#n1108 - we use the following things: - minimal task - standard task - cloud-image task (which involves ubuntu-server) - ubuntu-minimal package - server task if arch != amd64 OTOH, in the unminimize script, we use the following: (https://git.launchpad.net/livecd-rootfs/tree/live-build/auto/build#n286) - ubuntu-minimal package - ubuntu-standard package So upon running some tests, it was found that if we install ubuntu-server (with --fix-policy flag), we get the resulting image equivalent to that of a base image. cf: https://warthogs.atlassian.net/browse/CPC-3033 --- live-build/auto/build | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index 12cdb1a8..4520ee6f 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -292,6 +292,18 @@ if dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-server 2> /dev/ DEBIAN_FRONTEND=noninteractive apt-get install -y landscape-common fi EOF + + if [ "$PROJECT" = "ubuntu-cpc" ]; then + # we'd like to transform a minimized image to a base image + # when unminimize is run. + cat >> chroot/usr/local/sbin/unminimize <<'EOF' + +# even if ubuntu-server is installed, we should re-install it with --fix-policy --install-recommends +# to ensure all the Recommends of dependencies of ubuntu-server are installed, which aids in transforming +# this minimized image to an equivalent base image. +DEBIAN_FRONTEND=noninteractive apt-get --reinstall --fix-policy --install-recommends install -y ubuntu-server +EOF + fi if [ "$PROJECT" = "ubuntu-cpc" ] || [ "$PROJECT" = "ubuntu-server" ]; then cat >> chroot/usr/local/sbin/unminimize <<'EOF' From 940df6e060d9657872a24367393459508b6e9e82 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Fri, 8 Sep 2023 18:42:45 +0530 Subject: [PATCH 2/2] Install linux-virtual to restore the stripped headers In a minimized image, the linux headers are stripped, so when unminimizing it, we should restore those stripped headers by installing the linux-virtual package. --- live-build/auto/build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index 4520ee6f..e616c83d 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -302,6 +302,11 @@ EOF # to ensure all the Recommends of dependencies of ubuntu-server are installed, which aids in transforming # this minimized image to an equivalent base image. DEBIAN_FRONTEND=noninteractive apt-get --reinstall --fix-policy --install-recommends install -y ubuntu-server + +if dpkg-query --show --showformat='${db:Status-Status}\n' linux-image-virtual 2> /dev/null | grep -q '^installed$'; then + echo "Installing linux-virtual for installing the headers which were stripped in a minimized image" + DEBIAN_FRONTEND=noninteractive apt-get install -y linux-virtual +fi EOF fi