Skip to content

Commit

Permalink
Remove location_href from the repo unique constraint
Browse files Browse the repository at this point in the history
This will avoid situations where the same package can potentially
co-exist in a repo under different filenames.

closes pulp#2678
  • Loading branch information
dralley committed Feb 8, 2024
1 parent 4129dfc commit e676352
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES/2678.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pulp will no longer allow multiple packages with the same NEVRA to be present in a repo.
5 changes: 1 addition & 4 deletions pulp_rpm/app/models/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions pulp_rpm/app/serializers/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
3 changes: 3 additions & 0 deletions pulp_rpm/app/tasks/publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit e676352

Please sign in to comment.