Skip to content

Commit

Permalink
Use the correct relative paths in Release files
Browse files Browse the repository at this point in the history
fixes #6876
https://pulp.plan.io/issues/6876

I also fixed several instances of using the codename in paths. Codenames
should never be used in paths. Always use the "distribution" in paths.

See also:
https://pulp.plan.io/issues/6051
  • Loading branch information
quba42 committed Jun 4, 2020
1 parent 7cad3a9 commit 06b9ad1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES/6876.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where published Release files were using paths relative to the repo root, instead of relative to the release file.
27 changes: 20 additions & 7 deletions pulp_deb/app/tasks/publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def publish(repository_version_pk, simple=False, structured=False, signing_servi

if simple:
codename = "default"
distribution = "default"
component_name = "all"
architectures = (
Package.objects.filter(pk__in=repo_version.content.order_by("-pulp_created"),)
Expand All @@ -99,6 +100,7 @@ def publish(repository_version_pk, simple=False, structured=False, signing_servi
release_helper = _ReleaseHelper(
publication=publication,
codename=codename,
distribution=distribution,
components=[component_name],
architectures=architectures,
description=repository.description,
Expand All @@ -123,6 +125,7 @@ def publish(repository_version_pk, simple=False, structured=False, signing_servi
release_helper = _ReleaseHelper(
publication=publication,
codename=release.codename,
distribution=release.distribution,
components=components.values_list("component", flat=True),
architectures=architectures,
description=repository.description,
Expand Down Expand Up @@ -152,7 +155,7 @@ def __init__(self, parent, name):
for architecture in self.parent.architectures:
package_index_path = os.path.join(
"dists",
self.parent.release["codename"],
self.parent.distribution,
self.name,
"binary-{}".format(architecture),
"Packages",
Expand Down Expand Up @@ -199,9 +202,17 @@ def finish(self):

class _ReleaseHelper:
def __init__(
self, publication, codename, components, architectures, label=None, description=None
self,
publication,
codename,
distribution,
components,
architectures,
label=None,
description=None,
):
self.publication = publication
self.distribution = distribution
self.release = deb822.Release()
self.release["Codename"] = codename
self.release["Architectures"] = " ".join(architectures)
Expand All @@ -219,18 +230,20 @@ def __init__(

def add_metadata(self, metadata):
artifact = metadata._artifacts.get()
release_file_folder = os.path.join("dists", self.distribution)
release_file_relative_path = os.path.relpath(metadata.relative_path, release_file_folder)

self.release["MD5sum"].append(
{"md5sum": artifact.md5, "size": artifact.size, "name": metadata.relative_path}
{"md5sum": artifact.md5, "size": artifact.size, "name": release_file_relative_path}
)
self.release["SHA1"].append(
{"sha1": artifact.sha1, "size": artifact.size, "name": metadata.relative_path}
{"sha1": artifact.sha1, "size": artifact.size, "name": release_file_relative_path}
)
self.release["SHA256"].append(
{"sha256": artifact.sha256, "size": artifact.size, "name": metadata.relative_path}
{"sha256": artifact.sha256, "size": artifact.size, "name": release_file_relative_path}
)
self.release["SHA512"].append(
{"sha512": artifact.sha512, "size": artifact.size, "name": metadata.relative_path}
{"sha512": artifact.sha512, "size": artifact.size, "name": release_file_relative_path}
)

def finish(self):
Expand All @@ -239,7 +252,7 @@ def finish(self):
component.finish()
# Publish Release file
self.release["components"] = " ".join(self.components.keys())
release_dir = os.path.join("dists", self.release["codename"])
release_dir = os.path.join("dists", self.distribution)
release_path = os.path.join(release_dir, "Release")
os.makedirs(os.path.dirname(release_path), exist_ok=True)
with open(release_path, "wb") as release_file:
Expand Down

0 comments on commit 06b9ad1

Please sign in to comment.