Skip to content

Commit 07228d9

Browse files
committed
Added: Support for per-component/arch Release files
Rework creation of legacy release files. Restore CHANGES.md
1 parent 427795e commit 07228d9

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@
7272

7373
## 3.5.2 (2025-04-23) {: #3.5.2 }
7474

75-
#### Features {: #3.5.1-feature }
76-
77-
- Added compatibility with pulpcore 3.70+.
75+
No significant changes.
7876

7977
---
8078

CHANGES/1175.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support per-component/architecture Release files for cross-validation by related installers (i.e. ubiquity and debian-installer).

pulp_deb/app/tasks/publishing.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ def __init__(self, parent, component):
306306
self.plain_component = os.path.basename(component)
307307
self.package_index_files = {}
308308
self.source_index_file_info = None
309+
self.release_file_paths = {}
309310

310311
for architecture in self.parent.architectures:
311312
package_index_path = os.path.join(
@@ -320,6 +321,18 @@ def __init__(self, parent, component):
320321
open(package_index_path, "wb"),
321322
package_index_path,
322323
)
324+
325+
release_path = os.path.join(
326+
"dists",
327+
self.parent.dists_subfolder,
328+
self.plain_component,
329+
"binary-{}".format(architecture),
330+
"Release",
331+
)
332+
333+
self.release_file_paths[architecture] = _write_legacy_release_file(self, architecture)
334+
335+
323336
# Source indicies file
324337
source_index_path = os.path.join(
325338
"dists",
@@ -451,6 +464,13 @@ def finish(self):
451464
self.parent.add_metadata(source_index)
452465
self.parent.add_metadata(gz_source_index)
453466

467+
# Publish per-component/architecture Release files
468+
for release_path in self.release_file_paths.values():
469+
release = PublishedMetadata.create_from_file(
470+
publication=self.parent.publication, file=File(open(release_path, "rb"))
471+
)
472+
self.parent.add_metadata(release)
473+
454474
def generate_by_hash(self, index_path, index, gz_index_path, gz_index):
455475
for path, index in (
456476
(index_path, index),
@@ -477,6 +497,7 @@ def __init__(
477497
temp_dir,
478498
signing_service=None,
479499
):
500+
self._release = release
480501
self.publication = publication
481502
self.temp_env = {"PULP_TEMP_WORKING_DIR": _create_random_directory(temp_dir)}
482503
self.distribution = distribution = release.distribution
@@ -608,3 +629,36 @@ def _create_random_directory(path):
608629
dir_path = path + "/" + dir_name
609630
os.makedirs(dir_path, exist_ok=True)
610631
return dir_path
632+
633+
634+
def _write_legacy_release_file(component, arch):
635+
"""
636+
Add legacy per-architecture release files
637+
https://wiki.debian.org/DebianRepository/Format#Legacy_per-component-and-architecture_Release_files
638+
:param component: ComponentHelper instance this belongs to.
639+
:param arch: target architecture
640+
:return: relative path of the release file
641+
"""
642+
643+
rel = deb822.Release()
644+
645+
parent_release = component.parent.release
646+
rel["Archive"] = parent_release.get("Suite", parent_release["Codename"])
647+
rel["Origin"] = parent_release.get("Origin", "Pulp 3")
648+
rel["Label"] = parent_release.get("Label", "Pulp 3")
649+
if settings.APT_BY_HASH:
650+
rel["Acquire-By-Hash"] = settings.APT_BY_HASH
651+
rel["Component"] = component.plain_component
652+
rel["Architecture"] = arch
653+
654+
rel_path = os.path.join(
655+
"dists",
656+
component.parent.dists_subfolder,
657+
component.plain_component,
658+
f"binary-{arch}",
659+
"Release",
660+
)
661+
os.makedirs(os.path.dirname(rel_path), exist_ok=True)
662+
with open(rel_path, "wb") as fh:
663+
rel.dump(fh)
664+
return rel_path

0 commit comments

Comments
 (0)