1
0
Fork 0
forked from infra/ansible

copr-be: don't modify the redirect path for dnf install

This commit is contained in:
Jakub Kadlcik 2026-01-08 17:46:30 +01:00
commit 9f7c3b53c6

View file

@ -64,6 +64,8 @@ function pulp_url(copr_path)
url = url .. "/"
end
local split = string_split(copr_path, "/")
if copr_path:sub(-4) ~= ".rpm" then
-- This is easy for .xml files inside the repodata, because in Pulp they are
-- located at the same place where they would be on Copr backend.
@ -71,22 +73,30 @@ function pulp_url(copr_path)
--
-- This is the only thing that is needed to make `dnf copr enable` work, and
-- for the repos to use the https://download.copr.fedorainfracloud.org CDN.
-- This alone will not `dnf install` from the repos, though. See below.
url = url .. copr_path
elseif split[4] == "Packages" then
-- This is a .rpm file but the path already contains /Packages/, therefore
-- we know that this is a `dnf install` situation. The repo already points
-- to the correct path in Pulp, we just need to translate the CDN hostname
-- to the Pulp hostname
url = url .. copr_path
else
-- For .rpm files, the redirect is more complicated.
-- This is a .rpm file but we are not accessing it through a repository.
-- Therefore this redirect is not needed for DNF to work. It is for the
-- people that manually download RPMs from Copr using the CDN URL and they
-- use the paths that would be available before a project migration to Pulp
-- (e.g. Packit, Testing Farm, `copr-cli download-build`).
--
-- On Copr backend we used to have paths like this
-- @copr/copr-dev/fedora-43-x86_64/09975054-copr-cli/copr-cli-2.4.post1-1.git.12.8aed90c.fc43.src.rpm
-- While in Pulp, the same file is stored as
-- @copr/copr-dev/fedora-43-x86_64/Packages/c/copr-cli-2.4.post1-1.git.12.8aed90c.fc43.src.rpm
--
-- This redirect is not needed for DNF to work. This is for the people that
-- manually download RPMs from Copr using the CDN URL (e.g. Packit, Testing
-- Farm, `copr-cli download-build`).
local split = string_split(copr_path, "/")
local filename = split[5]
-- Replace e.g. `02924366-copr-cli` with `Packages/c`
local filename = split[5]
table.remove(split, 4)
table.insert(split, 4, "Packages")
table.insert(split, 5, filename:sub(1, 1))