tree-wide: use an absolute path to dnf-json

Previously, all the osbuild-composer tools must be run from a directory with
dnf-json. This was often confusing, especially with the dnf-json-tests. This
commit changes the path to be absolute, so this is no longer an issue.
This commit is contained in:
Ondřej Budai 2020-05-19 11:04:34 +02:00 committed by Tom Gundersen
parent b93df4b524
commit c00cf1ac11
4 changed files with 9 additions and 7 deletions

View file

@ -87,9 +87,7 @@ func main() {
log.Fatal("CACHE_DIRECTORY is not set. Is the service file missing CacheDirectory=?")
}
// osbuild-composer must be run in /usr/libexec/osbuild-composer directory,
// therefore use ./dnf-json as the path to dnf-json.
rpm := rpmmd.NewRPMMD(path.Join(cacheDirectory, "rpmmd"), "./dnf-json")
rpm := rpmmd.NewRPMMD(path.Join(cacheDirectory, "rpmmd"), "/usr/libexec/osbuild-composer/dnf-json")
distros, err := distro.NewRegistry(fedora31.New(), fedora32.New(), rhel8.New())
if err != nil {

View file

@ -35,7 +35,9 @@ func TestFetchChecksum(t *testing.T) {
IgnoreSSL: true,
}
rpmMetadata := rpmmd.NewRPMMD(path.Join(dir, "rpmmd"), "./dnf-json")
// use a fullpath to dnf-json, this allows this test to have an arbitrary
// working directory
rpmMetadata := rpmmd.NewRPMMD(path.Join(dir, "rpmmd"), "/usr/libexec/osbuild-composer/dnf-json")
_, c, err := rpmMetadata.FetchMetadata([]rpmmd.RepoConfig{repoCfg}, "platform:f31", "x86_64")
assert.Nilf(t, err, "Failed to fetch checksum: %v", err)
assert.NotEqual(t, "", c["repo"], "The checksum is empty")
@ -60,7 +62,9 @@ func TestCrossArchDepsolve(t *testing.T) {
require.Nilf(t, err, "Failed to create tmp dir for depsolve test: %v", err)
defer os.RemoveAll(dir)
rpm := rpmmd.NewRPMMD(dir, "./dnf-json")
// use a fullpath to dnf-json, this allows this test to have an arbitrary
// working directory
rpm := rpmmd.NewRPMMD(dir, "/usr/libexec/osbuild-composer/dnf-json")
repos, err := rpmmd.LoadRepositories([]string{repoDir}, distroStruct.Name())
require.NoErrorf(t, err, "Failed to LoadRepositories %v", distroStruct.Name())

View file

@ -132,7 +132,7 @@ func main() {
panic("os.UserHomeDir(): " + err.Error())
}
rpmmd := rpmmd.NewRPMMD(path.Join(home, ".cache/osbuild-composer/rpmmd"), "./dnf-json")
rpmmd := rpmmd.NewRPMMD(path.Join(home, ".cache/osbuild-composer/rpmmd"), "/usr/libexec/osbuild-composer/dnf-json")
packageSpecs, checksums, err := rpmmd.Depsolve(packages, excludePkgs, repos, d.ModulePlatformID(), arch.Name())
if err != nil {
panic("Could not depsolve: " + err.Error())

View file

@ -137,7 +137,7 @@ func main() {
if err != nil {
panic("os.UserHomeDir(): " + err.Error())
}
rpmmd := rpmmd.NewRPMMD(path.Join(homeDir, ".cache/osbuild-composer/rpmmd"), "./dnf-json")
rpmmd := rpmmd.NewRPMMD(path.Join(homeDir, ".cache/osbuild-composer/rpmmd"), "/usr/libexec/osbuild-composer/dnf-json")
s := store.New(&cwd, a, nil)
if s == nil {