[Bf-blender-cvs] [053fe5de6c6] codesign: Codesign: Tweaks to be able to sign non-Blender bundles

Sergey Sharybin noreply at git.blender.org
Wed Jan 8 16:32:14 CET 2020


Commit: 053fe5de6c6ec3e322ed64010e35027041e8e30c
Author: Sergey Sharybin
Date:   Wed Jan 8 16:31:48 2020 +0100
Branches: codesign
https://developer.blender.org/rB053fe5de6c6ec3e322ed64010e35027041e8e30c

Codesign: Tweaks to be able to sign non-Blender bundles

===================================================================

M	build_files/buildbot/codesign/macos_code_signer.py
M	build_files/buildbot/slave_bundle_dmg.py

===================================================================

diff --git a/build_files/buildbot/codesign/macos_code_signer.py b/build_files/buildbot/codesign/macos_code_signer.py
index 3d67b17d673..70f6ea06e10 100644
--- a/build_files/buildbot/codesign/macos_code_signer.py
+++ b/build_files/buildbot/codesign/macos_code_signer.py
@@ -121,10 +121,23 @@ class MacOSCodeSigner(BaseCodeSigner):
 
         mode = file.absolute_filepath.lstat().st_mode
         if mode & stat.S_IXUSR != 0:
-            return True
+            file_output = subprocess.check_output(
+                ("file", file.absolute_filepath)).decode()
+            if "64-bit executable" in file_output:
+                return True
 
         return file.relative_filepath.suffix in EXTENSIONS_TO_BE_SIGNED
 
+    def collect_files_to_sign(self, path: Path) \
+            -> List[AbsoluteAndRelativeFileName]:
+        # Include all files when signing app or dmg bundle: all the files are
+        # needed to do valid signature of bundle.
+        if path.name.endswith('.app'):
+            return AbsoluteAndRelativeFileName.recursively_from_directory(path)
+        if path.name.endswith('.dmg') and path.is_dir():
+            return AbsoluteAndRelativeFileName.recursively_from_directory(path)
+        return super().collect_files_to_sign(path)
+
     ############################################################################
     # Codesign.
 
diff --git a/build_files/buildbot/slave_bundle_dmg.py b/build_files/buildbot/slave_bundle_dmg.py
index 8a632d2ff3b..6fd74433ee7 100755
--- a/build_files/buildbot/slave_bundle_dmg.py
+++ b/build_files/buildbot/slave_bundle_dmg.py
@@ -156,6 +156,13 @@ def copy_app_bundles_to_directory(app_bundles: List[Path],
         shutil.copytree(app_bundle, directory / app_bundle.name)
 
 
+def get_main_app_bundle(app_bundles: List[Path]) -> Path:
+    """
+    Get application bundle main for the installation
+    """
+    return app_bundles[0]
+
+
 def create_dmg_image(app_bundles: List[Path],
                      dmg_filepath: Path,
                      volume_name: str) -> None:
@@ -239,13 +246,13 @@ def eject_volume(volume_name: str) -> None:
     mount_output = subprocess.check_output(['mount']).decode()
     device = ''
     for line in mount_output.splitlines():
+        if f'on {mount_directory_str} (' not in line:
+            continue
         tokens = line.split(' ', 3)
         if len(tokens) < 3:
             continue
         if tokens[1] != 'on':
             continue
-        if tokens[2] != mount_directory_str:
-            continue
         if device:
             raise Exception(
                 f'Multiple devices found for mounting point {mount_directory}')
@@ -293,15 +300,17 @@ def create_applications_link(mount_directory: Path) -> None:
 
 def run_applescript(applescript: Path,
                     volume_name: str,
+                    app_bundles: List[Path],
                     background_image_filepath: Path) -> None:
     """
     Run given applescript to adjust look and feel of the DMG
     """
 
+    main_app_bundle = get_main_app_bundle(app_bundles)
+
     with NamedTemporaryFile(
             mode='w', suffix='.applescript') as temp_applescript:
         print('Adjusting applescript for volume name...')
-        mount_directory = get_mount_directory_for_volume_name(volume_name)
         # Adjust script to the specific volume name.
         with open(applescript, mode='r') as input:
             for line in input.readlines():
@@ -319,6 +328,7 @@ def run_applescript(applescript: Path,
                         line = re.sub('to file ".*"',
                                       f'to file "{background_image_short}"',
                                       line)
+                line = line.replace('blender.app', main_app_bundle.name)
                 temp_applescript.write(line)
 
         temp_applescript.flush()
@@ -415,7 +425,8 @@ def create_final_dmg(app_bundles: List[Path],
 
     copy_background_if_needed(background_image_filepath, mount_directory)
     create_applications_link(mount_directory)
-    run_applescript(applescript, volume_name, background_image_filepath)
+    run_applescript(applescript, volume_name, app_bundles,
+                    background_image_filepath)
 
     print('Ejecting read-write DMG image...')
     eject_volume(volume_name)
@@ -485,7 +496,9 @@ def get_volume_name_from_dmg_filepath(dmg_filepath: Path) -> str:
     """
 
     tokens = dmg_filepath.name.split('-')
-    return tokens[0].capitalize()
+    words = tokens[0].split()
+
+    return ' '.join(word.capitalize() for word in words)
 
 
 def get_volume_name(requested_volume_name: str,



More information about the Bf-blender-cvs mailing list