1 import shutil
, os
, sys
, zipfile
3 #valid_platforms = ["win32", "linux86", "linux86_64", "src"]
6 print("wrong number of arguments")
7 print(sys
.argv
[0], "VERSION PLATFORM")
12 platform
= sys
.argv
[2]
29 #if not platform in valid_platforms:
30 # print("not a valid platform")
31 # print(valid_platforms)
34 if platform
== 'win32':
43 def copydir(src
, dst
, excl
=[]):
44 for root
, dirs
, files
in os
.walk(src
, topdown
=True):
45 if "/." in root
or "\\." in root
:
49 os
.mkdir(os
.path
.join(dst
, root
, name
))
52 shutil
.copy(os
.path
.join(root
, name
), os
.path
.join(dst
, root
, name
))
54 package
= "%s-%s-%s" %(name
, version
, platform
)
57 print("cleaning target")
58 shutil
.rmtree(package_dir
, True)
62 shutil
.copy("readme.txt", package_dir
)
63 shutil
.copy("license.txt", package_dir
)
64 shutil
.copy("storage.cfg", package_dir
)
66 if include_data
and not use_bundle
:
67 os
.mkdir(os
.path
.join(package_dir
, "data"))
68 copydir("data", package_dir
)
69 if platform
[:3] == "win":
70 shutil
.copy("other/config_directory.bat", package_dir
)
71 shutil
.copy("SDL.dll", package_dir
)
72 shutil
.copy("freetype.dll", package_dir
)
74 if include_exe
and not use_bundle
:
75 shutil
.copy(name
+exe_ext
, package_dir
)
76 shutil
.copy(name
+"_srv"+exe_ext
, package_dir
)
79 for p
in ["src", "scripts", "datasrc", "other", "objs"]:
80 os
.mkdir(os
.path
.join(package_dir
, p
))
81 copydir(p
, package_dir
)
82 shutil
.copy("bam.lua", package_dir
)
83 shutil
.copy("configure.lua", package_dir
)
86 os
.system("lipo -create -output "+name
+"_srv "+name
+"_srv"+"_ppc "+name
+"_srv"+"_x86")
87 os
.system("lipo -create -output "+name
+" "+name
+"_ppc "+name
+"_x86")
88 os
.system("lipo -create -output serverlaunch serverlaunch_ppc serverlaunch_x86")
90 # create Teeworlds appfolder
91 clientbundle_content_dir
= os
.path
.join(package_dir
, "Teeworlds.app/Contents")
92 clientbundle_bin_dir
= os
.path
.join(clientbundle_content_dir
, "MacOS")
93 clientbundle_resource_dir
= os
.path
.join(clientbundle_content_dir
, "Resources")
94 clientbundle_framework_dir
= os
.path
.join(clientbundle_content_dir
, "Frameworks")
95 os
.mkdir(os
.path
.join(package_dir
, "Teeworlds.app"))
96 os
.mkdir(clientbundle_content_dir
)
97 os
.mkdir(clientbundle_bin_dir
)
98 os
.mkdir(clientbundle_resource_dir
)
99 os
.mkdir(clientbundle_framework_dir
)
100 os
.mkdir(os
.path
.join(clientbundle_resource_dir
, "data"))
101 copydir("data", clientbundle_resource_dir
)
102 shutil
.copy("other/icons/Teeworlds.icns", clientbundle_resource_dir
)
103 shutil
.copy(name
+exe_ext
, clientbundle_bin_dir
)
104 os
.system("cp -R /Library/Frameworks/SDL.framework " + clientbundle_framework_dir
)
105 file(os
.path
.join(clientbundle_content_dir
, "Info.plist"), "w").write("""
106 <?xml version="1.0" encoding="UTF-8"?>
107 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
108 <plist version="1.0">
110 <key>CFBundleDevelopmentRegion</key>
111 <string>English</string>
112 <key>CFBundleExecutable</key>
113 <string>teeworlds</string>
114 <key>CFBundleIconFile</key>
115 <string>Teeworlds</string>
116 <key>CFBundleInfoDictionaryVersion</key>
118 <key>CFBundlePackageType</key>
119 <string>APPL</string>
120 <key>CFBundleSignature</key>
121 <string>????</string>
122 <key>CFBundleVersion</key>
127 file(os
.path
.join(clientbundle_content_dir
, "PkgInfo"), "w").write("APPL????")
129 # create Teeworlds Server appfolder
130 serverbundle_content_dir
= os
.path
.join(package_dir
, "Teeworlds Server.app/Contents")
131 serverbundle_bin_dir
= os
.path
.join(serverbundle_content_dir
, "MacOS")
132 serverbundle_resource_dir
= os
.path
.join(serverbundle_content_dir
, "Resources")
133 os
.mkdir(os
.path
.join(package_dir
, "Teeworlds Server.app"))
134 os
.mkdir(serverbundle_content_dir
)
135 os
.mkdir(serverbundle_bin_dir
)
136 os
.mkdir(serverbundle_resource_dir
)
137 os
.mkdir(os
.path
.join(serverbundle_resource_dir
, "data"))
138 os
.mkdir(os
.path
.join(serverbundle_resource_dir
, "data/maps"))
139 os
.mkdir(os
.path
.join(serverbundle_resource_dir
, "data/mapres"))
140 copydir("data/maps", serverbundle_resource_dir
)
141 shutil
.copy("other/icons/Teeworlds_srv.icns", serverbundle_resource_dir
)
142 shutil
.copy(name
+"_srv"+exe_ext
, serverbundle_bin_dir
)
143 shutil
.copy("serverlaunch"+exe_ext
, serverbundle_bin_dir
+ "/"+name
+"_server")
144 file(os
.path
.join(serverbundle_content_dir
, "Info.plist"), "w").write("""
145 <?xml version="1.0" encoding="UTF-8"?>
146 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
147 <plist version="1.0">
149 <key>CFBundleDevelopmentRegion</key>
150 <string>English</string>
151 <key>CFBundleExecutable</key>
152 <string>teeworlds_server</string>
153 <key>CFBundleIconFile</key>
154 <string>Teeworlds_srv</string>
155 <key>CFBundleInfoDictionaryVersion</key>
157 <key>CFBundlePackageType</key>
158 <string>APPL</string>
159 <key>CFBundleSignature</key>
160 <string>????</string>
161 <key>CFBundleVersion</key>
166 file(os
.path
.join(serverbundle_content_dir
, "PkgInfo"), "w").write("APPL????")
169 print("making zip archive")
170 zf
= zipfile
.ZipFile("%s.zip" % package
, 'w', zipfile
.ZIP_DEFLATED
)
172 for root
, dirs
, files
in os
.walk(package_dir
, topdown
=True):
174 n
= os
.path
.join(root
, name
)
180 print("making tar.gz archive")
181 os
.system("tar czf %s.tar.gz %s" % (package
, package_dir
))
184 print("making disk image")
185 os
.system("rm -f %s.dmg %s_temp.dmg" % (package
, package
))
186 os
.system("hdiutil create -srcfolder %s -volname Teeworlds -quiet %s_temp" % (package_dir
, package
))
187 os
.system("hdiutil convert %s_temp.dmg -format UDBZ -o %s.dmg -quiet" % (package
, package
))
188 os
.system("rm -f %s_temp.dmg" % package
)