composer+worker: make dnf-json path externally configurable

The default value is the installation path.
This commit is contained in:
Achilleas Koutsou 2022-04-27 15:34:12 +02:00 committed by Tom Gundersen
parent 8070321169
commit 6fbddeea35
4 changed files with 12 additions and 3 deletions

View file

@ -74,6 +74,7 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos
logrus.Infof("Loaded %d distros", len(c.distros.List())) logrus.Infof("Loaded %d distros", len(c.distros.List()))
c.solver = dnfjson.NewBaseSolver(path.Join(c.cacheDir, "rpmmd")) c.solver = dnfjson.NewBaseSolver(path.Join(c.cacheDir, "rpmmd"))
c.solver.SetDNFJSONPath(c.config.DNFJson)
var jobs jobqueue.JobQueue var jobs jobqueue.JobQueue
if config.Worker.PGDatabase != "" { if config.Worker.PGDatabase != "" {

View file

@ -17,6 +17,7 @@ type ComposerConfigFile struct {
SyslogServer string `toml:"syslog_server" env:"SYSLOG_SERVER"` SyslogServer string `toml:"syslog_server" env:"SYSLOG_SERVER"`
LogLevel string `toml:"log_level"` LogLevel string `toml:"log_level"`
LogFormat string `toml:"log_format"` LogFormat string `toml:"log_format"`
DNFJson string `toml:"dnf-json"`
} }
type KojiAPIConfig struct { type KojiAPIConfig struct {
@ -108,6 +109,7 @@ func GetDefaultConfig() *ComposerConfigFile {
}, },
LogLevel: "info", LogLevel: "info",
LogFormat: "text", LogFormat: "text",
DNFJson: "/usr/libexec/osbuild-composer/dnf-json",
} }
} }

View file

@ -12,7 +12,7 @@ import (
) )
type DepsolveJobImpl struct { type DepsolveJobImpl struct {
RPMMDCache string Solver *dnfjson.BaseSolver
} }
// depsolve each package set in the pacakgeSets map. The repositories defined // depsolve each package set in the pacakgeSets map. The repositories defined
@ -20,7 +20,7 @@ type DepsolveJobImpl struct {
// packageSetsRepos are only used for the package set with the same name // packageSetsRepos are only used for the package set with the same name
// (matching map keys). // (matching map keys).
func (impl *DepsolveJobImpl) depsolve(packageSetsChains map[string][]string, packageSets map[string]rpmmd.PackageSet, repos []rpmmd.RepoConfig, packageSetsRepos map[string][]rpmmd.RepoConfig, modulePlatformID, arch, releasever string) (map[string][]rpmmd.PackageSpec, error) { func (impl *DepsolveJobImpl) depsolve(packageSetsChains map[string][]string, packageSets map[string]rpmmd.PackageSet, repos []rpmmd.RepoConfig, packageSetsRepos map[string][]rpmmd.RepoConfig, modulePlatformID, arch, releasever string) (map[string][]rpmmd.PackageSpec, error) {
solver := dnfjson.NewSolver(modulePlatformID, releasever, arch, impl.RPMMDCache) solver := impl.Solver.NewWithConfig(modulePlatformID, releasever, arch)
depsolvedSets := make(map[string][]rpmmd.PackageSpec) depsolvedSets := make(map[string][]rpmmd.PackageSpec)
// first depsolve package sets that are part of a chain // first depsolve package sets that are part of a chain

View file

@ -22,6 +22,7 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/dnfjson"
"github.com/osbuild/osbuild-composer/internal/upload/azure" "github.com/osbuild/osbuild-composer/internal/upload/azure"
"github.com/osbuild/osbuild-composer/internal/upload/koji" "github.com/osbuild/osbuild-composer/internal/upload/koji"
"github.com/osbuild/osbuild-composer/internal/worker" "github.com/osbuild/osbuild-composer/internal/worker"
@ -223,6 +224,7 @@ func main() {
} `toml:"authentication"` } `toml:"authentication"`
RelaxTimeoutFactor uint `toml:"RelaxTimeoutFactor"` RelaxTimeoutFactor uint `toml:"RelaxTimeoutFactor"`
BasePath string `toml:"base_path"` BasePath string `toml:"base_path"`
DNFJson string `toml:"dnf-json"`
} }
var unix bool var unix bool
flag.BoolVar(&unix, "unix", false, "Interpret 'address' as a path to a unix domain socket instead of a network address") flag.BoolVar(&unix, "unix", false, "Interpret 'address' as a path to a unix domain socket instead of a network address")
@ -396,11 +398,15 @@ func main() {
// depsolve jobs can be done during other jobs // depsolve jobs can be done during other jobs
depsolveCtx, depsolveCtxCancel := context.WithCancel(context.Background()) depsolveCtx, depsolveCtxCancel := context.WithCancel(context.Background())
solver := dnfjson.NewBaseSolver(rpmmd_cache)
if config.DNFJson != "" {
solver.SetDNFJSONPath(config.DNFJson)
}
defer depsolveCtxCancel() defer depsolveCtxCancel()
go func() { go func() {
jobImpls := map[string]JobImplementation{ jobImpls := map[string]JobImplementation{
"depsolve": &DepsolveJobImpl{ "depsolve": &DepsolveJobImpl{
RPMMDCache: rpmmd_cache, Solver: solver,
}, },
} }
acceptedJobTypes := []string{} acceptedJobTypes := []string{}