2007-08-04 22:51:41 +00:00
|
|
|
import shutil, os, sys, zipfile
|
|
|
|
|
2007-12-12 19:52:57 +00:00
|
|
|
#valid_platforms = ["win32", "linux86", "linux86_64", "src"]
|
2007-08-04 22:51:41 +00:00
|
|
|
|
|
|
|
if len(sys.argv) != 3:
|
|
|
|
print "wrong number of arguments"
|
|
|
|
print sys.argv[0], "VERSION PLATFORM"
|
|
|
|
sys.exit(-1)
|
|
|
|
|
2008-03-22 18:40:27 +00:00
|
|
|
name = "teeworlds"
|
2007-08-04 22:51:41 +00:00
|
|
|
version = sys.argv[1]
|
|
|
|
platform = sys.argv[2]
|
|
|
|
exe_ext = ""
|
|
|
|
use_zip = 0
|
2007-12-09 13:36:54 +00:00
|
|
|
use_gz = 1
|
2009-01-11 12:10:30 +00:00
|
|
|
use_dmg = 0
|
2007-12-15 11:44:27 +00:00
|
|
|
use_bundle = 0
|
2007-12-09 13:36:54 +00:00
|
|
|
include_data = True
|
|
|
|
include_exe = True
|
|
|
|
include_src = False
|
|
|
|
|
|
|
|
if platform == "src":
|
2007-12-12 19:52:57 +00:00
|
|
|
include_data = True
|
2007-12-09 13:36:54 +00:00
|
|
|
include_exe = False
|
|
|
|
include_src = True
|
|
|
|
use_zip = 1
|
|
|
|
use_gz = 1
|
2007-08-04 22:51:41 +00:00
|
|
|
|
2007-12-12 19:52:57 +00:00
|
|
|
#if not platform in valid_platforms:
|
|
|
|
# print "not a valid platform"
|
|
|
|
# print valid_platforms
|
|
|
|
# sys.exit(-1)
|
2007-08-04 22:51:41 +00:00
|
|
|
|
|
|
|
if platform == 'win32':
|
|
|
|
exe_ext = ".exe"
|
|
|
|
use_zip = 1
|
2007-12-09 13:36:54 +00:00
|
|
|
use_gz = 0
|
2009-01-11 12:10:30 +00:00
|
|
|
if platform == 'osx':
|
|
|
|
use_dmg = 1
|
2007-12-15 11:44:27 +00:00
|
|
|
use_gz = 0
|
2008-10-08 16:33:08 +00:00
|
|
|
use_bundle = 1
|
2007-08-04 22:51:41 +00:00
|
|
|
|
2007-12-09 13:36:54 +00:00
|
|
|
def copydir(src, dst, excl=[]):
|
2007-08-04 22:51:41 +00:00
|
|
|
for root, dirs, files in os.walk(src, topdown=True):
|
2007-08-04 23:06:58 +00:00
|
|
|
if "/." in root or "\\." in root:
|
2007-08-04 22:51:41 +00:00
|
|
|
continue
|
|
|
|
for name in dirs:
|
|
|
|
if name[0] != '.':
|
|
|
|
os.mkdir(os.path.join(dst, root, name))
|
|
|
|
for name in files:
|
|
|
|
if name[0] != '.':
|
|
|
|
shutil.copy(os.path.join(root, name), os.path.join(dst, root, name))
|
|
|
|
|
|
|
|
package = "%s-%s-%s" %(name, version, platform)
|
|
|
|
package_dir = package
|
|
|
|
|
2007-12-09 13:36:54 +00:00
|
|
|
print "cleaning target"
|
2007-08-04 22:51:41 +00:00
|
|
|
shutil.rmtree(package_dir, True)
|
|
|
|
os.mkdir(package_dir)
|
2007-12-09 13:36:54 +00:00
|
|
|
|
|
|
|
print "adding files"
|
2007-08-04 22:51:41 +00:00
|
|
|
shutil.copy("readme.txt", package_dir)
|
2007-12-09 13:36:54 +00:00
|
|
|
shutil.copy("license.txt", package_dir)
|
2007-08-04 22:51:41 +00:00
|
|
|
|
2007-12-15 11:44:27 +00:00
|
|
|
if include_data and not use_bundle:
|
2007-12-09 13:36:54 +00:00
|
|
|
os.mkdir(os.path.join(package_dir, "data"))
|
|
|
|
copydir("data", package_dir)
|
2007-12-13 18:46:43 +00:00
|
|
|
if platform[:3] == "win":
|
|
|
|
shutil.copy("other/config_directory.bat", package_dir)
|
2007-12-09 13:36:54 +00:00
|
|
|
|
2007-12-15 11:44:27 +00:00
|
|
|
if include_exe and not use_bundle:
|
2008-03-22 18:40:27 +00:00
|
|
|
shutil.copy(name+exe_ext, package_dir)
|
|
|
|
shutil.copy(name+"_srv"+exe_ext, package_dir)
|
2007-12-09 13:36:54 +00:00
|
|
|
|
|
|
|
if include_src:
|
2007-12-15 14:40:39 +00:00
|
|
|
for p in ["src", "scripts", "datasrc", "other", "objs"]:
|
2007-12-09 13:36:54 +00:00
|
|
|
os.mkdir(os.path.join(package_dir, p))
|
|
|
|
copydir(p, package_dir)
|
|
|
|
shutil.copy("default.bam", package_dir)
|
2007-08-04 22:51:41 +00:00
|
|
|
|
2007-12-15 11:44:27 +00:00
|
|
|
if use_bundle:
|
2009-01-11 12:10:30 +00:00
|
|
|
os.system("lipo -create -output teeworlds_srv teeworlds_srv_ppc teeworlds_srv_x86")
|
|
|
|
os.system("lipo -create -output teeworlds teeworlds_ppc teeworlds_x86")
|
2008-03-22 18:40:27 +00:00
|
|
|
bundle_content_dir = os.path.join(package_dir, "Teeworlds.app/Contents")
|
2007-12-15 13:01:09 +00:00
|
|
|
bundle_bin_dir = os.path.join(bundle_content_dir, "MacOS")
|
2007-12-15 11:44:27 +00:00
|
|
|
bundle_resource_dir = os.path.join(bundle_content_dir, "Resources")
|
2008-10-21 15:59:32 +00:00
|
|
|
bundle_framework_dir = os.path.join(bundle_content_dir, "Frameworks")
|
2008-03-22 18:40:27 +00:00
|
|
|
os.mkdir(os.path.join(package_dir, "Teeworlds.app"))
|
2007-12-15 11:44:27 +00:00
|
|
|
os.mkdir(bundle_content_dir)
|
|
|
|
os.mkdir(bundle_bin_dir)
|
|
|
|
os.mkdir(bundle_resource_dir)
|
2008-10-21 15:59:32 +00:00
|
|
|
os.mkdir(bundle_framework_dir)
|
2007-12-15 11:44:27 +00:00
|
|
|
os.mkdir(os.path.join(bundle_resource_dir, "data"))
|
|
|
|
copydir("data", bundle_resource_dir)
|
2008-03-22 18:40:27 +00:00
|
|
|
shutil.copy("other/icons/Teeworlds.icns", bundle_resource_dir)
|
|
|
|
shutil.copy(name+exe_ext, bundle_bin_dir)
|
|
|
|
shutil.copy(name+"_srv"+exe_ext, bundle_bin_dir)
|
2008-10-21 16:16:16 +00:00
|
|
|
os.system("cp -R /Library/Frameworks/SDL.framework " + bundle_framework_dir)
|
2007-12-15 13:01:09 +00:00
|
|
|
file(os.path.join(bundle_content_dir, "Info.plist"), "w").write("""
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>CFBundleDevelopmentRegion</key>
|
|
|
|
<string>English</string>
|
|
|
|
<key>CFBundleExecutable</key>
|
2008-10-21 15:59:32 +00:00
|
|
|
<string>teeworlds</string>
|
2007-12-15 13:01:09 +00:00
|
|
|
<key>CFBundleIconFile</key>
|
2008-03-22 18:40:27 +00:00
|
|
|
<string>Teeworlds</string>
|
2007-12-15 13:01:09 +00:00
|
|
|
<key>CFBundleInfoDictionaryVersion</key>
|
|
|
|
<string>6.0</string>
|
|
|
|
<key>CFBundlePackageType</key>
|
|
|
|
<string>APPL</string>
|
|
|
|
<key>CFBundleSignature</key>
|
|
|
|
<string>????</string>
|
|
|
|
<key>CFBundleVersion</key>
|
|
|
|
<string>%s</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
""" % (version))
|
|
|
|
file(os.path.join(bundle_content_dir, "PkgInfo"), "w").write("APPL????")
|
2007-12-15 11:44:27 +00:00
|
|
|
|
2007-08-04 22:51:41 +00:00
|
|
|
if use_zip:
|
2007-12-09 13:36:54 +00:00
|
|
|
print "making zip archive"
|
2007-08-04 22:51:41 +00:00
|
|
|
zf = zipfile.ZipFile("%s.zip" % package, 'w', zipfile.ZIP_DEFLATED)
|
|
|
|
|
|
|
|
for root, dirs, files in os.walk(package_dir, topdown=True):
|
|
|
|
for name in files:
|
|
|
|
n = os.path.join(root, name)
|
|
|
|
zf.write(n, n)
|
2007-12-09 13:36:54 +00:00
|
|
|
#zf.printdir()
|
2007-08-04 22:51:41 +00:00
|
|
|
zf.close()
|
2007-12-09 13:36:54 +00:00
|
|
|
|
|
|
|
if use_gz:
|
|
|
|
print "making tar.gz archive"
|
|
|
|
os.system("tar czf %s.tar.gz %s" % (package, package_dir))
|
2009-01-11 12:10:30 +00:00
|
|
|
|
|
|
|
if use_dmg:
|
|
|
|
print "making disk image"
|
|
|
|
os.system("rm -f %s.dmg %s_temp.dmg" % (package, package))
|
|
|
|
os.system("hdiutil create -srcfolder %s -volname Teeworlds -quiet %s_temp" % (package_dir, package))
|
|
|
|
os.system("hdiutil convert %s_temp.dmg -format UDBZ -o %s.dmg -quiet" % (package, package))
|
|
|
|
os.system("rm -f %s_temp.dmg" % package)
|
2007-12-09 13:36:54 +00:00
|
|
|
|
|
|
|
print "done"
|