The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/306
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This changes the behaviour of package refresh. It only runs if packages need to be installed or removed, or an update needs to be performed. Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From 62f0c595475ff91187dc6baaf60fb964cda528c4 Mon Sep 17 00:00:00 2001 From: Thomas Hipp <thomas.h...@canonical.com> Date: Tue, 10 Mar 2020 15:56:17 +0100 Subject: [PATCH] chroot: Perform package refresh only when needed This changes the behaviour of package refresh. It only runs if packages need to be installed or removed, or an update needs to be performed. Signed-off-by: Thomas Hipp <thomas.h...@canonical.com> --- distrobuilder/chroot.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/distrobuilder/chroot.go b/distrobuilder/chroot.go index 6c23f7f..242f87e 100644 --- a/distrobuilder/chroot.go +++ b/distrobuilder/chroot.go @@ -52,9 +52,23 @@ func manageRepositories(def *shared.Definition, manager *managers.Manager, image } func managePackages(def *shared.Definition, manager *managers.Manager, imageTarget shared.ImageTarget) error { - var err error + var validSets []shared.DefinitionPackagesSet + + for _, set := range def.Packages.Sets { + if !shared.ApplyFilter(&set, def.Image.Release, def.Image.ArchitectureMapped, def.Image.Variant, def.Targets.Type, imageTarget) { + continue + } + + validSets = append(validSets, set) + } - err = manager.Refresh() + // If there's nothing to install or remove, and no updates need to be performed, + // we can exit here. + if len(validSets) == 0 && !def.Packages.Update { + return nil + } + + err := manager.Refresh() if err != nil { return err } @@ -74,16 +88,6 @@ func managePackages(def *shared.Definition, manager *managers.Manager, imageTarg } } - var validSets []shared.DefinitionPackagesSet - - for _, set := range def.Packages.Sets { - if !shared.ApplyFilter(&set, def.Image.Release, def.Image.ArchitectureMapped, def.Image.Variant, def.Targets.Type, imageTarget) { - continue - } - - validSets = append(validSets, set) - } - for _, set := range optimizePackageSets(validSets) { if set.Action == "install" { err = manager.Install(set.Packages, set.Flags)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel