-
Notifications
You must be signed in to change notification settings - Fork 2
/
UnityStandaloneMac.py
139 lines (94 loc) · 3.65 KB
/
UnityStandaloneMac.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/pyhton
#created by: [email protected]
import os
import subprocess
import plistlib as PlistParser
appPath = "/Users/user/Desktop/MyApp.app"
entitlements = "/Users/user/Desktop/entitlements.plist"
signingProfileName = "3rd Party Mac Developer Application: Company, INC."
signingInstallerProfileName = ""
#outPut package name. or path to save default is current directory
AppPackageName = "myApp.pkg"
#Info.plist values
bundleStringinfoValue = "Kids Learning Program 1.1.0. (c) 2014 MyCompany Inc. All rights reserved."
bundleVersionStringValue = "1.1.0"
bundleVersionNumberValue = "1.1.0"
bundleIdentifierValue = "com.company.MyApp"
bundleNameValue = "MyApp"
ApplicationCategoryValue = "public.app-category.arcade-games"
ReadableCopyRightValue = "MyCompany v1.0.0 (c) MyCompany, Inc."
def removeMetaFilesFromDirectiory(dirPath):
fileslist = []
for root, dirs, files in os.walk(dirPath):
for file in files:
if file.endswith('.meta'):
metaFilePath = root + '/' + file
fileslist.append(metaFilePath)
for filePath in fileslist:
print 'deleting file: ', filePath
os.remove(filePath)
def signPlugins():
pluginsPath = appPath + '/Contents/Plugins'
if os.path.exists(pluginsPath):
for plugin in os.listdir(pluginsPath):
p = pluginsPath + '/' + plugin
removeMetaFilesFromDirectiory(p)
executeCodeSign(p)
def UpdateInfoPlist():
plistPath = appPath + "/Contents/Info.plist"
allData = PlistParser.readPlist(plistPath)
allData["CFBundleGetInfoString"] = bundleStringinfoValue
allData["CFBundleShortVersionString"] = bundleVersionStringValue
allData["CFBundleVersion"] = bundleVersionNumberValue
allData["CFBundleIdentifier"] = bundleIdentifierValue
allData["CFBundleName"] = bundleNameValue
allData["LSApplicationCategoryType"] = ApplicationCategoryValue
allData["NSHumanReadableCopyright"] = ReadableCopyRightValue
PlistParser.writePlist(allData, plistPath)
def executeCodeSign(pathToTargetSign):
codesignPlugin = subprocess.call(["codesign", "--deep", "-f", "-v", "-s", signingProfileName, "--entitlements", entitlements, pathToTargetSign])
if codesignPlugin == 0:
print '\nSigning Completed of ', pathToTargetSign
return True
else:
print subprocess.CalledProcessError
return False
def AppSigning():
print "\n\n**********Signing App for Mac AppStore with \"", signingProfileName, "\" ************"
codesignOutput = subprocess.call(["codesign", "--deep", "-f", "-v", "-s", signingProfileName, "--entitlements", entitlements, appPath])
if codesignOutput == 0:
print '\n\nSigning Completed'
return True
else:
print subprocess.CalledProcessError
return False
def PackageCreation():
if len(signingInstallerProfileName) == 0:
print '\n\nCreating Package without installer signing.'
installerOutPut = subprocess.call(["productbuild", "--component", appPath, "/Applications", AppPackageName])
if installerOutPut == 0:
print '\n\nPackage Created'
else:
print subprocess.CalledProcessError
else:
print '\n\nCreating Package with ',signingInstallerProfileName, ' installer signing.'
installerOutPut = subprocess.call(["productbuild", "--component", appPath, "/Applications", "--sign", signingInstallerProfileName, AppPackageName])
if installerOutPut == 0:
print '\n\nPackage Created'
else:
print subprocess.CalledProcessError
def main():
if os.path.exists(appPath) == False:
print 'File Does Not Exist: ', appPath
return
if os.path.exists(entitlements) == False:
print 'File Does Not Exist: ', entitlements
return
UpdateInfoPlist()
signPlugins()
isSigned = AppSigning()
if isSigned:
PackageCreation()
print '\n\n**********End************'
if __name__ == "__main__":
main()