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

Fix: let copr plugin to respect the installroot option #2081

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nikromen
Copy link

@nikromen nikromen commented Feb 22, 2025

This creates repofiles in installroot to respect its location. However dnf4 copr behaves the same way as dnf5 copr with --use-host-config:

[root@7223880ab7fc tmp]# dnf4 copr enable @copr/copr-ping --installroot=/tmp/dnf4 -y
...
[root@7223880ab7fc tmp]# tree
.
└── dnf4
    ├── usr
    │   └── lib
    │       └── sysimage
    │           └── rpm
    │               ├── rpmdb.sqlite
    │               ├── rpmdb.sqlite-shm
    │               └── rpmdb.sqlite-wal
    └── var
        ├── cache
        │   └── dnf
        │       └── expired_repos.json
        └── log
            ├── dnf.librepo.log
            ├── dnf.log
            └── dnf.rpm.log

10 directories, 7 files
[root@7223880ab7fc tmp]#

the repofile is created inside /etc/yum.repos.d, the installroot is ignored.

[root@7223880ab7fc tmp]# ls /etc/yum.repos.d/
_copr:copr.fedorainfracloud.org:group_copr:copr-ping.repo                      fedora-cisco-openh264.repo   fedora-updates.repo
_copr:copr.fedorainfracloud.org:packit:rpm-software-management-dnf5-2081.repo  fedora-updates-testing.repo  fedora.repo

But dnf4 install buildtag --installroot=/tmp/dnf4 somehow uses the repofile in /etc/yum.repos.d. The same steps with dnf5 will result in

[root@7223880ab7fc tmp]# dnf5 install buildtag --installroot=/tmp/dnf5
Updating and loading repositories:
Repositories loaded.
Failed to resolve the transaction:
No match for argument: buildtag
No repositories were loaded from the installroot. To use the configuration and repositories of the host system, pass --use-host-config.

because dnf5 by default looks to the installroot. I don't know whether we want to change the default behaviour of dnf copr between versions 4 and 5, but I'd expect the dnf5 copr command to create repofile inside installroot, so this PR should address this issue.

Fix #1497

@@ -37,11 +38,14 @@ namespace dnf5 {

std::filesystem::path copr_repo_directory() {
std::filesystem::path result;
libdnf5::Base base;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line creates a new instance of the Base class with the default settings.

We need to use the base object from the current dnf5 application context. It is obtained in multiple places using the line auto & base = get_context().get_base();. So we need to pass it here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes I was testing it yesterday whether it works and the installroot was for some reason empty... that explains it, thanks! however when I try to compile this, I get this error:

/builddir/build/BUILD/dnf5-5.2.10.0-build/dnf5-5.2.10.0/dnf5-plugins/copr_plugin/copr_repo.cpp:42:19: error: ‘get_context’ was not declared in this scope; did you mean ‘gettext’?
   42 |     auto & base = get_context().get_base();
      |                   ^~~~~~~~~~~
      |                   gettext
[ 77%] Building CXX object dnf5/CMakeFiles/dnf5.dir/commands/autoremove/autoremove.cpp.o

I have no idea why - this is the first time I've got my hands dirty with cpp so I suppose it's something simple like missing some definition in .hpp file? Or do I need to pass it from somewhere as function argument?

@jrohel jrohel self-assigned this Feb 26, 2025
@nikromen nikromen force-pushed the copr-enable-installroot branch from df8515c to 8972179 Compare February 26, 2025 17:53
@nikromen nikromen requested a review from a team as a code owner February 26, 2025 17:53
@nikromen nikromen requested review from m-blaha and removed request for a team February 26, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

copr enable does not respect --installroot
2 participants