-
Notifications
You must be signed in to change notification settings - Fork 83
Added: Support for per-component/arch Release files #1275
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Support per-component/architecture Release files for cross-validation by related installers (i.e. ubiquity and debian-installer). | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,7 @@ def publish( | |
| repository_version_pk, | ||
| simple, | ||
| structured, | ||
| publish_legacy_release_files, | ||
| checkpoint=False, | ||
| signing_service_pk=None, | ||
| publish_upstream_release_fields=None, | ||
|
|
@@ -109,12 +110,19 @@ def publish( | |
|
|
||
| log.info( | ||
| _( | ||
| "Publishing: repository={repo}, version={ver}, simple={simple}, structured={structured}" | ||
| ( | ||
| "Publishing: repository={repo}, " | ||
| "version={ver}, " | ||
| "simple={simple}, " | ||
| "structured={structured}, " | ||
| "publish_legacy_release_files={publish_legacy_release_files}" | ||
| ) | ||
| ).format( # noqa | ||
| repo=repo_version.repository.name, | ||
| ver=repo_version.number, | ||
| simple=simple, | ||
| structured=structured, | ||
| publish_legacy_release_files=publish_legacy_release_files, | ||
| ) | ||
| ) | ||
| with tempfile.TemporaryDirectory(".") as temp_dir: | ||
|
|
@@ -124,6 +132,7 @@ def publish( | |
| publication.simple = simple | ||
| publication.structured = structured | ||
| publication.signing_service = signing_service | ||
| publication.publish_legacy_release_files = publish_legacy_release_files | ||
| repository = AptRepository.objects.get(pk=repo_version.repository.pk) | ||
|
|
||
| if simple: | ||
|
|
@@ -306,6 +315,7 @@ def __init__(self, parent, component): | |
| self.plain_component = os.path.basename(component) | ||
| self.package_index_files = {} | ||
| self.source_index_file_info = None | ||
| self.release_file_paths = {} | ||
|
|
||
| for architecture in self.parent.architectures: | ||
| package_index_path = os.path.join( | ||
|
|
@@ -320,6 +330,12 @@ def __init__(self, parent, component): | |
| open(package_index_path, "wb"), | ||
| package_index_path, | ||
| ) | ||
|
|
||
| if self.parent.publication.publish_legacy_release_files: | ||
| self.release_file_paths[architecture] = _write_legacy_release_file( | ||
| self, architecture | ||
| ) | ||
|
|
||
| # Source indicies file | ||
| source_index_path = os.path.join( | ||
| "dists", | ||
|
|
@@ -451,6 +467,13 @@ def finish(self): | |
| self.parent.add_metadata(source_index) | ||
| self.parent.add_metadata(gz_source_index) | ||
|
|
||
| # Publish per-component/architecture Release files | ||
| for release_path in self.release_file_paths.values(): | ||
| release = PublishedMetadata.create_from_file( | ||
| publication=self.parent.publication, file=File(open(release_path, "rb")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we need to loop over this. Can't we just say this way we don't need the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea and i really appreciate the help. I updated the PR with the file creation in its own function as you suggested in the other change. I still used the |
||
| ) | ||
| self.parent.add_metadata(release) | ||
|
|
||
| def generate_by_hash(self, index_path, index, gz_index_path, gz_index): | ||
| for path, index in ( | ||
| (index_path, index), | ||
|
|
@@ -477,6 +500,7 @@ def __init__( | |
| temp_dir, | ||
| signing_service=None, | ||
| ): | ||
| self._release = release | ||
| self.publication = publication | ||
| self.temp_env = {"PULP_TEMP_WORKING_DIR": _create_random_directory(temp_dir)} | ||
| self.distribution = distribution = release.distribution | ||
|
|
@@ -608,3 +632,36 @@ def _create_random_directory(path): | |
| dir_path = path + "/" + dir_name | ||
| os.makedirs(dir_path, exist_ok=True) | ||
| return dir_path | ||
|
|
||
|
|
||
| def _write_legacy_release_file(component, arch): | ||
| """ | ||
| Add legacy per-architecture release files | ||
| https://wiki.debian.org/DebianRepository/Format#Legacy_per-component-and-architecture_Release_files | ||
| :param component: ComponentHelper instance this belongs to. | ||
| :param arch: target architecture | ||
| :return: relative path of the release file | ||
| """ | ||
|
|
||
| rel = deb822.Release() | ||
|
|
||
| parent_release = component.parent.release | ||
| rel["Archive"] = parent_release.get("Suite", parent_release["Codename"]) | ||
| rel["Origin"] = parent_release.get("Origin", "Pulp 3") | ||
| rel["Label"] = parent_release.get("Label", "Pulp 3") | ||
| if settings.APT_BY_HASH: | ||
| rel["Acquire-By-Hash"] = settings.APT_BY_HASH | ||
| rel["Component"] = component.plain_component | ||
| rel["Architecture"] = arch | ||
|
|
||
| rel_path = os.path.join( | ||
| "dists", | ||
| component.parent.dists_subfolder, | ||
| component.plain_component, | ||
| f"binary-{arch}", | ||
| "Release", | ||
| ) | ||
| os.makedirs(os.path.dirname(rel_path), exist_ok=True) | ||
| with open(rel_path, "wb") as fh: | ||
| rel.dump(fh) | ||
| return rel_path | ||
Uh oh!
There was an error while loading. Please reload this page.