rpmmd: pass in cache directory explicitly

rpmmd looked at the CACHE_DIRECTORY environment variable to set a path
for the dnf repository cache.  Aside from being a smelly thing to do
from a library, this breaks osbuild-pipeline and osbuild-dnf-json-tests,
which don't run as systemd services and thus don't have CACHE_DIRECTORY
set.

Explicitly pass the cache directory to rpmmd. Keep using a path based on
CACHE_DIRECTORY for osbuild-composer. Use the user's `.cache` directory
for osbuild-pipeline and a temporary directory for the tests.
This commit is contained in:
Lars Karlitski 2020-03-02 20:17:16 +01:00 committed by Tom Gundersen
parent 5e6103f4a8
commit 60301df8f7
4 changed files with 26 additions and 19 deletions

View file

@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"github.com/osbuild/osbuild-composer/internal/common"
@ -87,7 +88,12 @@ func main() {
}
packages = append(pkgs, packages...)
rpmmd := rpmmd.NewRPMMD()
home, err := os.UserHomeDir()
if err != nil {
panic("os.UserHomeDir(): " + err.Error())
}
rpmmd := rpmmd.NewRPMMD(path.Join(home, ".cache/osbuild-composer/rpmmd"))
packageSpecs, checksums, err := rpmmd.Depsolve(packages, exclude_pkgs, d.Repositories(archArg), d.ModulePlatformID(), false)
if err != nil {
panic("Could not depsolve: " + err.Error())