manifestgen: use temporary cache dir if no cacheDir is given
This commit creates a temporary directory for the defaultDepvolver() if no cacheDir is given. This ensures that we do not clutter the current working directory with `platform:foo` cache directories that `solver.Depvolve()` creates. Note that this is only tested indirectly via the integration test in `test_container.py:test_container_builds_image()` that checks that the output directory is clean.
This commit is contained in:
parent
cc4a730381
commit
058e3d6832
1 changed files with 9 additions and 0 deletions
|
|
@ -22,6 +22,15 @@ import (
|
|||
// into a common helper in "images" or images should do this on its
|
||||
// own
|
||||
func defaultDepsolver(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d distro.Distro, arch string) (map[string][]rpmmd.PackageSpec, map[string][]rpmmd.RepoConfig, error) {
|
||||
if cacheDir == "" {
|
||||
var err error
|
||||
cacheDir, err = os.MkdirTemp("", "manifestgen")
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("cannot create temporary directory: %w", err)
|
||||
}
|
||||
defer os.RemoveAll(cacheDir)
|
||||
}
|
||||
|
||||
solver := dnfjson.NewSolver(d.ModulePlatformID(), d.Releasever(), arch, d.Name(), cacheDir)
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec)
|
||||
repoSets := make(map[string][]rpmmd.RepoConfig)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue