From d36578f6bb4a1f182044af709ccd3e2ded1f5aec Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 18 Sep 2018 08:55:04 +0200 Subject: [PATCH] Import patches-unapplied version 2.537 to ubuntu/cosmic-proposed Imported using git-ubuntu import. Changelog parent: 4de1045012a988a3fd716afac1c3e4fe1cc5ee46 New changelog entries: * Minimize the number of manually installed packages in images by marking dependencies of metapackages as automatically installed. --- .subiquity/subiquity-debug.log | 5 ---- debian/changelog | 7 +++++ debian/control | 1 + debian/install | 1 + live-build/auto/build | 2 ++ minimize-manual | 52 ++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 5 deletions(-) delete mode 100644 .subiquity/subiquity-debug.log create mode 100755 minimize-manual diff --git a/.subiquity/subiquity-debug.log b/.subiquity/subiquity-debug.log deleted file mode 100644 index 15c9e51f..00000000 --- a/.subiquity/subiquity-debug.log +++ /dev/null @@ -1,5 +0,0 @@ -2018-06-12 10:15:24,458 subiquity:107 Starting SUbiquity v0.0.5 -2018-06-12 10:15:24,458 subiquity:108 Arguments passed: ['/home/mwhudson/src/subiquity/subiquity/__main__.py', '--dry-run', '--machine-config', 'examples/mwhudson.json', '--screens', 'Filesystem', '--uefi', '--click', 'Use', '--click', 'Cru'] -2018-06-12 10:15:24,458 subiquitycore.utils:30 Checking environment for installer requirements... -2018-06-12 10:15:24,461 subiquitycore.utils:81 FAIL: /usr/bin/curtin is not found on the filesystem -2018-06-12 10:15:24,461 subiquitycore.prober:40 User specified machine_config: examples/mwhudson.json diff --git a/debian/changelog b/debian/changelog index e773ad65..9c7360a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.537) cosmic; urgency=medium + + * Minimize the number of manually installed packages in images by marking + dependencies of metapackages as automatically installed. + + -- Julian Andres Klode Tue, 18 Sep 2018 08:55:04 +0200 + livecd-rootfs (2.536) cosmic; urgency=medium * Fix live-server journald config snippet to actually disable journald rate diff --git a/debian/control b/debian/control index f6468b91..9d47c949 100644 --- a/debian/control +++ b/debian/control @@ -26,6 +26,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 50831ba2..ec3d61bc 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -445,6 +445,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..6bd18780 --- /dev/null +++ b/minimize-manual @@ -0,0 +1,52 @@ +#!/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() + + 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: + 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: + workset.add(ver.package) + + seen.add(pkg) + + cache.commit() + + +if __name__ == '__main__': + main()