1 #!/usr/bin/python -u -OO
14 if __name__ == "__main__":
15 sys.path.append(os.path.realpath('../..'))
16 sys.path.append(os.path.realpath('../../packages'))
17 sys.path.append(os.path.realpath('../mono-mac'))
19 from MonoReleaseProfile import MonoReleaseProfile
20 from bockbuild.util.util import *
23 class MonoXamarinPackageProfile(MonoReleaseProfile):
26 MonoReleaseProfile.__init__(self)
28 # add the private stuff
29 self.packages_to_build.extend(['mono-extensions'])
31 if self.cmd_options.release_build:
34 info("'--release' option not set, will not attempt to sign package!")
36 self.cache_host = 'http://storage.bos.xamarin.com/bockbuild_cache/'
38 def setup_codesign(self):
39 self.identity = "Developer ID Installer: Xamarin Inc"
41 output = backtick("security -v find-identity")
42 if self.identity not in " ".join(output):
43 error("Identity '%s' was not found. You can create an unsigned package by removing '--release' to your command line." % self.identity)
45 password = os.getenv("CODESIGN_KEYCHAIN_PASSWORD")
47 print "Unlocking the keychain"
48 run_shell("security unlock-keychain -p %s" % password)
50 error("CODESIGN_KEYCHAIN_PASSWORD needs to be defined.")
52 def setup_release(self):
53 MonoReleaseProfile.setup_release(self)
54 self.release_packages['mono'].configure_flags.extend(
55 ['--enable-extension-module=xamarin --enable-native-types --enable-pecrypt'])
56 info('Xamarin extensions enabled')
58 def run_pkgbuild(self, working_dir, package_type):
59 output = MonoReleaseProfile.run_pkgbuild(
60 self, working_dir, package_type)
62 output_unsigned = os.path.join(os.path.dirname(
63 output), os.path.basename(output).replace('.pkg', '.UNSIGNED.pkg'))
64 shutil.move(output, output_unsigned)
66 if not self.cmd_options.release_build:
67 return output_unsigned
69 productsign = "/usr/bin/productsign"
70 productsign_cmd = ' '.join([productsign,
71 "-s '%s'" % self.identity,
72 "'%s'" % output_unsigned,
74 run_shell(productsign_cmd)
75 os.remove(output_unsigned)
76 self.verify_codesign(output)
80 def verify_codesign(self, pkg):
83 name = os.path.basename(pkg)
84 pkgdir = os.path.dirname(pkg)
86 spctl = "/usr/sbin/spctl"
88 [spctl, "-vvv", "--assess", "--type install", name, "2>&1"])
89 output = backtick(spctl_cmd)
91 if "accepted" in " ".join(output):
92 warn("%s IS SIGNED" % pkg)
94 error("%s IS NOT SIGNED:" % pkg)
98 if __name__ == "__main__":
100 MonoXamarinPackageProfile().build()
101 except Exception as e:
102 exc_type, exc_value, exc_traceback = sys.exc_info()
103 error('%s (%s)' % (e, exc_type.__name__), more_output=True)
104 error(('%s:%s @%s\t\t"%s"' % p for p in traceback.extract_tb(
105 exc_traceback)[-3:]), more_output=True)
106 except KeyboardInterrupt:
107 error('Interrupted.')