Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some issues around overlapping package relative paths #3426

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 4 additions & 7 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 Expand Up @@ -262,11 +262,8 @@ def deferred_validate(self, data):
)
+ ".rpm"
)
if not data.get("relative_path"):
data["relative_path"] = filename
new_pkg["location_href"] = filename
else:
new_pkg["location_href"] = data["relative_path"]
data["relative_path"] = filename
new_pkg["location_href"] = filename

data.update(new_pkg)
return data
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
Loading