main: add --force-repo flag
This commit adds an `--force-repo` flag that can be used to replace all the base repositories with a base url to a repository. This is useful for testing but also dangerous as it will not do any checks and happily use a fedora-42 repository for centos-8 depsolving. This will make the use-case of the koji builder easier and is also something that the `build` tool in `images` supports.
This commit is contained in:
parent
e2aeecec8e
commit
bc5be2ba8a
6 changed files with 120 additions and 44 deletions
|
|
@ -646,3 +646,40 @@ func TestManifestExtraRepo(t *testing.T) {
|
|||
assert.Contains(t, fakeStdout.String(), `"path":"dummy-1.0.0-0.noarch.rpm"`)
|
||||
assert.Contains(t, fakeStdout.String(), fmt.Sprintf(`"url":"file://%s"`, localRepoDir))
|
||||
}
|
||||
|
||||
func TestManifestOverrideRepo(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("manifest generation takes a while")
|
||||
}
|
||||
if !hasDepsolveDnf() {
|
||||
t.Skip("no osbuild-depsolve-dnf binary found")
|
||||
}
|
||||
|
||||
var fakeStderr bytes.Buffer
|
||||
restore := main.MockOsStderr(&fakeStderr)
|
||||
defer restore()
|
||||
|
||||
restore = main.MockOsArgs([]string{
|
||||
"manifest",
|
||||
"qcow2",
|
||||
"--distro=centos-9",
|
||||
"--arch=x86_64",
|
||||
"--force-repo=http://xxx.abcdefgh-no-such-host.com/repo",
|
||||
})
|
||||
defer restore()
|
||||
|
||||
// XXX: dnfjson is very chatty and puts a bunch of output on stderr
|
||||
// we should probably silence this in images as its the job of the
|
||||
// error to catpure this. Use CaptureStdio here to ensure we don't
|
||||
// get noisy and confusing errors when this test runs.
|
||||
var err error
|
||||
testutil.CaptureStdio(t, func() {
|
||||
err = main.Run()
|
||||
})
|
||||
assert.ErrorContains(t, err, "forced repo#0 xxx.abcdefgh-no-such-host.com/repo: http://xxx.abcdefgh-no-such-host.com/repo]: Cannot download repomd.xml")
|
||||
// XXX: we should probably look into "images" here, there is a bunch
|
||||
// of redundancy in the full error message:
|
||||
//
|
||||
// `error depsolving: running osbuild-depsolve-dnf failed:
|
||||
// DNF error occurred: RepoError: There was a problem reading a repository: Failed to download metadata for repo '9828718901ab404ac1b600157aec1a8b19f4b2139e7756f347fb0ecc06c92929' [forced repo#0 xxx.abcdefgh-no-such-host.com/repo: http://xxx.abcdefgh-no-such-host.com/repo]: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue