@@ -221,109 +221,44 @@ def update_expat(dirs: Dirs, env: EnvMapping) -> None:
221221 # Copy *.h and *.c to expat directory
222222 expat_lib_dir = dirs .source / "Modules" / "expat" / f"expat-{ version } " / "lib"
223223 expat_dir = dirs .source / "Modules" / "expat"
224+ updated_files = []
224225 for file in glob .glob (str (expat_lib_dir / "*.h" )):
225- if expat_dir / os .path .basename (file ):
226- (expat_dir / os .path .basename (file )).unlink ()
226+ target = expat_dir / os .path .basename (file )
227+ if target .exists ():
228+ target .unlink ()
227229 shutil .move (file , str (expat_dir ))
230+ updated_files .append (target )
228231 for file in glob .glob (str (expat_lib_dir / "*.c" )):
229- if expat_dir / os .path .basename (file ):
230- (expat_dir / os .path .basename (file )).unlink ()
232+ target = expat_dir / os .path .basename (file )
233+ if target .exists ():
234+ target .unlink ()
231235 shutil .move (file , str (expat_dir ))
232- # Update sbom.spdx.json with the correct hashes. This became a thing in 3.12
233- # python Tools/build/generate_sbom.py doesn't work because it requires a git
234- # repository, so we have to do it manually.
235- if env ["RELENV_PY_MAJOR_VERSION" ] in ["3.12" , "3.13" , "3.14" ]:
236- checksums = {
237- "Modules/expat/expat.h" : [
238- {
239- "algorithm" : "SHA1" ,
240- "checksumValue" : "a4395dd0589a97aab0904f7a5f5dc5781a086aa2" ,
241- },
242- {
243- "algorithm" : "SHA256" ,
244- "checksumValue" : "610b844bbfa3ec955772cc825db4d4db470827d57adcb214ad372d0eaf00e591" ,
245- },
246- ],
247- "Modules/expat/expat_external.h" : [
248- {
249- "algorithm" : "SHA1" ,
250- "checksumValue" : "8fdf2e79a7ab46a3c76c74ed7e5fe641cbef308d" ,
251- },
252- {
253- "algorithm" : "SHA256" ,
254- "checksumValue" : "ffb960af48b80935f3856a16e87023524b104f7fc1e58104f01db88ba7bfbcc9" ,
255- },
256- ],
257- "Modules/expat/internal.h" : [
258- {
259- "algorithm" : "SHA1" ,
260- "checksumValue" : "7dce7d98943c5db33ae05e54801dcafb4547b9dd" ,
261- },
262- {
263- "algorithm" : "SHA256" ,
264- "checksumValue" : "6bfe307d52e7e4c71dbc30d3bd902a4905cdd83bbe4226a7e8dfa8e4c462a157" ,
265- },
266- ],
267- "Modules/expat/refresh.sh" : [
268- {
269- "algorithm" : "SHA1" ,
270- "checksumValue" : "71812ca27328697a8dcae1949cd638717538321a" ,
271- },
272- {
273- "algorithm" : "SHA256" ,
274- "checksumValue" : "64fd1368de41e4ebc14593c65f5a676558aed44bd7d71c43ae05d06f9086d3b0" ,
275- },
276- ],
277- "Modules/expat/xmlparse.c" : [
278- {
279- "algorithm" : "SHA1" ,
280- "checksumValue" : "4c81a1f04fc653877c63c834145c18f93cd95f3e" ,
281- },
282- {
283- "algorithm" : "SHA256" ,
284- "checksumValue" : "04a379615f476d55f95ca1853107e20627b48ca4afe8d0fd5981ac77188bf0a6" ,
285- },
286- ],
287- "Modules/expat/xmlrole.h" : [
288- {
289- "algorithm" : "SHA1" ,
290- "checksumValue" : "ac2964cca107f62dd133bfd4736a9a17defbc401" ,
291- },
292- {
293- "algorithm" : "SHA256" ,
294- "checksumValue" : "92e41f373b67f6e0dcd7735faef3c3f1e2c17fe59e007e6b74beef6a2e70fa88" ,
295- },
296- ],
297- "Modules/expat/xmltok.c" : [
298- {
299- "algorithm" : "SHA1" ,
300- "checksumValue" : "1e2d35d90a1c269217f83d3bdf3c71cc22cb4c3f" ,
301- },
302- {
303- "algorithm" : "SHA256" ,
304- "checksumValue" : "98d0fc735041956cc2e7bbbe2fb8f03130859410e0aee5e8015f406a37c02a3c" ,
305- },
306- ],
307- "Modules/expat/xmltok.h" : [
308- {
309- "algorithm" : "SHA1" ,
310- "checksumValue" : "d126831eaa5158cff187a8c93f4bc1c8118f3b17" ,
311- },
312- {
313- "algorithm" : "SHA256" ,
314- "checksumValue" : "91bf003a725a675761ea8d92cebc299a76fd28c3a950572f41bc7ce5327ee7b5" ,
315- },
316- ],
317- }
318- spdx_json = dirs .source / "Misc" / "sbom.spdx.json"
319- with open (str (spdx_json ), "r" ) as f :
320- data = json .load (f )
321- for file in data ["files" ]:
322- if file ["fileName" ] in checksums .keys ():
323- print (file ["fileName" ])
324- file ["checksums" ] = checksums [file ["fileName" ]]
325- with open (str (spdx_json ), "w" ) as f :
326- json .dump (data , f , indent = 2 )
236+ updated_files .append (target )
237+
238+ # Touch all updated files to ensure MSBuild rebuilds them
239+ # (The original files may have newer timestamps)
240+ import time
241+
242+ now = time .time ()
243+ for target_file in updated_files :
244+ os .utime (target_file , (now , now ))
245+
246+ # Update SBOM with correct checksums for updated expat files
247+ # Map SBOM file names to actual file paths
248+ from relenv .build .common import update_sbom_checksums
249+
250+ files_to_update = {}
251+ for target_file in updated_files :
252+ # SBOM uses relative paths from Python source root
253+ relative_path = f"Modules/expat/{ target_file .name } "
254+ files_to_update [relative_path ] = target_file
255+
256+ # Also include refresh.sh which was patched
257+ bash_refresh = dirs .source / "Modules" / "expat" / "refresh.sh"
258+ if bash_refresh .exists ():
259+ files_to_update ["Modules/expat/refresh.sh" ] = bash_refresh
260+
261+ update_sbom_checksums (dirs .source , files_to_update )
327262
328263
329264def build_python (env : EnvMapping , dirs : Dirs , logfp : IO [str ]) -> None :
0 commit comments