This commit adds a new flag `--extra-repo` that can be used
to point to a repository url that is added to the base
repositories when depsolving. Note that *no* gpg checking
will be performed for such repos as there is no way to
add gpg-keys (yet) via this mechanism.
This means that with a repo created with e.g. `createrepo_c` like
```console
$ mkdir repo
$ (cd repo && dnf download hello)
$ createrepo_c ./repo
```
and a blueprint like:
```toml
[[packages]]
name = "hello"
```
a manifest is generated that gets hello from this local repo:
```console
$ image-builder --extra-repo file:$(pwd)/repo manifest qcow2 --distro centos-9 --blueprint ./bp.toml |jq|grep hello
"path": "hello-2.12.1-5.fc41.x86_64.rpm",
```
Note that this is part of the base repositories so anything with a
higher version number will get pulled from the extra-repo, even
system libraries or kernels. Note also that this repository does
not become part of the image so after the image build all rpms
from there are not updated (unless of course the normal repos
have higher versions of them).
Note as well that there is no safeguard right now against adding
extra repos for the wrong version of the distro, i.e. one could
add an extra repo build against/for fedora-42 on a fedora-40 image
which most likely will break with bad depsolve errors. But that
is okay, this option is meant for advanced users and testing.
30 lines
685 B
Go
30 lines
685 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/osbuild/images/pkg/rpmmd"
|
|
)
|
|
|
|
func TestParseExtraRepoHappy(t *testing.T) {
|
|
checkGPG := false
|
|
|
|
cfg, err := parseExtraRepo("file:///path/to/repo")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, cfg, []rpmmd.RepoConfig{
|
|
{
|
|
Id: "file:///path/to/repo",
|
|
Name: "file:///path/to/repo",
|
|
BaseURLs: []string{"file:///path/to/repo"},
|
|
CheckGPG: &checkGPG,
|
|
CheckRepoGPG: &checkGPG,
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestParseExtraRepoSad(t *testing.T) {
|
|
_, err := parseExtraRepo("/just/a/path")
|
|
assert.EqualError(t, err, `scheme missing in "/just/a/path", please prefix with e.g. file:`)
|
|
}
|