The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/284
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) === Instead of completely removing /var/cache/pacman/pkg, we should only remove its content. Due to packages now being processed twice when running pack-lxc or pack-lxd, the old behaviour caused pacman to fail when trying to install new packages. Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From d3ed6b4db72c7fb78e36d7fe8fc00f896870b018 Mon Sep 17 00:00:00 2001 From: Thomas Hipp <thomas.h...@canonical.com> Date: Thu, 20 Feb 2020 11:13:09 +0100 Subject: [PATCH] managers/pacman: Clean up properly Instead of completely removing /var/cache/pacman/pkg, we should only remove its content. Due to packages now being processed twice when running pack-lxc or pack-lxd, the old behaviour caused pacman to fail when trying to install new packages. Signed-off-by: Thomas Hipp <thomas.h...@canonical.com> --- managers/pacman.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/managers/pacman.go b/managers/pacman.go index d4e947b9..59147646 100644 --- a/managers/pacman.go +++ b/managers/pacman.go @@ -1,6 +1,7 @@ package managers import ( + "io/ioutil" "os" "path/filepath" "runtime" @@ -55,7 +56,28 @@ func NewPacman() *Manager { }, hooks: ManagerHooks{ clean: func() error { - return os.RemoveAll("/var/cache/pacman/pkg") + path := "/var/cache/pacman/pkg" + + // List all entries. + entries, err := ioutil.ReadDir(path) + if err != nil { + if os.IsNotExist(err) { + return nil + } + + return errors.Wrapf(err, "Failed to list directory '%s'", path) + } + + // Individually wipe all entries. + for _, entry := range entries { + entryPath := filepath.Join(path, entry.Name()) + err := os.RemoveAll(entryPath) + if err != nil && !os.IsNotExist(err) { + return errors.Wrapf(err, "Failed to remove '%s'", entryPath) + } + } + + return nil }, }, }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel