Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container: run dnf check in container for dnf4/dnf5 compat #658

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions bib/internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@ func (c *Container) ExecArgv() []string {
return []string{"podman", "exec", "-i", c.id}
}

// InitDNF initializes dnf in the container. This is necessary when the caller wants to read the image's dnf
// repositories, but they are not static, but rather configured by dnf dynamically. The primaru use-case for
// this is RHEL and subscription-manager.
// InitDNF initializes dnf in the container. This is necessary when
// the caller wants to read the image's dnf repositories, but they are
// not static, but rather configured by dnf dynamically. The primaru
// use-case for this is RHEL and subscription-manager.
//
// The implementation is simple: We just run plain `dnf` in the container.
// The implementation is simple: We just run plain `dnf` in the
// container so that the subscription-manager gets initialized. For
// compatibility with both dnf and dnf5 we cannot just run "dnf" as
// dnf5 will error and do nothing in this case. So we use "dnf check
// --duplicates" as this is fast on both dnf4/dnf5 (just doing "dnf5
// check" without arguments takes around 25s so that is not a great
// option).
func (c *Container) InitDNF() error {
if output, err := exec.Command("podman", "exec", c.id, "dnf").CombinedOutput(); err != nil {
if output, err := exec.Command("podman", "exec", c.id, "dnf", "check", "--duplicates").CombinedOutput(); err != nil {
return fmt.Errorf("initializing dnf in %s container failed: %w\noutput:\n%s", c.id, err, string(output))
}

Expand Down
8 changes: 4 additions & 4 deletions test/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class TestCaseFedora(TestCase):


@dataclasses.dataclass
class TestCaseFedora41(TestCase):
container_ref: str = "quay.io/fedora/fedora-bootc:41"
class TestCaseFedora42(TestCase):
container_ref: str = "quay.io/fedora/fedora-bootc:42"
rootfs: str = "btrfs"


Expand Down Expand Up @@ -103,7 +103,7 @@ def gen_testcases(what): # pylint: disable=too-many-return-statements
return [
TestCaseCentos(target_arch="arm64"),
# TODO: merge with TestCaseFedora once the arches are build there
TestCaseFedora41(target_arch="ppc64le"),
TestCaseFedora41(target_arch="s390x"),
TestCaseFedora42(target_arch="ppc64le"),
TestCaseFedora42(target_arch="s390x"),
]
raise ValueError(f"unknown test-case type {what}")
Loading