Skip to content

Commit

Permalink
Added to the distribution generate_config_repo field.
Browse files Browse the repository at this point in the history
closes #2985
  • Loading branch information
ipanova committed Sep 19, 2023
1 parent 748b3dd commit a749afa
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES/2985.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added to the distribution gnerate_config_repo field specifying whether Pulp should generate
``*.repo`` files. Defaults to False.
19 changes: 18 additions & 1 deletion docs/workflows/use_pulp_repo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Download GET response:
Install a package from Pulp
---------------------------
Download the config.repo file from the server at distribution's
If available, download the config.repo file from the server at distribution's
base_path and store it in /etc/yum.repos.d::

curl http://localhost:24816/pulp/content/foo/config.repo > /etc/yum.repos.d/foo.repo
Expand All @@ -54,6 +54,23 @@ Now use dnf to install a package::

sudo dnf install walrus

If config.repo file is not served by the distribution, it is necessary to manually set up the
configuration for the repository. One may initialize the configuration by leveraging the utility
``dnf config-manager`` like shown below. Afterwards, the user should be able to install the packages
by running dnf install packages.

.. code:: shell
BASE_URL=$(pulp rpm distribution show --name "${DIST_NAME}" | jq -r '.base_url')
BASE_PATH=$(pulp rpm distribution show --name "${DIST_NAME}" | jq -r '.base_path')
sudo dnf config-manager --add-repo "${BASE_URL}"
sudo dnf config-manager --save \
--setopt=*"${BASE_PATH}".gpgcheck=0 \
--setopt=*"${BASE_PATH}".repo_gpgcheck=0 \
sudo dnf install walrus
List and Install applicable Advisories
--------------------------------------

Expand Down
18 changes: 18 additions & 0 deletions pulp_rpm/app/migrations/0053_rpmdistribution_config_repo_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-06 14:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("rpm", "0051_alter_distributiontree_unique_together_and_more"),
]

operations = [
migrations.AddField(
model_name="rpmdistribution",
name="generate_config_repo",
field=models.BooleanField(default=False),
),
]
6 changes: 4 additions & 2 deletions pulp_rpm/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,11 @@ class RpmDistribution(Distribution, AutoAddObjPermsMixin):
repository_config_file_name = "config.repo"
INVALID_REPO_ID_CHARS = r"[^\w\-_.:]"

generate_config_repo = models.BooleanField(default=False)

def content_handler(self, path):
"""Serve config.repo and repomd.xml.key."""
if path == self.repository_config_file_name:
if self.generate_config_repo and path == self.repository_config_file_name:
repository, publication = self.get_repository_and_publication()
if not publication:
return
Expand Down Expand Up @@ -504,7 +506,7 @@ def content_headers_for(self, path):
def content_handler_list_directory(self, rel_path):
"""Return the extra dir entries."""
retval = set()
if rel_path == "":
if self.generate_config_repo and rel_path == "":
retval.add(self.repository_config_file_name)
return retval

Expand Down
7 changes: 6 additions & 1 deletion pulp_rpm/app/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,14 @@ class RpmDistributionSerializer(DistributionSerializer):
queryset=Publication.objects.exclude(complete=False),
allow_null=True,
)
generate_config_repo = serializers.BooleanField(
default=False,
required=False,
help_text=_("An option specifying whether Pulp should generate *.repo files."),
)

class Meta:
fields = DistributionSerializer.Meta.fields + ("publication",)
fields = DistributionSerializer.Meta.fields + ("publication", "generate_config_repo")
model = RpmDistribution


Expand Down

0 comments on commit a749afa

Please sign in to comment.