3 # ##### BEGIN GPL LICENSE BLOCK #####
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # ##### END GPL LICENSE BLOCK #####
21 # Helper script which takes care of signing provided location.
23 # The location can either be a directory (in which case all eligible binaries
24 # will be signed) or a single file (in which case a single file will be signed).
26 # This script takes care of all the complexity of communicating between process
27 # which requests file to be signed and the code signing server.
29 # NOTE: Signing happens in-place.
34 from pathlib import Path
36 from codesign.simple_code_signer import SimpleCodeSigner
39 def create_argument_parser():
40 parser = argparse.ArgumentParser()
41 parser.add_argument('path_to_sign', type=Path)
46 parser = create_argument_parser()
47 args = parser.parse_args()
48 path_to_sign = args.path_to_sign.absolute()
50 if sys.platform == 'win32':
51 # When WIX packed is used to generate .msi on Windows the CPack will
52 # install two different projects and install them to different
53 # installation prefix:
55 # - C:\b\build\_CPack_Packages\WIX\Blender
56 # - C:\b\build\_CPack_Packages\WIX\Unspecified
58 # Annoying part is: CMake's post-install script will only be run
59 # once, with the install prefix which corresponds to a project which
60 # was installed last. But we want to sign binaries from all projects.
61 # So in order to do so we detect that we are running for a CPack's
62 # project used for WIX and force parent directory (which includes both
63 # projects) to be signed.
65 # Here we force both projects to be signed.
66 if path_to_sign.name == 'Unspecified' and 'WIX' in str(path_to_sign):
67 path_to_sign = path_to_sign.parent
69 code_signer = SimpleCodeSigner()
70 code_signer.sign_file_or_directory(path_to_sign)
73 if __name__ == "__main__":