@@ -624,16 +624,19 @@ def _to_d_artifact(self, relative_path, data=None):
624
624
)
625
625
626
626
async def _handle_distribution (self , distribution ):
627
+ is_flat = distribution .endswith ("/" )
628
+ stored_distribution = "flat-repo" if is_flat else distribution
629
+
627
630
log .info (_ ('Downloading Release file for distribution: "{}"' ).format (distribution ))
628
631
# Create release_file
629
- if distribution [ - 1 ] == "/" :
630
- release_file_dir = distribution .strip ("/" )
632
+ if is_flat :
633
+ upstream_file_dir = distribution .strip ("/" )
631
634
else :
632
- release_file_dir = os .path .join ("dists" , distribution )
635
+ upstream_file_dir = os .path .join ("dists" , distribution )
633
636
release_file_dc = DeclarativeContent (
634
- content = ReleaseFile (distribution = distribution , relative_path = release_file_dir ),
637
+ content = ReleaseFile (distribution = stored_distribution , relative_path = upstream_file_dir ),
635
638
d_artifacts = [
636
- self ._to_d_artifact (os .path .join (release_file_dir , filename ))
639
+ self ._to_d_artifact (os .path .join (upstream_file_dir , filename ))
637
640
for filename in ReleaseFile .SUPPORTED_ARTIFACTS
638
641
],
639
642
)
@@ -665,7 +668,7 @@ async def _handle_distribution(self, distribution):
665
668
release_fields = {
666
669
"codename" : release_file .codename ,
667
670
"suite" : release_file .suite ,
668
- "distribution" : distribution ,
671
+ "distribution" : stored_distribution ,
669
672
}
670
673
671
674
if "version" in release_file_dict :
@@ -680,17 +683,17 @@ async def _handle_distribution(self, distribution):
680
683
await self .put (DeclarativeContent (content = Release (** release_fields )))
681
684
682
685
# Create release architectures
683
- if release_file .architectures :
684
- architectures = _filter_split_architectures (
685
- release_file .architectures , self .remote .architectures , distribution
686
- )
687
- elif distribution [- 1 ] == "/" :
686
+ if is_flat :
688
687
message = (
689
- "The ReleaseFile content unit architecrures are unset for the flat repo with "
688
+ "The ReleaseFile content unit architectures are unset for the flat repo with "
690
689
"distribution '{}'. ReleaseArchitecture content creation is deferred!"
691
690
)
692
691
log .warning (_ (message ).format (distribution ))
693
692
architectures = []
693
+ elif release_file .architectures :
694
+ architectures = _filter_split_architectures (
695
+ release_file .architectures , self .remote .architectures , distribution
696
+ )
694
697
695
698
for architecture in architectures :
696
699
release_architecture_dc = DeclarativeContent (
@@ -719,9 +722,16 @@ async def _handle_distribution(self, distribution):
719
722
for unit in release_file_dict [digest_name ]:
720
723
file_references [unit ["Name" ]].update (unit )
721
724
722
- if distribution [ - 1 ] == "/" :
725
+ if is_flat :
723
726
# Handle flat repo
724
- sub_tasks = [self ._handle_flat_repo (file_references , release_file , distribution )]
727
+ sub_tasks = [
728
+ self ._handle_flat_repo (
729
+ file_references ,
730
+ release_file ,
731
+ distribution = stored_distribution ,
732
+ upstream_dist_path = upstream_file_dir ,
733
+ )
734
+ ]
725
735
else :
726
736
# Handle components
727
737
sub_tasks = [
@@ -833,7 +843,9 @@ async def _handle_component(
833
843
)
834
844
await asyncio .gather (* pending_tasks )
835
845
836
- async def _handle_flat_repo (self , file_references , release_file , distribution ):
846
+ async def _handle_flat_repo (
847
+ self , file_references , release_file , distribution , upstream_dist_path
848
+ ):
837
849
# We are creating a component so the flat repo can be published as a structured repo!
838
850
release_component_dc = DeclarativeContent (
839
851
content = ReleaseComponent (component = "flat-repo-component" , distribution = distribution )
@@ -849,6 +861,7 @@ async def _handle_flat_repo(self, file_references, release_file, distribution):
849
861
architecture = "" ,
850
862
file_references = file_references ,
851
863
distribution = distribution ,
864
+ is_flat = True ,
852
865
)
853
866
)
854
867
@@ -868,15 +881,19 @@ async def _handle_package_index(
868
881
infix = "" ,
869
882
distribution = None ,
870
883
hybrid_format = False ,
884
+ is_flat = False ,
871
885
):
886
+ if is_flat :
887
+ release_file_package_index_dir = ""
888
+ else :
889
+ release_file_package_index_dir = os .path .join (
890
+ release_component .plain_component ,
891
+ infix ,
892
+ f"binary-{ architecture } " ,
893
+ )
872
894
# Create package_index
873
895
release_base_path = os .path .dirname (release_file .relative_path )
874
- # Package index directory relative to the release file:
875
- release_file_package_index_dir = (
876
- os .path .join (release_component .plain_component , infix , "binary-{}" .format (architecture ))
877
- if release_file .distribution [- 1 ] != "/"
878
- else ""
879
- )
896
+
880
897
# Package index directory relative to the repository root:
881
898
package_index_dir = os .path .join (release_base_path , release_file_package_index_dir )
882
899
d_artifacts = []
@@ -948,7 +965,7 @@ async def _handle_package_index(
948
965
):
949
966
# Sanity check the architecture from the package paragraph:
950
967
package_paragraph_architecture = package_paragraph ["Architecture" ]
951
- if release_file . distribution [ - 1 ] == "/" :
968
+ if is_flat :
952
969
if (
953
970
self .remote .architectures
954
971
and package_paragraph_architecture != "all"
@@ -1035,32 +1052,23 @@ async def _handle_package_index(
1035
1052
)
1036
1053
)
1037
1054
await self .put (package_release_component_dc )
1038
- if release_file . distribution [ - 1 ] == "/" :
1055
+ if is_flat :
1039
1056
package_architectures .add (package .architecture )
1040
1057
1041
1058
# For flat repos we may still need to create ReleaseArchitecture content:
1042
- if release_file . distribution [ - 1 ] == "/" :
1059
+ if is_flat :
1043
1060
if release_file .architectures :
1044
1061
for architecture in package_architectures :
1045
- if architecture not in release_file .architectures .split ():
1046
- message = (
1047
- "The flat repo with distribution '{}' contains packages with "
1048
- "architecture '{}' but this is not included in the ReleaseFile's "
1049
- "architectures field '{}'!"
1050
- )
1051
- log .warning (
1052
- _ (message ).format (
1053
- release_file .distribution , architecture , release_file .architectures
1054
- )
1055
- )
1056
- message = "Creating additional ReleaseArchitecture for architecture '{}'!"
1057
- log .warning (_ (message ).format (architecture ))
1058
- release_architecture_dc = DeclarativeContent (
1059
- content = ReleaseArchitecture (
1060
- architecture = architecture , distribution = distribution
1061
- )
1062
+ log .debug (
1063
+ "Flat Repo Architecture handling: "
1064
+ f"Creating ReleaseArchitecture for architecture { architecture } ."
1065
+ )
1066
+ release_architecture_dc = DeclarativeContent (
1067
+ content = ReleaseArchitecture (
1068
+ architecture = architecture , distribution = "flat-repo"
1062
1069
)
1063
- await self .put (release_architecture_dc )
1070
+ )
1071
+ await self .put (release_architecture_dc )
1064
1072
else :
1065
1073
package_architectures_string = " " .join (package_architectures )
1066
1074
message = (
@@ -1076,7 +1084,7 @@ async def _handle_package_index(
1076
1084
for architecture in package_architectures :
1077
1085
release_architecture_dc = DeclarativeContent (
1078
1086
content = ReleaseArchitecture (
1079
- architecture = architecture , distribution = distribution
1087
+ architecture = architecture , distribution = "flat-repo"
1080
1088
)
1081
1089
)
1082
1090
await self .put (release_architecture_dc )
0 commit comments