repos: lookup <buildin>, /{etc,usr/share}/image-builder/repositories
This commit switches the default repositories to use the build-in ones from images PR#1112. It is still possible to override using `/etc/image-builder` and `/usr/share/image-builder` or `--datadir`. This is implicitly tested via the container test that no longer includes the files from osbuild-composer in the container.
This commit is contained in:
parent
6d9e91eb3c
commit
80cadaf291
4 changed files with 28 additions and 37 deletions
|
|
@ -1,22 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/osbuild/images/data/repositories"
|
||||
"github.com/osbuild/images/pkg/reporegistry"
|
||||
)
|
||||
|
||||
// XXX: copied from "composer", should be exported there so
|
||||
// that we keep this in sync
|
||||
// XXX2: means we need to depend on osbuild-composer-common or a new rpm
|
||||
// that provides the relevant packages *or* we use go:embed (cf images#1038)
|
||||
//
|
||||
// defaultDataDirs contains the default search paths to look for repository
|
||||
// data. Note that the repositories are under a repositories/ sub-directory
|
||||
// and contain a bunch of json files of the form "$distro_$version".json
|
||||
// (but that is an implementation detail that the "images" library takes
|
||||
// care of).
|
||||
var defaultDataDirs = []string{
|
||||
"/etc/osbuild-composer",
|
||||
"/usr/share/osbuild-composer",
|
||||
"/etc/image-builder",
|
||||
"/usr/share/image-builder",
|
||||
}
|
||||
|
||||
var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
|
||||
|
|
@ -27,5 +27,17 @@ var newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
|
|||
dataDirs = defaultDataDirs
|
||||
}
|
||||
|
||||
return reporegistry.New(dataDirs)
|
||||
// XXX: think about sharing this with reporegistry?
|
||||
var fses []fs.FS
|
||||
for _, d := range dataDirs {
|
||||
fses = append(fses, os.DirFS(filepath.Join(d, "repositories")))
|
||||
}
|
||||
fses = append(fses, repos.FS)
|
||||
|
||||
// XXX: should we support disabling the build-ins somehow?
|
||||
conf, err := reporegistry.LoadAllRepositoriesFromFS(fses)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return reporegistry.NewFromDistrosRepoConfigs(conf), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue