From 7e1bd33544ffd626ff7f3a2abb57a294cf2f489b Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 Jun 2018 11:07:06 +1200 Subject: [PATCH 01/15] do not install ubuntu-minimal in ubuntu-base's unminimize --- live-build/auto/build | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/live-build/auto/build b/live-build/auto/build index 01dcc182..03b3d486 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -152,6 +152,11 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp echo "/etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp and restore the files manually." fi fi +EOF + + if [ "$PROJECT" != "ubuntu-base" ]; then + # The ubuntu-base unminimizer should not install ubuntu-minimal, but others should. + cat >> chroot/usr/local/sbin/unminimize <<'EOF' if ! dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-minimal 2> /dev/null | grep -q '^installed$'; then echo "Installing ubuntu-minimal package to provide the familiar Ubuntu minimal system..." @@ -163,10 +168,12 @@ if dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-server 2> /dev/ echo "Installing ubuntu-server recommends..." DEBIAN_FRONTEND=noninteractive apt-get install -y landscape-common fi +EOF +fi + cat >> chroot/usr/local/sbin/unminimize <<'EOF' # unminimization succeeded, there is no need to mention it in motd rm -f /etc/update-motd.d/60-unminimize - EOF chmod +x chroot/usr/local/sbin/unminimize From 514faae2db7ac1163deff65b5d3f7d4fcb56e6ea Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 Jun 2018 11:08:33 +1200 Subject: [PATCH 02/15] divert /usr/bin/man in minimized images to a script that mentions the unminimize script --- live-build/auto/build | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/live-build/auto/build b/live-build/auto/build index 03b3d486..4a7bc177 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -152,6 +152,10 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp echo "/etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp and restore the files manually." fi fi + +# Remove diverted man binary +rm -f /usr/bin/man +dpkg-divert --quiet --remove --rename /usr/bin/man EOF if [ "$PROJECT" != "ubuntu-base" ]; then @@ -190,7 +194,19 @@ echo "To restore this content, you can run the 'unminimize' command." EOF chmod +x chroot/etc/update-motd.d/60-unminimize - fi + Chroot chroot "dpkg-divert --quiet --add \ + --divert /usr/bin/man.REAL --rename \ + /usr/bin/man" + cat > chroot/usr/bin/man << EOF +#!/bin/sh +echo "This system has been minimized by removing packages and content that are" +echo "not required on a system that users do not log into." +echo "" +echo "To restore this content, including manpages, you can run the 'unminimize'" +echo " command." +EOF + chmod +x chroot/usr/bin/man + fi Chroot chroot "dpkg-divert --quiet --add \ --divert /usr/sbin/update-initramfs.REAL --rename \ /usr/sbin/update-initramfs" From fa1bce5389875383c1647603cbd50aecbe2d1c7b Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 Jun 2018 19:58:46 +1200 Subject: [PATCH 03/15] still install a few packages in docker unminimize --- debian/changelog | 6 ++++++ live-build/auto/build | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 21115c0f..ccc00916 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.529~ppa1manpages1) cosmic; urgency=medium + + * Test build. + + -- Michael Hudson-Doyle Tue, 05 Jun 2018 14:19:17 +1200 + livecd-rootfs (2.528) cosmic; urgency=medium * Don't divert grub-probe; otherwise we're missing the filesystem UUIDs that diff --git a/live-build/auto/build b/live-build/auto/build index 4a7bc177..0217df43 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -158,8 +158,14 @@ rm -f /usr/bin/man dpkg-divert --quiet --remove --rename /usr/bin/man EOF - if [ "$PROJECT" != "ubuntu-base" ]; then - # The ubuntu-base unminimizer should not install ubuntu-minimal, but others should. + if [ "$PROJECT" = "ubuntu-base" ]; then + # ubuntu-minimal is too much for a docker container (it contains + # e.g. systemd) but we should restore at least a few common things. + cat >> chroot/usr/local/sbin/unminimize <<'EOF' +apt-get install -y less man-db iproute2 vim-tiny +EOF + else + # Other unminimizers install more. cat >> chroot/usr/local/sbin/unminimize <<'EOF' if ! dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-minimal 2> /dev/null | grep -q '^installed$'; then @@ -203,7 +209,7 @@ echo "This system has been minimized by removing packages and content that are" echo "not required on a system that users do not log into." echo "" echo "To restore this content, including manpages, you can run the 'unminimize'" -echo " command." +echo "command." EOF chmod +x chroot/usr/bin/man fi From a2bd86d326e4ae66551a7ff00a073080734868db Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 Jun 2018 20:01:13 +1200 Subject: [PATCH 04/15] update changelog --- debian/changelog | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index ccc00916..af0962de 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ -livecd-rootfs (2.529~ppa1manpages1) cosmic; urgency=medium +livecd-rootfs (2.529~ppa2~manpages1) cosmic; urgency=medium - * Test build. + * Improvements to the ubuntu-base (i.e. Docker) build: + - Customize the unminimize script to not install so many packages. + - Divert /usr/bin/man to a script that points to the unminimize script. -- Michael Hudson-Doyle Tue, 05 Jun 2018 14:19:17 +1200 From 2fc3993d48128db5c0ed3b086007889b846de13b Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 6 Jun 2018 06:44:20 +1200 Subject: [PATCH 05/15] Remove apt lists that are currently removed downstream anyway. (LP: #1699913) --- debian/changelog | 2 ++ live-build/auto/build | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index af0962de..c1ecaabd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ livecd-rootfs (2.529~ppa2~manpages1) cosmic; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: - Customize the unminimize script to not install so many packages. - Divert /usr/bin/man to a script that points to the unminimize script. + - Remove apt lists that are currently removed downstream anyway. + (LP: #1699913) -- Michael Hudson-Doyle Tue, 05 Jun 2018 14:19:17 +1200 diff --git a/live-build/auto/build b/live-build/auto/build index 0217df43..eb18d5fe 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -261,6 +261,11 @@ EOF # remove crufty files that shouldn't be left in an image rm -f chroot/var/cache/debconf/*-old chroot/var/lib/dpkg/*-old Chroot chroot apt clean + if [ "${PROJECT}:${SUBPROJECT:-}" = "ubuntu-base:minimized" ]; then + # Save even more size by removing apt lists (that are currently removed + # downstream anyway) + rm -f chroot/var/lib/apt/lists/* + fi if [ -f config/oem-config-preinstalled ]; then From ccef323973101a6c18f34f8d00a68195fe216a0c Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 6 Jun 2018 07:12:01 +1200 Subject: [PATCH 06/15] go back to having docker unminimize not install any extra packages update text of man diversion to mention need to install man-db package --- debian/changelog | 4 ++-- live-build/auto/build | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index c1ecaabd..b23f1957 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ -livecd-rootfs (2.529~ppa2~manpages1) cosmic; urgency=medium +livecd-rootfs (2.529~ppa4) cosmic; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: - - Customize the unminimize script to not install so many packages. + - Customize the unminimize script to not install ubuntu-minimal. - Divert /usr/bin/man to a script that points to the unminimize script. - Remove apt lists that are currently removed downstream anyway. (LP: #1699913) diff --git a/live-build/auto/build b/live-build/auto/build index eb18d5fe..c9598d34 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -158,14 +158,9 @@ rm -f /usr/bin/man dpkg-divert --quiet --remove --rename /usr/bin/man EOF - if [ "$PROJECT" = "ubuntu-base" ]; then + if [ "$PROJECT" != "ubuntu-base" ]; then # ubuntu-minimal is too much for a docker container (it contains - # e.g. systemd) but we should restore at least a few common things. - cat >> chroot/usr/local/sbin/unminimize <<'EOF' -apt-get install -y less man-db iproute2 vim-tiny -EOF - else - # Other unminimizers install more. + # systemd and other things) cat >> chroot/usr/local/sbin/unminimize <<'EOF' if ! dpkg-query --show --showformat='${db:Status-Status}\n' ubuntu-minimal 2> /dev/null | grep -q '^installed$'; then @@ -209,7 +204,7 @@ echo "This system has been minimized by removing packages and content that are" echo "not required on a system that users do not log into." echo "" echo "To restore this content, including manpages, you can run the 'unminimize'" -echo "command." +echo "command. You will still need to ensure the 'man-db' package is installed." EOF chmod +x chroot/usr/bin/man fi From 7c7c2c5b30cb968e1d91eac3bbc4766997563bad Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 6 Jun 2018 07:36:49 +1200 Subject: [PATCH 07/15] rm -r the lists --- live-build/auto/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/auto/build b/live-build/auto/build index c9598d34..6bc025af 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -259,7 +259,7 @@ EOF if [ "${PROJECT}:${SUBPROJECT:-}" = "ubuntu-base:minimized" ]; then # Save even more size by removing apt lists (that are currently removed # downstream anyway) - rm -f chroot/var/lib/apt/lists/* + rm -rf chroot/var/lib/apt/lists/* fi if [ -f config/oem-config-preinstalled ]; then From 664ace2f301f5dccfce6ffb1f462c9dba495a431 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 6 Jun 2018 10:51:35 +1200 Subject: [PATCH 08/15] man un-diverting man idempotent --- debian/changelog | 2 +- live-build/auto/build | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index b23f1957..de1fc9a4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -livecd-rootfs (2.529~ppa4) cosmic; urgency=medium +livecd-rootfs (2.529~ppa6) cosmic; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: - Customize the unminimize script to not install ubuntu-minimal. diff --git a/live-build/auto/build b/live-build/auto/build index 6bc025af..374f6b67 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -115,7 +115,7 @@ echo "" echo "Reinstallation of packages may fail due to changes to the system" echo "configuration, the presence of third-party packages, or for other" echo "reasons." -read -p "Would you like to continue? [y/N]" REPLY +read -p "Would you like to continue? [y/N] " REPLY echo # (optional) move to a new line if [ "$REPLY" != "y" ] && [ "$REPLY" != "Y" ] then @@ -153,9 +153,11 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp fi fi -# Remove diverted man binary -rm -f /usr/bin/man -dpkg-divert --quiet --remove --rename /usr/bin/man +if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then + # Remove diverted man binary + rm -f /usr/bin/man + dpkg-divert --quiet --remove --rename /usr/bin/man +fi EOF if [ "$PROJECT" != "ubuntu-base" ]; then From ba96d42d7e0074978b3c255f1263a30e50c0747c Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 7 Jun 2018 05:47:40 +1200 Subject: [PATCH 09/15] fix version number --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index de1fc9a4..54aba798 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -livecd-rootfs (2.529~ppa6) cosmic; urgency=medium +livecd-rootfs (2.529) cosmic; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: - Customize the unminimize script to not install ubuntu-minimal. From 5979538f434e9b0a021e2a81e2cd8b2479bd1603 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 7 Jun 2018 05:49:53 +1200 Subject: [PATCH 10/15] UNRELEASED --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 54aba798..2f5f5cf6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -livecd-rootfs (2.529) cosmic; urgency=medium +livecd-rootfs (2.529) UNRELEASED; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: - Customize the unminimize script to not install ubuntu-minimal. From 02581df4a1bb852fae806aad934b086f5357e673 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 7 Jun 2018 05:59:20 +1200 Subject: [PATCH 11/15] releasing package livecd-rootfs version 2.529 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2f5f5cf6..f7871c15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -livecd-rootfs (2.529) UNRELEASED; urgency=medium +livecd-rootfs (2.529) cosmic; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: - Customize the unminimize script to not install ubuntu-minimal. @@ -6,7 +6,7 @@ livecd-rootfs (2.529) UNRELEASED; urgency=medium - Remove apt lists that are currently removed downstream anyway. (LP: #1699913) - -- Michael Hudson-Doyle Tue, 05 Jun 2018 14:19:17 +1200 + -- Michael Hudson-Doyle Thu, 07 Jun 2018 05:59:12 +1200 livecd-rootfs (2.528) cosmic; urgency=medium From 0e5b19259d8bff41972f9fe678cc22a73905ac4e Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 6 Jun 2018 11:24:10 -0700 Subject: [PATCH 12/15] ubuntu-cpc: Reintroduce the -root.tar.xz artifact (LP: #1585233). --- debian/changelog | 6 ++++ .../ubuntu-cpc/hooks/031-root-xz.binary | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 live-build/ubuntu-cpc/hooks/031-root-xz.binary diff --git a/debian/changelog b/debian/changelog index f7871c15..422c7128 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.530) UNRELEASED; urgency=medium + + * ubuntu-cpc: Reintroduce the -root.tar.xz artifact (LP: #1585233). + + -- Daniel Watkins Wed, 06 Jun 2018 11:21:57 -0700 + livecd-rootfs (2.529) cosmic; urgency=medium * Improvements to the ubuntu-base (i.e. Docker) build: diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary new file mode 100644 index 00000000..4e52369b --- /dev/null +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -0,0 +1,30 @@ +#!/bin/bash -ex +# vi: ts=4 expandtab +# +# Generate the rootfs.tar.xz and manifest + +if [ -n "$SUBARCH" ]; then + echo "Skipping rootfs build for subarch flavor build" + exit 0 +fi + +. /build/config/functions + +tardir=filesystem.dir +mkdir $tardir +cp -a chroot/* $tardir + +setup_mountpoint $tardir + +env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get --purge remove --assume-yes '^linux-.*' 'linux-base+' +env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get --purge remove --assume-yes '^grub-.*' +env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get autoremove --purge --assume-yes +chroot $tardir mkdir -p /lib/modules + +teardown_mountpoint $tardir + +dpkg-query --admindir=$tardir/var/lib/dpkg -W > livecd.ubuntu-cpc.rootfs.manifest + +(cd "$tardir/" && tar -c *) | xz > "livecd.ubuntu-cpc.rootfs.tar.xz" + +rm -rf $tardir From 8e344b1f6b4773baceeda15f640592cb9e094b5e Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 6 Jun 2018 14:53:58 -0700 Subject: [PATCH 13/15] Add comment explaining /lib/modules creation --- live-build/ubuntu-cpc/hooks/031-root-xz.binary | 3 +++ 1 file changed, 3 insertions(+) diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary index 4e52369b..ab91adb1 100644 --- a/live-build/ubuntu-cpc/hooks/031-root-xz.binary +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -19,6 +19,9 @@ setup_mountpoint $tardir env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get --purge remove --assume-yes '^linux-.*' 'linux-base+' env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get --purge remove --assume-yes '^grub-.*' env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get autoremove --purge --assume-yes + +# This directory is required downstream by MAAS (LP: #1543204), so ensure it +# exists chroot $tardir mkdir -p /lib/modules teardown_mountpoint $tardir From 136e2e2200d5e8b2c1a67a93c2156ef9ff1eda5f Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 6 Jun 2018 15:32:06 -0700 Subject: [PATCH 14/15] Drop /lib/modules creation as MAAS handles it downstream --- live-build/ubuntu-cpc/hooks/031-root-xz.binary | 4 ---- 1 file changed, 4 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary index ab91adb1..9d710d73 100644 --- a/live-build/ubuntu-cpc/hooks/031-root-xz.binary +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -20,10 +20,6 @@ env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get --purge remove --assum env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get --purge remove --assume-yes '^grub-.*' env DEBIAN_FRONTEND=noninteractive chroot $tardir apt-get autoremove --purge --assume-yes -# This directory is required downstream by MAAS (LP: #1543204), so ensure it -# exists -chroot $tardir mkdir -p /lib/modules - teardown_mountpoint $tardir dpkg-query --admindir=$tardir/var/lib/dpkg -W > livecd.ubuntu-cpc.rootfs.manifest From a9bb37c661d3c89232e7440817de0ea34645cecf Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Wed, 6 Jun 2018 16:04:45 -0700 Subject: [PATCH 15/15] Use a relative path for config/functions --- live-build/ubuntu-cpc/hooks/031-root-xz.binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks/031-root-xz.binary b/live-build/ubuntu-cpc/hooks/031-root-xz.binary index 9d710d73..62881cd8 100644 --- a/live-build/ubuntu-cpc/hooks/031-root-xz.binary +++ b/live-build/ubuntu-cpc/hooks/031-root-xz.binary @@ -8,7 +8,7 @@ if [ -n "$SUBARCH" ]; then exit 0 fi -. /build/config/functions +. config/functions tardir=filesystem.dir mkdir $tardir