Skip to content

fix: copr: Actually respect installroot for the repo directory (fix of #2081) - #3035

Open
jrohel wants to merge 2 commits into
rpm-software-management:mainfrom
jrohel:fix/copr_plugin_repo_path
Open

jrohel wants to merge 2 commits into
rpm-software-management:mainfrom
jrohel:fix/copr_plugin_repo_path

Conversation

@jrohel

@jrohel jrohel commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This PR updates and expands the CI tests, touching on the changes introduced in #3004. Please merge #3004 first.

PR #2081 attempted to fix "copr doesn't use repositories in installroot" (#1497) by prepending the installroot in copr_repo_directory(). However, the fix did not work. It computed the destination directory as installroot / COPR_REPO_DIRECTORY where COPR_REPO_DIRECTORY is an absolute path ("/etc/yum.repos.d"). Appending an absolute path with std::filesystem::path::operator / replaces the left-hand side entirely, so the installroot was silently discarded: dnf5 --installroot=X copr enable ... still wrote the ".repo" file into the host's "/etc/yum.repos.d" instead of "X/etc/yum.repos.d", and copr disable/copr remove could not find the repository (they enumerate repositories from the installroot-prefixed reposdir) without --use-host-config.

Strip the root directory from COPR_REPO_DIRECTORY before appending, so that the installroot is actually prepended.

Completes the fix of #1497; fixes the fix from #2081.

CI tests updated and extended.

@jrohel
jrohel requested a review from a team as a code owner November 9, 2026 11:59
@jrohel
jrohel requested review from pkratoch and removed request for a team November 9, 2026 11:59
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix Copr installroot paths and manage per-repository vendor policies

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes


AI Description

• Write Copr repository files inside the installroot so disable and remove can find them.
• Add configurable, directional vendor-change policies for enabled Copr repositories and revoke them
 on disable or remove.
• Report repository write failures and expand integration coverage for installroot and policy
 lifecycles.
Diagram

graph TD
  CLI["Copr commands"] --> Config["Copr configuration"] --> Enable["Enable repository"] --> Repos[("Installroot repos")]
  CLI --> Cleanup["Disable or remove"] --> Repos
  Enable --> Manager["Vendor change manager"] --> Policies[("Vendor policy files")]
  Cleanup --> Manager
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use one shared Copr vendor policy
  • ➕ Fewer policy files to manage.
  • ➖ Cannot preserve independent choices for each project.
  • ➖ Disabling one project could affect exceptions for others.
2. Require transaction-time vendor overrides
  • ➕ Avoids persistent policy files.
  • ➖ Users must repeat the choice for later transactions.
  • ➖ Does not attach the exception to the repositories being enabled.

Recommendation: Keep per-project incoming and outgoing policies: the manager's filters combine incoming and outgoing conditions, so two files express the directions independently. Project-specific files also make disable and remove cleanup predictable. Review the policy contents as well as file existence, since the added integration scenarios chiefly assert command output and file lifecycle.

Files changed (10) +609 / -33

Enhancement (5) +283 / -3
copr.hppStore an explicit vendor-change choice for enable +7/-0

Store an explicit vendor-change choice for enable

• Adds optional command state for the --vendor-change choice, distinct from configuration and interactive defaults.

dnf5-plugins/copr_plugin/copr.hpp

copr_config.cppParse configured vendor-change defaults +33/-0

Parse configured vendor-change defaults

• Accepts directional choices and boolean values from Copr configuration. Reports invalid configured values and defaults to allowing both directions when unset.

dnf5-plugins/copr_plugin/copr_config.cpp

copr_config.hppDefine vendor-change choices and configuration accessors +35/-0

Define vendor-change choices and configuration accessors

• Introduces the four directional choices and declares parsing and default-reading methods used by the enable command.

dnf5-plugins/copr_plugin/copr_config.hpp

copr_enable.cppApply directional policies when enabling Copr +194/-1

Apply directional policies when enabling Copr

• Adds --vendor-change parsing and an interactive choice when no explicit value or --assumeyes is supplied. After a repository is saved, writes separate incoming and outgoing policies covering its enabled repository parts.

dnf5-plugins/copr_plugin/copr_enable.cpp

copr_repo.hppExpose repository IDs and policy naming +14/-2

Expose repository IDs and policy naming

• Declares accessors for enabled repository parts and their shared policy filename base. Makes interactive saving return whether it saved the repository, preventing policy creation after rejection.

dnf5-plugins/copr_plugin/copr_repo.hpp

Bug fix (1) +100 / -15
copr_repo.cppFix installroot writes and manage Copr policy cleanup +100/-15

Fix installroot writes and manage Copr policy cleanup

• Makes the absolute repository-directory constant relative before joining it to installroot and replaces std::ofstream with error-reporting filesystem writes. Exposes enabled repository IDs and a shared filename base, resets policies on disable, and removes manageable policies on remove.

dnf5-plugins/copr_plugin/copr_repo.cpp

Tests (2) +206 / -12
copr-chroot.featureVerify chroot repository discovery without host configuration +10/-5

Verify chroot repository discovery without host configuration

• Removes the --use-host-config workaround from the repository-list check and updates expected enable output for vendor policy creation.

integration-tests/dnf-behave-tests/dnf/plugins-core/copr-chroot.feature

copr.featureExercise installroot and vendor-policy lifecycles +196/-7

Exercise installroot and vendor-policy lifecycles

• Adds scenarios for configured and explicit vendor choices, policy-file creation, disable resets, and removal. Removes host-configuration workarounds and expects repository and policy paths under the installroot.

integration-tests/dnf-behave-tests/dnf/plugins-core/copr.feature

Documentation (1) +19 / -2
copr.8.rstDocument the vendor-change option +19/-2

Document the vendor-change option

• Describes directional and boolean option values, interactive and configured defaults, and an enable-command example.

doc/dnf5_plugins/copr.8.rst

Other (1) +1 / -1
copr_cmd_plugin.cppBump the Copr plugin version +1/-1

Bump the Copr plugin version

• Increases the plugin version from 0.1.0 to 0.2.0 alongside the expanded command behavior.

dnf5-plugins/copr_plugin/copr_cmd_plugin.cpp

@pkratoch pkratoch self-assigned this Nov 24, 2026
@pkratoch

Copy link
Copy Markdown
Contributor

The last two commits look good. Waiting for #3004 and then a rebase of this one.

copr_repo_directory() computed the destination directory as
"installroot / COPR_REPO_DIRECTORY". But COPR_REPO_DIRECTORY is
an absolute path ("/etc/yum.repos.d"), and appending an absolute path
with std::filesystem::path::operator/ replaces the left-hand side
entirely -- the installroot was silently discarded. As a result,
"dnf5 --installroot=X copr enable ..." wrote the .repo file into
the host's /etc/yum.repos.d instead of X/etc/yum.repos.d, and
"copr disable"/"copr remove" could not find the repository (they
enumerate repositories from the installroot-prefixed reposdir)
without --use-host-config.

Strip the root directory from COPR_REPO_DIRECTORY with
relative_path() before appending.
The copr plugin now correctly stores .repo files inside the
installroot. Update the tests accordingly:

- Check that "copr enable" creates the .repo file inside the
  installroot.
- Drop --use-host-config from "copr disable" and the follow-up
  "repo list": repositories enabled into the installroot are found
  there now, and the expected paths are installroot-relative.
- Add a "Test removing an enabled project" scenario verifying that
  "copr remove" deletes the .repo file and both vendor change
  policy files.

Also update the @destructive justification: it is no longer about
repositories outside the installroot (issue rpm-software-management#1497, fixed), but about
the Copr plugin reading its configuration outside the installroot,
which the tests need to modify.
@jrohel
jrohel force-pushed the fix/copr_plugin_repo_path branch from 440c2ce to 149bc8b Compare December 4, 2026 16:28
@jrohel

jrohel commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

@pkratoch Thanks for the review. PR #3004 was merged and this PR rebased.

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.

2 participants