Skip to content

Commit

Permalink
Fix copr chroot specification: replace faulty regex with simpler split
Browse files Browse the repository at this point in the history
The regex `-[^-]*` has multiple matches in a chroot like:
`fedora-rawhide-x86_64`, the result of the `regex_replace` is just `fedora`.

Replace it with simpler split.
  • Loading branch information
kontura committed Nov 15, 2024
1 parent 708604c commit d5001b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dnf5-plugins/copr_plugin/copr_repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ CoprRepo::CoprRepo(
baseurl_chroot = selected_chroot;
if (!available_chroots.contains(selected_chroot))
available_chroots_error(available_chroots, selected_chroot);
// remove the "-<arch>" suffix
json_selector = std::regex_replace(selected_chroot, std::regex("-[^-]*"), "");
arch = std::regex_replace(selected_chroot, std::regex(".*-"), "");
// Chroot can look like: fedora-rawhide-x86_64
// Split on second/last "-" to: "fedora-rawhide" and "x86_64"
size_t second_dash_pos = selected_chroot.find_last_of("-");
json_selector = selected_chroot.substr(0, second_dash_pos);
arch = selected_chroot.substr(second_dash_pos + 1);
} else {
baseurl_chroot = get_repo_triplet(available_chroots, config_name_version, arch, json_selector);
if (baseurl_chroot.empty()) {
Expand Down

0 comments on commit d5001b1

Please sign in to comment.