diff --git a/Containerfile b/Containerfile index dea9de3..927c54b 100644 --- a/Containerfile +++ b/Containerfile @@ -18,32 +18,6 @@ RUN dnf install -y dnf-plugins-core \ COPY --from=builder /build/image-builder /usr/bin/ -# install repo data from osbuild-composer in an ugly way -# XXX: find a better way -RUN <-.json", + files, e.g. "fedora-41.json". See these [examples](https://github.com/osbuild/images/tree/main/data/repositories). Use the "--datadir" switch and + place them under "repositories/name-version.json", e.g. for: + "--datadir ~/my-project --distro foo-1" a json file must be put under + "~/my-project/repositories/foo-1.json. + ## Project * **Website**: diff --git a/cmd/image-builder/repos.go b/cmd/image-builder/repos.go index 8964753..bc238dc 100644 --- a/cmd/image-builder/repos.go +++ b/cmd/image-builder/repos.go @@ -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 } diff --git a/test/containerbuild.py b/test/conftest.py similarity index 100% rename from test/containerbuild.py rename to test/conftest.py