12 from MonoReleaseProfile import MonoReleaseProfile
13 from bockbuild.util.util import *
16 class MonoXamarinPackageProfile(MonoReleaseProfile):
19 MonoReleaseProfile.__init__(self)
21 # add the private stuff
22 self.packages_to_build.extend(['mono-extensions'])
24 if self.cmd_options.release_build:
27 info("'--release' option not set, will not attempt to sign package!")
29 self.cache_host = 'http://storage.bos.xamarin.com/bockbuild_cache/'
31 def setup_codesign(self):
32 self.identity = "Developer ID Installer: Xamarin Inc"
34 output = backtick("security -v find-identity")
35 if self.identity not in " ".join(output):
36 error("Identity '%s' was not found. You can create an unsigned package by removing '--release' to your command line." % self.identity)
38 password = os.getenv("CODESIGN_KEYCHAIN_PASSWORD")
40 print "Unlocking the keychain"
41 run_shell("security unlock-keychain -p %s" % password)
43 error("CODESIGN_KEYCHAIN_PASSWORD needs to be defined.")
45 def setup_release(self):
46 MonoReleaseProfile.setup_release(self)
47 self.release_packages['mono'].configure_flags.extend(
48 ['--enable-extension-module=xamarin --enable-native-types --enable-pecrypt'])
49 info('Xamarin extensions enabled')
51 def run_pkgbuild(self, working_dir, package_type):
52 output = MonoReleaseProfile.run_pkgbuild(
53 self, working_dir, package_type)
55 output_unsigned = os.path.join(os.path.dirname(
56 output), os.path.basename(output).replace('.pkg', '.UNSIGNED.pkg'))
57 shutil.move(output, output_unsigned)
59 if not self.cmd_options.release_build:
60 return output_unsigned
62 productsign = "/usr/bin/productsign"
63 productsign_cmd = ' '.join([productsign,
64 "-s '%s'" % self.identity,
65 "'%s'" % output_unsigned,
67 run_shell(productsign_cmd)
68 os.remove(output_unsigned)
69 self.verify_codesign(output)
73 def verify_codesign(self, pkg):
76 name = os.path.basename(pkg)
77 pkgdir = os.path.dirname(pkg)
79 spctl = "/usr/sbin/spctl"
81 [spctl, "-vvv", "--assess", "--type install", name, "2>&1"])
82 output = backtick(spctl_cmd)
84 if "accepted" in " ".join(output):
85 warn("%s IS SIGNED" % pkg)
87 error("%s IS NOT SIGNED:" % pkg)