1818
1919import yaml
2020
21- from ..features .cname import CName
2221from .bucket import Bucket
2322
2423
@@ -116,11 +115,6 @@ def upload_from_directory(
116115
117116 artifacts_dir = Path (artifacts_dir )
118117
119- cname_object = CName (cname )
120-
121- if cname_object .arch is None :
122- raise RuntimeError ("Architecture could not be determined from cname" )
123-
124118 if not artifacts_dir .is_dir ():
125119 raise RuntimeError (f"Artifacts directory given is invalid: { artifacts_dir } " )
126120
@@ -130,18 +124,17 @@ def upload_from_directory(
130124 release_config = ConfigParser (allow_unnamed_section = True )
131125 release_config .read (release_file )
132126
133- if cname_object . version != release_config . get (
134- UNNAMED_SECTION , "GARDENLINUX_VERSION"
135- ):
136- raise RuntimeError (
137- f"Release file data and given cname conflict detected: Version { cname_object . version } "
138- )
127+ # Get architecture from the GARDENLINUX_CNAME (second to last element when split by -)
128+ release_cname = release_config . get ( UNNAMED_SECTION , "GARDENLINUX_CNAME" )
129+ cname_parts = release_cname . split ( "-" )
130+ if len ( cname_parts ) < 2 :
131+ raise RuntimeError ( f"Invalid GARDENLINUX_CNAME format in release file: { release_cname } " )
132+ arch = cname_parts [ - 2 ] # Second to last element is the architecture
139133
140- if cname_object .commit_id != release_config .get (
141- UNNAMED_SECTION , "GARDENLINUX_COMMIT_ID"
142- ):
134+ # Verify the provided cname matches the release file
135+ if cname != release_cname :
143136 raise RuntimeError (
144- f"Release file data and given cname conflict detected: Commit ID { cname_object . commit_id } "
137+ f"Release file cname does not match provided cname: { release_cname } != { cname } "
145138 )
146139
147140 commit_hash = release_config .get (UNNAMED_SECTION , "GARDENLINUX_COMMIT_ID_LONG" )
@@ -171,13 +164,16 @@ def upload_from_directory(
171164 if secureboot is None :
172165 secureboot = "_trustedboot" in feature_list
173166
167+ version = release_config .get (UNNAMED_SECTION , "GARDENLINUX_VERSION" )
168+ platform = release_config .get (UNNAMED_SECTION , "GARDENLINUX_PLATFORM" )
169+
174170 metadata = {
175- "platform" : cname_object . platform ,
176- "architecture" : cname_object . arch ,
171+ "platform" : platform ,
172+ "architecture" : arch ,
177173 "base_image" : None ,
178174 "build_committish" : commit_hash ,
179175 "build_timestamp" : datetime .fromtimestamp (release_timestamp ).isoformat (),
180- "gardenlinux_epoch" : int (cname_object . version .split ("." , 1 )[0 ]),
176+ "gardenlinux_epoch" : int (version .split ("." , 1 )[0 ]),
181177 "logs" : None ,
182178 "modifiers" : feature_list ,
183179 "require_uefi" : require_uefi ,
@@ -186,10 +182,15 @@ def upload_from_directory(
186182 "s3_bucket" : self ._bucket .name ,
187183 "s3_key" : f"meta/singles/{ cname } " ,
188184 "test_result" : None ,
189- "version" : cname_object . version ,
185+ "version" : version ,
190186 "paths" : [],
191187 }
192188
189+ if release_config .has_option (UNNAMED_SECTION , "GARDENLINUX_PLATFORM_VARIANT" ):
190+ metadata ["platform_variant" ] = release_config .get (
191+ UNNAMED_SECTION , "GARDENLINUX_PLATFORM_VARIANT"
192+ )
193+
193194 re_object = re .compile ("[^a-zA-Z0-9\\ s+\\ -=.\\ _:/@]" )
194195
195196 for artifact in artifacts_dir .iterdir ():
@@ -219,9 +220,9 @@ def upload_from_directory(
219220 }
220221
221222 s3_tags = {
222- "architecture" : re_object .sub ("+" , cname_object . arch ),
223- "platform" : re_object .sub ("+" , cname_object . platform ),
224- "version" : re_object .sub ("+" , cname_object . version ),
223+ "architecture" : re_object .sub ("+" , arch ),
224+ "platform" : re_object .sub ("+" , platform ),
225+ "version" : re_object .sub ("+" , version ),
225226 "committish" : commit_hash ,
226227 "md5sum" : md5sum ,
227228 "sha256sum" : sha256sum ,
0 commit comments