From abbbeb8fdaf7234dabc3338edcc1617d80c6d323 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:08 -0400 Subject: [PATCH 01/19] Begin adding support for a project-independent 'minimize' subproject, which (ironically) omits ubuntu-minimal in favor of using only the minbase package set. --- live-build/auto/config | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index 3f504463..927b4641 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -238,6 +238,10 @@ esac SIGNED_KERNEL_PACKAGE="linux-signed-generic" +if [ "$SUBPROJECT" = minimize ]; then + OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal" +fi + case $PROJECT in ubuntu|ubuntu-dvd) add_task install minimal standard ubuntu-desktop @@ -524,8 +528,12 @@ case $PROJECT in ;; ubuntu-cpc) - add_task install minimal standard cloud-image - add_package install ubuntu-minimal + if [ "$SUBPROJECT" = minimize ]; then + add_task install cloud-image + else + add_task install minimal standard cloud-image + add_package install ubuntu-minimal + fi BINARY_REMOVE_LINUX=false OPTS="${OPTS:+$OPTS }--initramfs=none" From e6bbe5f8a54af47dbfb2ce16c0440eae36e5c946 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 02/19] Export the subproject into config/chroot and config/binary, so that this information is available to per-project hooks that need to be subproject-aware (e.g., to skip steps when SUBPROJECT=minimize) --- live-build/auto/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/live-build/auto/config b/live-build/auto/config index 927b4641..3a3b5a82 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -687,8 +687,10 @@ lb config noauto \ "$@" echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot +echo "SUBPROJECT=\"$SUBPROJECT\"" >> config/chroot echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary echo "BUILDSTAMP=\"$NOW\"" >> config/binary +echo "SUBPROJECT=\"$SUBPROJECT\"" >> config/binary case $ARCH+$SUBARCH in armhf+raspi2) From 786370819ca543f577c36dd622d5aa6055a5a2d3 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 03/19] Make the 999-cpc-fixes.chroot subproject-aware, so we don't try to locale-gen --- live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot index 633f8d66..d1fc8abf 100755 --- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -3,6 +3,8 @@ rootd="${1:-/}" root_fs_label=cloudimg-rootfs set -ex +. /root/config/chroot + CLOUD_IMG_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process" LANG=C @@ -57,7 +59,9 @@ _xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts' _xchroot "${rootd}" sh -c 'rm -f /etc/ssh/ssh_host_[rd]sa_key*' ## -------------- -_xchroot "${rootd}" locale-gen en_US.utf8 +if [ "${SUBPROJECT:-}" != minimize ]; then + _xchroot "${rootd}" locale-gen en_US.utf8 +fi ## -------------- # We continue to pre-generate en_US.UTF-8 locale above, but the default locale From 95890f6713886c16db30b0697484921044d8e7a4 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 04/19] We probably still want sudo, even in a minimal image. --- live-build/auto/config | 1 + 1 file changed, 1 insertion(+) diff --git a/live-build/auto/config b/live-build/auto/config index 3a3b5a82..34ea8ec7 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -530,6 +530,7 @@ case $PROJECT in ubuntu-cpc) if [ "$SUBPROJECT" = minimize ]; then add_task install cloud-image + add_package install sudo else add_task install minimal standard cloud-image add_package install ubuntu-minimal From 3ed1f4fdd14da4b00a29ad0575b3915fef6cb56b Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 05/19] In a cloud environment, we can rely on the kernel being able to boot the root filesystem directly, without an initramfs; enable this when building minimized. --- live-build/functions | 4 ++++ .../ubuntu-cpc/hooks/032-disk-image.binary | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/live-build/functions b/live-build/functions index 2106df21..3e0fe329 100644 --- a/live-build/functions +++ b/live-build/functions @@ -275,6 +275,10 @@ replace_grub_root_with_label() { # Instead, we want grub to use the right labelled disk CHROOT_ROOT="$1" + # If boot by partuuid has been requested, don't override. + if grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub; then + return 0 + fi sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \ "$CHROOT_ROOT/boot/grub/grub.cfg" } diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 81e8339e..94383158 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -5,6 +5,8 @@ FS_LABEL="cloudimg-rootfs" . config/functions +. /build/config/binary + BOOTPART_START= BOOTPART_END= BOOT_MOUNTPOINT= @@ -69,6 +71,8 @@ create_empty_partition "${disk_image}" "$ROOTPART" "$ROOTPART_START" -1 ext2 "$R mount_image "${disk_image}" "$ROOTPART" +partuuid=$(blkid -s PARTUUID -o value "$rootfs_dev_mapper") + # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" mkdir mountpoint @@ -116,6 +120,25 @@ if [ "${should_install_grub}" -eq 1 ]; then ${loop_device} rm mountpoint/tmp/device.map + + if [ "$SUBPROJECT" = minimize ] && [ -n "$partuuid" ]; then + echo "partuuid found for root device; omitting initrd" + chroot mountpoint dpkg-divert --add \ + --divert /usr/sbin/update-initramfs.divert-minimize \ + --rename /usr/sbin/update-initramfs + cat > mountpoint/usr/sbin/update-initramfs <<'EOF' +#! /bin/sh +echo "initramfs disabled on this system. To reenable, run:" >&2 +echo " sudo rm -f /usr/sbin/update-initramfs" >&2 +echo " sudo dpkg-divert --remove --rename /usr/sbin/update-initramfs" >&2 +exit 0 +EOF + chmod +x mountpoint/usr/sbin/update-initramfs + rm -f mountpoint/boot/initrd.img-* + + echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub + chroot mountpoint update-grub + fi fi if [ "$ARCH" = "s390x" ]; then From 83f165ec91cb953fe41ca77073b6d4f9b16599bb Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 06/19] if we're using SUBPROJECT=minimize, and tzdata is not installed, remove files that have been left behind. This is a workaround for a bug that should be fixed in tzdata. --- live-build/auto/build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index 5c7b88ce..9f4b1593 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -45,6 +45,12 @@ Expire-Date: 0 lb bootstrap "$@" + if [ "$SUBPROJECT" = minimize ] \ + && ! Chroot chroot dpkg -l tzdata 2>&1 |grep -q ^ii; then + # workaround for tzdata purge not removing these files + rm -f chroot/etc/localtime chroot/etc/timezone + fi + Chroot chroot "dpkg-divert --quiet --add \ --divert /usr/sbin/update-initramfs.REAL --rename \ /usr/sbin/update-initramfs" From d65e1edfd1d09130c2f44a125ca5b676b8c4e9f5 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 07/19] Source config/binary instead of /build/config/binary which may not exist --- live-build/ubuntu-cpc/hooks/032-disk-image.binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 94383158..2d078f8b 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -5,7 +5,7 @@ FS_LABEL="cloudimg-rootfs" . config/functions -. /build/config/binary +. config/binary BOOTPART_START= BOOTPART_END= From bb7e620701ee30b1a66961e7534fdb90449c3162 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 08/19] Drop man pages and most of the documentation from minimized images /usr/share/doc/*/copyright and changelog.Debian.gz files are still kept --- live-build/auto/build | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index 9f4b1593..bcf22922 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -51,6 +51,27 @@ Expire-Date: 0 rm -f chroot/etc/localtime chroot/etc/timezone fi + if [ "$SUBPROJECT" = minimize ]; then + # set up dpkg filters to skip installing docs on minimized system + mkdir -p chroot/etc/dpkg/dpkg.cfg.d + cat > chroot/etc/dpkg/dpkg.cfg.d/excludes < Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 09/19] Add unminimize script for reverting minimization on running system --- live-build/auto/build | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index bcf22922..956d850f 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -70,6 +70,36 @@ EOF # Remove docs installed by bootstrap Chroot chroot dpkg-query -f '${binary:Package}\n' -W | Chroot chroot xargs apt-get install --reinstall + + # Add unminimizer script which restores default image behavior + mkdir -p chroot/usr/local/sbin + cat > chroot/usr/local/sbin/unminimize <<'EOF' +#!/bin/sh + +set -e + +if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp ]; then + echo "Re-enabling installation of all documentation in dpkg..." + if [ -f /etc/dpkg/dpkg.cfg.d/excludes ]; then + mv /etc/dpkg/dpkg.cfg.d/excludes /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp + fi + echo "Updating package list and upgrading packages..." + apt-get update + # apt-get upgrade asks for confirmation before upgrading packages to let the user stop here + apt-get upgrade + echo "Restoring system documentation..." + echo "Reinstalling packages with files in /usr/share/man/ ..." + dpkg -S /usr/share/man/ |sed 's|, |\n|g;s|: [^:]*$||' | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y + echo "Reinstalling packages with system documentaion in /usr/share/doc/ .." + dpkg --verify | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ + | xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y + if dpkg --verify > /dev/null; then + echo "Documentation has been restored successfully." + rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp + fi +fi +EOF + chmod +x chroot/usr/local/sbin/unminimize fi Chroot chroot "dpkg-divert --quiet --add \ From d5483eb728aabfda317b0ad9c86ce9c436be0acb Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 10/19] Install ubuntu-minimal while unminimizing the system --- live-build/auto/build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index 956d850f..b1a065b9 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -98,6 +98,12 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp fi fi + +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..." + DEBIAN_FRONTEND=noninteractive apt-get install -y ubuntu-minimal +fi + EOF chmod +x chroot/usr/local/sbin/unminimize fi From 9dd615d380b22907ad1a162ce1f9b920627dfd34 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 11/19] Drop initramfs-tools diversion Kernels which are able to boot without initramfs now dropped dependency on initramfs-tools thus initramfs-tools can be removed from the image instead of having to divert it to avoid initramfs generation. --- live-build/ubuntu-cpc/hooks/032-disk-image.binary | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index 2d078f8b..be45c51b 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -122,20 +122,7 @@ if [ "${should_install_grub}" -eq 1 ]; then rm mountpoint/tmp/device.map if [ "$SUBPROJECT" = minimize ] && [ -n "$partuuid" ]; then - echo "partuuid found for root device; omitting initrd" - chroot mountpoint dpkg-divert --add \ - --divert /usr/sbin/update-initramfs.divert-minimize \ - --rename /usr/sbin/update-initramfs - cat > mountpoint/usr/sbin/update-initramfs <<'EOF' -#! /bin/sh -echo "initramfs disabled on this system. To reenable, run:" >&2 -echo " sudo rm -f /usr/sbin/update-initramfs" >&2 -echo " sudo dpkg-divert --remove --rename /usr/sbin/update-initramfs" >&2 -exit 0 -EOF - chmod +x mountpoint/usr/sbin/update-initramfs - rm -f mountpoint/boot/initrd.img-* - + echo "partuuid found for root device; forcing it in Grub" echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub chroot mountpoint update-grub fi From 11da0c59a5b08d467d48225873a8aeac9b311929 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 12/19] Fix typo --- 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 b1a065b9..cad466ad 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -90,7 +90,7 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp echo "Restoring system documentation..." echo "Reinstalling packages with files in /usr/share/man/ ..." dpkg -S /usr/share/man/ |sed 's|, |\n|g;s|: [^:]*$||' | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y - echo "Reinstalling packages with system documentaion in /usr/share/doc/ .." + echo "Reinstalling packages with system documentation in /usr/share/doc/ .." dpkg --verify | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ | xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y if dpkg --verify > /dev/null; then From 3532fa0b18ddff6a8f5147b7ce0864230f5d6bee Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 13/19] Use "dpkg --verify-format rpm" explicitly to be safe when the default changes --- live-build/auto/build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index cad466ad..59a4cfe3 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -91,9 +91,9 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp echo "Reinstalling packages with files in /usr/share/man/ ..." dpkg -S /usr/share/man/ |sed 's|, |\n|g;s|: [^:]*$||' | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y echo "Reinstalling packages with system documentation in /usr/share/doc/ .." - dpkg --verify | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ + dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ | xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y - if dpkg --verify > /dev/null; then + if dpkg --verify --verify-format rpm> /dev/null; then echo "Documentation has been restored successfully." rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp fi From 583d813b9bd775400a6a8ccdc41e0ea36e187078 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 14/19] Verify only documentation that should have been restored after unminimization --- 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 59a4cfe3..08f80a34 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -93,7 +93,7 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp echo "Reinstalling packages with system documentation in /usr/share/doc/ .." dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ | xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y - if dpkg --verify --verify-format rpm> /dev/null; then + if dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {exit 1}'; then echo "Documentation has been restored successfully." rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp fi From e28933a1d59d5e743bd9b9e0ccb16aae1d7e4f94 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 15/19] Explain why unminimization script is a bit complicated --- live-build/auto/build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/live-build/auto/build b/live-build/auto/build index 08f80a34..63ca2699 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -89,8 +89,13 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp apt-get upgrade echo "Restoring system documentation..." echo "Reinstalling packages with files in /usr/share/man/ ..." + # Reinstallation takes place in two steps because a single dpkg --verified + # command generates very long parameter list for "xargs dpkg -S" and may go + # over ARG_MAX. Since many packages have man pages the second download + # handles a much smaller amount of packages. dpkg -S /usr/share/man/ |sed 's|, |\n|g;s|: [^:]*$||' | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y echo "Reinstalling packages with system documentation in /usr/share/doc/ .." + # This step processes the packages which still have missing documentation dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ | xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y if dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {exit 1}'; then From 2858d7fb625e7f0a0105c719335d0750dd5e6bd7 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 16/19] Print the documentation files which could not be restored by unminimize --- live-build/auto/build | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index 63ca2699..d3afccc1 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -99,8 +99,13 @@ if [ -f /etc/dpkg/dpkg.cfg.d/excludes ] || [ -f /etc/dpkg/dpkg.cfg.d/excludes.dp dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print $2}' | sed 's|/[^/]*$||' | sort |uniq \ | xargs dpkg -S | sed 's|, |\n|g;s|: [^:]*$||' | uniq | DEBIAN_FRONTEND=noninteractive xargs apt-get install --reinstall -y if dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {exit 1}'; then - echo "Documentation has been restored successfully." - rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp + echo "Documentation has been restored successfully." + rm /etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp + else + echo "There are still files missing from /usr/share/doc/:" + dpkg --verify --verify-format rpm | awk '/..5...... \/usr\/share\/doc/ {print " " $2}' + echo "You may want to try running this script again or you can remove" + echo "/etc/dpkg/dpkg.cfg.d/excludes.dpkg-tmp and restore the files manually." fi fi From 0365171ce3e9f9e6279257271dae64b42d541eb3 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 26 Sep 2017 22:39:09 -0400 Subject: [PATCH 17/19] minimization handling for UEFI disk images --- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index dd48af3f..fa805bf6 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -62,6 +62,14 @@ install_grub() { efi_boot_dir="/boot/efi/EFI/BOOT" chroot mountpoint mkdir -p "${efi_boot_dir}" + if [ "$SUBPROJECT" = minimize ] && [ -n "$partuuid" ]; then + # FIXME: code duplicated between 032-disk-image.binary + # and 033-disk-image-uefi.binary. We want to fix this to not + # have initramfs-tools installed at all on these images. + echo "partuuid found for root device; omitting initrd" + echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub + fi + chroot mountpoint apt-get -y update # UEFI GRUB modules are meant to be used equally by Secure Boot and @@ -122,6 +130,8 @@ create_empty_disk_image "${disk_image}" create_partitions "${disk_image}" mount_image "${disk_image}" 1 +partuuid=$(blkid -s PARTUUID -o value "$rootfs_dev_mapper") + # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" mkdir mountpoint From c5d01a6635608d2aa8efb40a38308fb76ee29c17 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Wed, 27 Sep 2017 18:54:09 -0400 Subject: [PATCH 18/19] Force partuuid in /etc/default/grub.d/* instead of in /etc/default/grub This prevents ucf questions upon installation of changed /etc/default/grub --- live-build/functions | 3 ++- live-build/ubuntu-cpc/hooks/032-disk-image.binary | 3 ++- live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/live-build/functions b/live-build/functions index 3e0fe329..7fe52f30 100644 --- a/live-build/functions +++ b/live-build/functions @@ -276,7 +276,8 @@ replace_grub_root_with_label() { CHROOT_ROOT="$1" # If boot by partuuid has been requested, don't override. - if grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub; then + if [ -f $CHROOT_ROOT/etc/default/grub.d/40-partuuid ] && \ + grep -q ^GRUB_FORCE_PARTUUID= $CHROOT_ROOT/etc/default/grub.d/40-partuuid; then return 0 fi sed -i -e "s,root=[^ ]\+,root=LABEL=${fs_label}," \ diff --git a/live-build/ubuntu-cpc/hooks/032-disk-image.binary b/live-build/ubuntu-cpc/hooks/032-disk-image.binary index be45c51b..0af56470 100755 --- a/live-build/ubuntu-cpc/hooks/032-disk-image.binary +++ b/live-build/ubuntu-cpc/hooks/032-disk-image.binary @@ -123,7 +123,8 @@ if [ "${should_install_grub}" -eq 1 ]; then if [ "$SUBPROJECT" = minimize ] && [ -n "$partuuid" ]; then echo "partuuid found for root device; forcing it in Grub" - echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub + mkdir -p mountpoint/etc/default/grub.d + echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid chroot mountpoint update-grub fi fi diff --git a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary index fa805bf6..5827a6fe 100755 --- a/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks/033-disk-image-uefi.binary @@ -67,7 +67,7 @@ install_grub() { # and 033-disk-image-uefi.binary. We want to fix this to not # have initramfs-tools installed at all on these images. echo "partuuid found for root device; omitting initrd" - echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub + echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid fi chroot mountpoint apt-get -y update From 83c2984556f1e4462bee3554dad6cc0f496793cc Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Wed, 27 Sep 2017 18:54:21 -0400 Subject: [PATCH 19/19] Update changelog --- debian/changelog | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index f35dd520..3b5a2b30 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,30 @@ livecd-rootfs (2.460) UNRELEASED; urgency=medium + [ Steve Langasek ] + * Begin adding support for a project-independent 'minimize' subproject, which + (ironically) omits ubuntu-minimal in favor of using only the minbase + package set. + * Export the subproject into config/chroot and config/binary, so that this + information is available to per-project hooks that need to be + subproject-aware (e.g., to skip steps when SUBPROJECT=minimize) + * Make the 999-cpc-fixes.chroot subproject-aware, so we don't try to + locale-gen + * In a cloud environment, we can rely on the kernel being able to boot the + root filesystem directly, without an initramfs; enable this when building + minimized. + * If we're using SUBPROJECT=minimize, and tzdata is not installed, remove + files that have been left behind. This is a workaround for a bug that + should be fixed in tzdata. + [ Balint Reczey ] * Mount using --make-rslave to ensure safe unmounts for rbind mounts * Don't ask for password and GECOS while creating vagrant user + * Drop man pages and most of the documentation from minimized images + /usr/share/doc/*/copyright and changelog.Debian.gz files are still kept + * Add unminimize script for reverting minimization on running system + * Install ubuntu-minimal while unminimizing the system - -- Steve Langasek Tue, 26 Sep 2017 00:59:08 -0400 + -- Balint Reczey Wed, 27 Sep 2017 12:29:02 -0400 livecd-rootfs (2.459) artful; urgency=medium