From 514bf24cd9bf0a191054c32aff2f7b15a93097de Mon Sep 17 00:00:00 2001 From: John Akre Date: Tue, 18 Feb 2020 15:14:48 -0800 Subject: [PATCH] Clean dnf cache before using it When building a mix with a version of a package repo that contains existing cache contents, dnf may resolve incorrect results. For instance, Mixer does not version the local package repo, so when incrementally building a mix with local content, dnf will continue to re-use the same cache for the local repo. This was problematic when the version of an rpm in the local repo was updated. In this case, the stale cache metadata was used to incorrectly resolve files for the package. Cleaning the dnf cache before using it prevents old cache metadata from impacting dnf results. Fixes #719 Signed-off-by: John Akre --- builder/bundles.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builder/bundles.go b/builder/bundles.go index ec1541e..5f39d93 100644 --- a/builder/bundles.go +++ b/builder/bundles.go @@ -801,11 +801,6 @@ var rpmMap map[string]bool var dnfDownloadDir string func buildFullChroot(b *Builder, set *bundleSet, packagerCmd []string, buildVersionDir, version string, downloadRetries int, numWorkers int) error { - fmt.Println("Cleaning DNF cache before full install") - if err := clearDNFCache(packagerCmd); err != nil { - return err - } - dnfDownloadDir = filepath.Join(buildVersionDir, "downloadedRpms") err := os.MkdirAll(dnfDownloadDir, 0755) if err != nil { @@ -1052,6 +1047,12 @@ src=%s fmt.Printf("Packager command-line: %s\n", strings.Join(packagerCmd, " ")) + // Existing DNF cache content can cause incorrect queries with stale results + fmt.Println("Cleaning DNF cache") + if err := clearDNFCache(packagerCmd); err != nil { + return err + } + numWorkers := b.NumBundleWorkers emptyDir, err := ioutil.TempDir("", "MixerEmptyDirForNoopInstall") if err != nil {