@@ -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