12 from MacSDK import profile
13 from bockbuild.util.util import *
16 class MonoXamarinPackageProfile(MonoReleaseProfile):
17 description = 'The Mono Framework for MacOS (official release)'
20 MonoReleaseProfile.setup (self)
21 bockbuild.packages_to_build.extend(['mono-extensions'])
22 if bockbuild.cmd_options.release_build:
25 info("'--release' option not set, will not attempt to sign package!")
27 self.cache_host = 'http://xamarin-storage/bockbuild_cache/'
29 def setup_codesign(self):
30 self.identity = "Developer ID Installer: Xamarin Inc"
32 output = backtick("security -v find-identity")
33 if self.identity not in " ".join(output):
34 error("Identity '%s' was not found. You can create an unsigned package by removing '--release' to your command line." % self.identity)
36 password = os.getenv("CODESIGN_KEYCHAIN_PASSWORD")
38 print "Unlocking the keychain"
39 run_shell("security unlock-keychain -p %s" % password)
41 error("CODESIGN_KEYCHAIN_PASSWORD needs to be defined.")
43 def setup_release(self):
44 MonoReleaseProfile.setup_release(self)
45 self.release_packages['mono'].configure_flags.extend(
46 ['--enable-extension-module=xamarin --enable-native-types --enable-pecrypt'])
47 info('Xamarin extensions enabled')
49 def run_pkgbuild(self, working_dir, package_type):
50 output = MonoReleaseProfile.run_pkgbuild(
51 self, working_dir, package_type)
53 output_unsigned = os.path.join(os.path.dirname(
54 output), os.path.basename(output).replace('.pkg', '.UNSIGNED.pkg'))
55 shutil.move(output, output_unsigned)
57 if not bockbuild.cmd_options.release_build:
58 return output_unsigned
60 productsign = "/usr/bin/productsign"
61 productsign_cmd = ' '.join([productsign,
62 "-s '%s'" % self.identity,
63 "'%s'" % output_unsigned,
65 run_shell(productsign_cmd)
66 os.remove(output_unsigned)
67 self.verify_codesign(output)
71 def verify_codesign(self, pkg):
74 name = os.path.basename(pkg)
75 pkgdir = os.path.dirname(pkg)
77 spctl = "/usr/sbin/spctl"
79 [spctl, "-vvv", "--assess", "--type install", name, "2>&1"])
80 output = backtick(spctl_cmd)
82 if "accepted" in " ".join(output):
83 warn("%s IS SIGNED" % pkg)
85 error("%s IS NOT SIGNED:" % pkg)
89 MonoXamarinPackageProfile()