cmd/osbuild-pipeline: find dnf-json binary
Search for (and set) the path for dnf-json by checking a few known locations: - ./dnf-json: for situations when the tool is ran from the source tree. This is checked first to prioritise local changes. - /usr/libexec/osbuild-composer/dnf-json: the default install location of the script when osbuild-composer is installed. - /usr/lib/osbuild-composer/dnf-json: the default install location of the script for distributions which don't use /usr/libexec. The function panics with an informative error message when it fails to find dnf-json.
This commit is contained in:
parent
6019a5022f
commit
d09176893b
1 changed files with 18 additions and 0 deletions
|
|
@ -42,6 +42,23 @@ type composeRequest struct {
|
|||
OSTree ostreeOptions `json:"ostree"`
|
||||
}
|
||||
|
||||
// osbuild-pipeline is a utility command and is often run from within the
|
||||
// source tree. Find the dnf-json binary in case the osbuild-composer package
|
||||
// isn't installed. This prioritises the local source version over the system
|
||||
// version if run from within the source tree.
|
||||
func findDnfJsonBin() string {
|
||||
locations := []string{"./dnf-json", "/usr/libexec/osbuild-composer/dnf-json", "/usr/lib/osbuild-composer/dnf-json"}
|
||||
for _, djPath := range locations {
|
||||
_, err := os.Stat(djPath)
|
||||
if !os.IsNotExist(err) {
|
||||
return djPath
|
||||
}
|
||||
}
|
||||
|
||||
// can't run: panic
|
||||
panic(fmt.Sprintf("could not find 'dnf-json' in any of the known paths: %+v", locations))
|
||||
}
|
||||
|
||||
func main() {
|
||||
var rpmmdArg bool
|
||||
flag.BoolVar(&rpmmdArg, "rpmmd", false, "output rpmmd struct instead of pipeline manifest")
|
||||
|
|
@ -126,6 +143,7 @@ func main() {
|
|||
packageSets := imageType.PackageSets(composeRequest.Blueprint)
|
||||
|
||||
solver := dnfjson.NewSolver(d.ModulePlatformID(), d.Releasever(), arch.Name(), path.Join(home, ".cache/osbuild-composer/rpmmd"))
|
||||
solver.SetDNFJSONPath(findDnfJsonBin())
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec)
|
||||
// first depsolve package sets that are part of a chain
|
||||
for specName, setNames := range imageType.PackageSetsChains() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue