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 <john.w.akre@intel.com>
This commit is contained in:
John Akre
2020-02-21 13:26:07 -08:00
committed by Reagan Lopez
parent 1cb0a99126
commit 514bf24cd9
+6 -5
View File
@@ -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 {