Skip to content

Commit

Permalink
frontend: point Copr repositories to Pulp
Browse files Browse the repository at this point in the history
Fix fedora-copr#3375

Of course only for Copr projects that has configured to have their
storage in Pulp, not all Copr projects.

There are three possible options how to implement this.

1. The Most straightforward is to not generate repofiles ourselves and let Pulp
   do it. The downside is that we would have to pass additional parameters (it
   is possible though) such as repo priority, module hotfixes attribute, etc,
   and figure out how to count repo downloads
2. Generate repofiles ourselves, only point to `baseurl` in Pulp. This IMHO the
   best option for keeping compatibility between storage on the backend and in
   Pulp, so I implement this option in this PR.
3. Adding a Lighttpd redirect for `baseurl` of the Pulp-stored projects to Pulp
   content URL. This will be needed in the future to ensure that users don't
   have to re-enable Copr repositories, once those projects are migrated to
   Pulp. But this will be hard to implement, so we decided to do it when the
   time comes.
  • Loading branch information
FrostyX committed Aug 24, 2024
1 parent 69957fc commit f8cef70
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions frontend/coprs_frontend/coprs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class Config(object):
ROLLING_CHROOTS_INACTIVITY_WARNING = 180
ROLLING_CHROOTS_INACTIVITY_REMOVAL = 180

# If build results for (some) projects are stored in Pulp, what is the
# shared part of the URL for all repositories, e.g.
# https://pulp.stage.devshift.net/api/pulp-content/copr
PULP_CONTENT_URL = None


class ProductionConfig(Config):
DEBUG = False
Expand Down
9 changes: 7 additions & 2 deletions frontend/coprs_frontend/coprs/templates/coprs/copr_dir.repo
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[{{ repo_id }}]
name={{ name }}
{{- " (" + arch + ")" if arch }}
{% if not pulp %}
baseurl={{ url | fix_url_https_backend }}
type=rpm-md
skip_if_unavailable=True
gpgcheck={{ config.REPO_GPGCHECK | default("1")}}
gpgkey={{ pubkey_url | fix_url_https_backend }}
{% else %}
baseurl={{ url }}
gpgcheck=0
{% endif %}
type=rpm-md
skip_if_unavailable=True
repo_gpgcheck=0
{% if cost %}
cost={{ cost }}
Expand Down
15 changes: 11 additions & 4 deletions frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter

from copr_common.enums import StorageEnum
from coprs import app
from coprs import cache
from coprs import db
Expand Down Expand Up @@ -861,14 +862,20 @@ def render_repo_template(copr_dir, mock_chroot, arch=None, cost=None, runtime_de
copr_dir.copr, copr_dir.name, multilib=arch,
dep_idx=runtime_dep, dependent=dependent)

url = os.path.join(copr_dir.repo_url, '') # adds trailing slash
repo_url = generate_repo_url(mock_chroot, url, arch)
pubkey_url = urljoin(url, "pubkey.gpg")
pulp = copr_dir.copr.storage == StorageEnum.pulp
if pulp:
url = "/".join([app.config["PULP_CONTENT_URL"], copr_dir.full_name])
pubkey_url = None
else:
url = os.path.join(copr_dir.repo_url, '') # adds trailing slash
pubkey_url = urljoin(url, "pubkey.gpg")

repo_url = generate_repo_url(mock_chroot, url, arch)
return flask.render_template("coprs/copr_dir.repo", copr_dir=copr_dir,
url=repo_url, pubkey_url=pubkey_url,
repo_id=repo_id, arch=arch, cost=cost,
name=name, repo_priority=copr_dir.copr.repo_priority)
name=name, pulp=pulp,
repo_priority=copr_dir.copr.repo_priority)


def _render_external_repo_template(dep, copr_dir, mock_chroot, dep_idx):
Expand Down

0 comments on commit f8cef70

Please sign in to comment.