@@ -1604,7 +1604,11 @@ async def _notarize_geckodriver(context, path, workdir):
1604
1604
1605
1605
1606
1606
async def _notarize_all (context , path , workdir ):
1607
- """Notarizes all files in a tarball"""
1607
+ """
1608
+ Notarizes all files in a tarball
1609
+
1610
+ @Deprecated: This function is deprecated and will be removed in the future. Use apple_notarize_stacked instead.
1611
+ """
1608
1612
_ , extension = os .path .splitext (path )
1609
1613
# Attempt extracting
1610
1614
await _extract_tarfile (context , path , extension , tmp_dir = workdir )
@@ -1634,10 +1638,11 @@ async def _notarize_all(context, path, workdir):
1634
1638
async def apple_notarize (context , path , * args , ** kwargs ):
1635
1639
"""
1636
1640
Notarizes given package(s) using rcodesign.
1641
+
1642
+ @Deprecated: This function is deprecated and will be removed in the future. Use apple_notarize_stacked instead.
1637
1643
"""
1638
1644
# Setup workdir
1639
1645
notarization_workdir = os .path .join (context .config ["work_dir" ], "apple_notarize" )
1640
- shutil .rmtree (notarization_workdir , ignore_errors = True )
1641
1646
utils .mkdir (notarization_workdir )
1642
1647
1643
1648
_ , extension = os .path .splitext (path )
@@ -1658,3 +1663,88 @@ async def apple_notarize_geckodriver(context, path, *args, **kwargs):
1658
1663
utils .mkdir (notarization_workdir )
1659
1664
1660
1665
return await _notarize_geckodriver (context , path , notarization_workdir )
1666
+
1667
+
1668
+ @time_async_function
1669
+ async def apple_notarize_stacked (context , filelist_dict ):
1670
+ """
1671
+ Notarizes multiple packages using rcodesign.
1672
+ Submits everything before polling for status.
1673
+ """
1674
+ ATTEMPTS = 5
1675
+
1676
+ relpath_index_map = {}
1677
+ paths_to_notarize = []
1678
+ task_index = 0
1679
+
1680
+ # Create list of files to be notarized + check for potential problems
1681
+ for relpath , path_dict in filelist_dict .items ():
1682
+ task_index += 1
1683
+ relpath_index_map [relpath ] = task_index
1684
+ notarization_workdir = os .path .join (context .config ["work_dir" ], f"apple_notarize-{ task_index } " )
1685
+ shutil .rmtree (notarization_workdir , ignore_errors = True )
1686
+ utils .mkdir (notarization_workdir )
1687
+ _ , extension = os .path .splitext (relpath )
1688
+ if extension == ".pkg" :
1689
+ path = os .path .join (notarization_workdir , relpath )
1690
+ utils .copy_to_dir (path_dict ["full_path" ], notarization_workdir , target = relpath )
1691
+ paths_to_notarize .append (path )
1692
+ elif extension == ".gz" :
1693
+ await _extract_tarfile (context , path_dict ["full_path" ], extension , notarization_workdir )
1694
+ workdir_files = os .listdir (notarization_workdir )
1695
+ supported_files = [filename for filename in workdir_files if _can_notarize (filename , (".app" , ".pkg" ))]
1696
+ if not supported_files :
1697
+ raise SigningScriptError (f"No supported files found for file { relpath } " )
1698
+ for file in supported_files :
1699
+ path = os .path .join (notarization_workdir , file )
1700
+ paths_to_notarize .append (path )
1701
+ else :
1702
+ raise SigningScriptError (f"Unsupported file extension: { extension } for file { relpath } " )
1703
+
1704
+ # notarization submissions map (path -> submission_id)
1705
+ submissions_map = {}
1706
+ # Submit to notarization one by one
1707
+ for path in paths_to_notarize :
1708
+ submissions_map [path ] = await retry_async (
1709
+ func = rcodesign_notarize ,
1710
+ args = (path , context .apple_credentials_path ),
1711
+ attempts = ATTEMPTS ,
1712
+ retry_exceptions = RCodesignError ,
1713
+ )
1714
+
1715
+ # Notary wait all files
1716
+ for path , submission_id in submissions_map .items ():
1717
+ await retry_async (
1718
+ func = rcodesign_notary_wait ,
1719
+ args = (submission_id , context .apple_credentials_path ),
1720
+ attempts = ATTEMPTS ,
1721
+ retry_exceptions = RCodesignError ,
1722
+ )
1723
+
1724
+ # Staple files
1725
+ for path in submissions_map .keys ():
1726
+ await retry_async (
1727
+ func = rcodesign_staple ,
1728
+ args = [path ],
1729
+ attempts = ATTEMPTS ,
1730
+ retry_exceptions = RCodesignError ,
1731
+ )
1732
+
1733
+ # Wrap up
1734
+ stapled_files = []
1735
+ for relpath , path_dict in filelist_dict .items ():
1736
+ task_index = relpath_index_map [relpath ]
1737
+ notarization_workdir = os .path .join (context .config ["work_dir" ], f"apple_notarize-{ task_index } " )
1738
+ target_path = os .path .join (context .config ["work_dir" ], relpath )
1739
+ _ , extension = os .path .splitext (relpath )
1740
+ # Pkgs don't need to be tarred
1741
+ if extension == ".pkg" :
1742
+ utils .copy_to_dir (os .path .join (notarization_workdir , relpath ), os .path .dirname (target_path ))
1743
+ else :
1744
+ all_files = []
1745
+ for root , _ , files in os .walk (notarization_workdir ):
1746
+ for f in files :
1747
+ all_files .append (os .path .join (root , f ))
1748
+ await _create_tarfile (context , target_path , all_files , extension , notarization_workdir )
1749
+ stapled_files .append (target_path )
1750
+ return stapled_files
0 commit comments