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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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/10] 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.