chroot: Honor package set order for install/remove

Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
This commit is contained in:
Thomas Hipp 2019-03-06 17:23:04 +01:00
parent 7031511afa
commit 9907a513cf
No known key found for this signature in database
GPG Key ID: 993408D1137B7D51

View File

@ -53,9 +53,6 @@ func managePackages(def shared.DefinitionPackages, actions []shared.DefinitionAc
}
}
var installablePackages []string
var removablePackages []string
for _, set := range def.Sets {
if len(set.Releases) > 0 && !lxd.StringInSlice(release, set.Releases) {
continue
@ -66,9 +63,12 @@ func managePackages(def shared.DefinitionPackages, actions []shared.DefinitionAc
}
if set.Action == "install" {
installablePackages = append(installablePackages, set.Packages...)
err = manager.Install(set.Packages)
} else if set.Action == "remove" {
removablePackages = append(removablePackages, set.Packages...)
err = manager.Remove(set.Packages)
}
if err != nil {
return err
}
}
@ -77,16 +77,6 @@ func managePackages(def shared.DefinitionPackages, actions []shared.DefinitionAc
manager.SetInstallFlags("install", "--allow-downgrade")
}
err = manager.Install(installablePackages)
if err != nil {
return err
}
err = manager.Remove(removablePackages)
if err != nil {
return err
}
if def.Cleanup {
err = manager.Clean()
if err != nil {