From f56b9d9e339e696a70b751dcfe6ffcbc8e3d3c03 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Tue, 30 Jan 2024 19:43:22 -0500 Subject: [PATCH] Remove location_href from the repo unique constraint This will avoid situations where the same package can potentially co-exist in a repo under different filenames. closes #2678 --- CHANGES/2678.bugfix | 1 + pulp_rpm/app/models/package.py | 5 +---- pulp_rpm/app/serializers/package.py | 4 ++-- pulp_rpm/app/tasks/publishing.py | 3 +++ 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 CHANGES/2678.bugfix diff --git a/CHANGES/2678.bugfix b/CHANGES/2678.bugfix new file mode 100644 index 0000000000..6b5b042a6f --- /dev/null +++ b/CHANGES/2678.bugfix @@ -0,0 +1 @@ +Pulp will no longer allow multiple packages with the same NEVRA to be present in a repo. diff --git a/pulp_rpm/app/models/package.py b/pulp_rpm/app/models/package.py index aeab1d27ad..83a5237f61 100644 --- a/pulp_rpm/app/models/package.py +++ b/pulp_rpm/app/models/package.py @@ -232,10 +232,7 @@ class Package(Content): # not part of createrepo_c metadata is_modular = models.BooleanField(default=False) - # createrepo_c treats 'nosrc' arch (opensuse specific use) as 'src' so it can seem that two - # packages are the same when they are not. By adding 'location_href' here we can recognize this. - # E.g. glibc-2.26.11.3.2.nosrc.rpm vs glibc-2.26.11.3.2.src.rpm - repo_key_fields = ("name", "epoch", "version", "release", "arch", "location_href") + repo_key_fields = ("name", "epoch", "version", "release", "arch") _pulp_domain = models.ForeignKey("core.Domain", default=get_domain_pk, on_delete=models.PROTECT) diff --git a/pulp_rpm/app/serializers/package.py b/pulp_rpm/app/serializers/package.py index 0109852581..36ae113d37 100644 --- a/pulp_rpm/app/serializers/package.py +++ b/pulp_rpm/app/serializers/package.py @@ -143,13 +143,13 @@ class PackageSerializer(SingleArtifactContentUploadSerializer, ContentChecksumSe ) location_base = serializers.CharField( - help_text=_("Base location of this package"), + help_text=_("DEPRECATED: Base location of this package"), allow_blank=True, required=False, read_only=True, ) location_href = serializers.CharField( - help_text=_("Relative location of package to the repodata"), + help_text=_("DEPRECATED: Relative location of package to the repodata"), read_only=True, ) diff --git a/pulp_rpm/app/tasks/publishing.py b/pulp_rpm/app/tasks/publishing.py index 6cdba4f616..7b87843557 100644 --- a/pulp_rpm/app/tasks/publishing.py +++ b/pulp_rpm/app/tasks/publishing.py @@ -148,6 +148,9 @@ def publish_artifacts(self, content, prefix=""): # Note that this only impacts user-created publications, which produce the "standard" # RPM layout of repo/Packages/f/foo.rpm. A publication created by mirror-sync retains # whatever layout their "upstream" repo-metadata dictates. + # + # Note, Jan 2024: As of now we are restricting new repository versions to only unique + # NEVRA, which means this hack can probably be phased out in a few years. fields = ["pk", "relative_path", "content__rpm_package__time_build"] for content_artifact in contentartifact_qs.values(*fields).iterator(): relative_path = content_artifact["relative_path"]