diff --git a/debian/changelog b/debian/changelog index 7b73467f..df8648c5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,18 @@ livecd-rootfs (2.525.20) UNRELEASED; urgency=medium + [ Steve Langasek ] * Drop /etc/update-motd.d/51-cloudguest from cloud images; this is not consistent with current Ubuntu Advantage product language. Any future customizations to update-motd for cloud images should be done via a package instead. + [ Julian Andres Klode ] + * Minimize the number of manually installed packages in images by marking + dependencies of metapackages as automatically installed. (LP: #1800610); + but do not mark direct dependencies of ubiquity as auto installed. This + caused cryptsetup to remain auto on the installed system in bionic (see + LP #1801629) + -- Steve Langasek Tue, 12 Mar 2019 11:39:34 -0700 livecd-rootfs (2.525.19) bionic; urgency=medium diff --git a/debian/control b/debian/control index 92378a3e..f7f315de 100644 --- a/debian/control +++ b/debian/control @@ -28,6 +28,7 @@ Depends: ${misc:Depends}, parted, procps, python-minimal | python, + python3-apt, python3-software-properties, qemu-utils, rsync, diff --git a/debian/install b/debian/install index 91d6ea37..4eb70070 100644 --- a/debian/install +++ b/debian/install @@ -1,2 +1,3 @@ live-build usr/share/livecd-rootfs get-ppa-fingerprint usr/share/livecd-rootfs +minimize-manual usr/share/livecd-rootfs diff --git a/live-build/auto/build b/live-build/auto/build index 1912ab5b..aa30f55a 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -435,6 +435,8 @@ EOF (cd chroot && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr) echo END docdirs + /usr/share/livecd-rootfs/minimize-manual chroot + lb binary "$@" touch binary.success ) 2>&1 | tee binary.log diff --git a/minimize-manual b/minimize-manual new file mode 100755 index 00000000..c8e3c166 --- /dev/null +++ b/minimize-manual @@ -0,0 +1,63 @@ +#!/usr/bin/python3 +"""Minimize the number of manually installed packages in the image. + +Finds all manually installed meta packages, and marks their dependencies +as automatically installed. +""" +import sys + +import apt + + +def is_root(pkg): + """Check if the package is a root package (manually inst. meta)""" + return (pkg.is_installed and + not pkg.is_auto_installed and + (pkg.section == "metapackages" or + pkg.section.endswith("/metapackages"))) + + +def main(): + """Main function""" + cache = apt.Cache(rootdir=sys.argv[1] if len(sys.argv) > 1 else None) + roots = set(pkg for pkg in cache if is_root(pkg)) + workset = set(roots) + seen = set() + ubiquity_depends = set() + + with cache.actiongroup(): + while True: + print("Iteration", file=sys.stderr) + to_proc = workset - seen + if not to_proc: + break + for pkg in sorted(to_proc): + print(" Visiting", pkg, file=sys.stderr) + + if pkg not in roots and pkg not in ubiquity_depends: + pkg.mark_auto() + + for dep in (pkg.installed.dependencies + + pkg.installed.recommends): + for bdep in dep.or_dependencies: + for ver in bdep.target_versions: + if ver.package.is_installed: + if pkg.name == "ubiquity": + ubiquity_depends.add(ver.package) + if pkg.name != "ubiquity": + # Reprocess this package again, as we did not mark it when we visited it from ubiquity + try: + ubiquity_depends.remove(ver.package) + # This will raise the KeyError here if ubiquity did not depend on it + seen.remove(ver.package) + except KeyError: + pass + workset.add(ver.package) + + seen.add(pkg) + + cache.commit() + + +if __name__ == '__main__': + main()