ddnet/scripts/make_release.py

227 lines
7.7 KiB
Python
Raw Normal View History

2013-12-30 18:49:19 +00:00
import shutil, os, sys, zipfile
2007-08-04 22:51:41 +00:00
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:
2011-04-02 02:49:14 +00:00
print("wrong number of arguments")
print(sys.argv[0], "VERSION PLATFORM")
2007-08-04 22:51:41 +00:00
sys.exit(-1)
2014-03-28 23:24:34 +00:00
name = "DDNet"
2007-08-04 22:51:41 +00:00
version = sys.argv[1]
platform = sys.argv[2]
exe_ext = ""
use_zip = 0
use_gz = 1
use_dmg = 0
2007-12-15 11:44:27 +00:00
use_bundle = 0
include_data = True
include_exe = True
include_src = False
if platform == "src":
2007-12-12 19:52:57 +00:00
include_data = True
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:
2011-04-02 02:49:14 +00:00
# print("not a valid platform")
# print(valid_platforms)
2007-12-12 19:52:57 +00:00
# sys.exit(-1)
2007-08-04 22:51:41 +00:00
2013-05-01 22:38:32 +00:00
if platform == 'win32' or platform == 'win64':
2007-08-04 22:51:41 +00:00
exe_ext = ".exe"
use_zip = 1
use_gz = 0
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
def copydir(src, dst, excl=[]):
2007-08-04 22:51:41 +00:00
for root, dirs, files in os.walk(src, topdown=True):
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))
2013-12-30 18:49:19 +00:00
2007-08-04 22:51:41 +00:00
package = "%s-%s-%s" %(name, version, platform)
package_dir = package
2011-04-02 02:49:14 +00:00
print("cleaning target")
2007-08-04 22:51:41 +00:00
shutil.rmtree(package_dir, True)
os.mkdir(package_dir)
2011-04-02 02:49:14 +00:00
print("adding files")
2014-03-29 17:28:49 +00:00
#shutil.copy("readme.txt", package_dir)
shutil.copy("license.txt", package_dir)
2010-10-06 21:07:35 +00:00
shutil.copy("storage.cfg", package_dir)
2014-04-27 22:13:15 +00:00
shutil.copy("autoexec.cfg", package_dir)
# DDRace
2010-12-05 17:25:04 +00:00
shutil.copy("announcement.txt", package_dir)
shutil.copy("license_DDRace.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:
os.mkdir(os.path.join(package_dir, "data"))
copydir("data", package_dir)
if platform[:3] == "win":
shutil.copy("other/config_directory.bat", package_dir)
2009-01-11 12:59:54 +00:00
shutil.copy("SDL.dll", package_dir)
shutil.copy("freetype.dll", package_dir)
2015-07-01 12:29:00 +00:00
if platform == "win32":
shutil.copy("libgcc_s_sjlj-1.dll", package_dir)
2015-07-01 12:40:37 +00:00
shutil.copy("libidn-11.dll", package_dir)
2015-07-01 12:29:00 +00:00
elif platform == "win64":
2015-07-01 12:59:44 +00:00
shutil.copy("libwinpthread-1.dll", package_dir)
2015-07-01 12:29:00 +00:00
shutil.copy("libgcc_s_seh-1.dll", package_dir)
2014-10-28 15:19:49 +00:00
shutil.copy("libogg-0.dll", package_dir)
shutil.copy("libopus-0.dll", package_dir)
shutil.copy("libopusfile-0.dll", package_dir)
2014-03-28 23:24:34 +00:00
#shutil.copy("libmysql.dll", package_dir)
#shutil.copy("mysqlcppconn.dll", package_dir)
shutil.copy("libcurl.dll", package_dir)
2015-02-05 22:56:03 +00:00
shutil.copy("libeay32.dll", package_dir)
shutil.copy("ssleay32.dll", package_dir)
2015-02-06 04:14:49 +00:00
shutil.copy("zlib1.dll", package_dir)
2007-12-15 11:44:27 +00:00
if include_exe and not use_bundle:
shutil.copy(name+exe_ext, package_dir)
shutil.copy(name+"-Server"+exe_ext, package_dir)
2014-05-08 23:17:46 +00:00
shutil.copy("dilate"+exe_ext, package_dir)
2014-03-28 23:24:34 +00:00
#shutil.copy(name+"-Server_sql"+exe_ext, package_dir)
if include_src:
2007-12-15 14:40:39 +00:00
for p in ["src", "scripts", "datasrc", "other", "objs"]:
os.mkdir(os.path.join(package_dir, p))
copydir(p, package_dir)
shutil.copy("bam.lua", package_dir)
shutil.copy("configure.lua", package_dir)
2007-08-04 22:51:41 +00:00
2007-12-15 11:44:27 +00:00
if use_bundle:
2014-05-08 23:17:46 +00:00
bins = [name, name+'-Server', 'dilate', 'serverlaunch']
platforms = ('x86', 'x86_64', 'ppc')
for bin in bins:
to_lipo = []
for p in platforms:
fname = bin+'_'+p
if os.path.isfile(fname):
to_lipo.append(fname)
if to_lipo:
os.system("lipo -create -output "+bin+" "+" ".join(to_lipo))
2009-01-12 20:04:14 +00:00
# create Teeworlds appfolder
2014-03-28 23:24:34 +00:00
clientbundle_content_dir = os.path.join(package_dir, "DDNet.app/Contents")
2009-01-12 20:04:14 +00:00
clientbundle_bin_dir = os.path.join(clientbundle_content_dir, "MacOS")
clientbundle_resource_dir = os.path.join(clientbundle_content_dir, "Resources")
clientbundle_framework_dir = os.path.join(clientbundle_content_dir, "Frameworks")
2014-03-28 23:08:35 +00:00
binary_path = clientbundle_bin_dir + "/" + name+exe_ext
2014-03-28 23:24:34 +00:00
os.mkdir(os.path.join(package_dir, "DDNet.app"))
2009-01-12 20:04:14 +00:00
os.mkdir(clientbundle_content_dir)
os.mkdir(clientbundle_bin_dir)
os.mkdir(clientbundle_resource_dir)
os.mkdir(clientbundle_framework_dir)
os.mkdir(os.path.join(clientbundle_resource_dir, "data"))
copydir("data", clientbundle_resource_dir)
2013-12-30 18:49:19 +00:00
2013-12-31 12:34:15 +00:00
shutil.copy("other/icons/DDNet.icns", clientbundle_resource_dir)
#shutil.copy("other/icons/Teeworlds.icns", clientbundle_resource_dir)
2009-01-12 20:04:14 +00:00
shutil.copy(name+exe_ext, clientbundle_bin_dir)
2014-03-28 23:08:35 +00:00
os.system("install_name_tool -change /opt/X11/lib/libfreetype.6.dylib @executable_path/../Frameworks/libfreetype.6.dylib " + binary_path)
os.system("install_name_tool -change /Library/Frameworks/SDL.framework/SDL @executable_path/../Frameworks/SDL.framework/SDL " + binary_path)
2009-01-12 20:04:14 +00:00
os.system("cp -R /Library/Frameworks/SDL.framework " + clientbundle_framework_dir)
os.system("cp /opt/X11/lib/libfreetype.6.dylib " + clientbundle_framework_dir)
2009-01-12 20:04:14 +00:00
file(os.path.join(clientbundle_content_dir, "Info.plist"), "w").write("""
2007-12-15 13:01:09 +00:00
<?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>
2014-03-28 23:24:34 +00:00
<string>DDNet</string>
2007-12-15 13:01:09 +00:00
<key>CFBundleIconFile</key>
2013-12-31 12:34:15 +00:00
<string>DDNet</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))
2009-01-12 20:04:14 +00:00
file(os.path.join(clientbundle_content_dir, "PkgInfo"), "w").write("APPL????")
# create Teeworlds Server appfolder
2014-03-28 23:24:34 +00:00
serverbundle_content_dir = os.path.join(package_dir, "DDNet-Server.app/Contents")
2009-01-12 20:04:14 +00:00
serverbundle_bin_dir = os.path.join(serverbundle_content_dir, "MacOS")
serverbundle_resource_dir = os.path.join(serverbundle_content_dir, "Resources")
2014-03-28 23:24:34 +00:00
os.mkdir(os.path.join(package_dir, "DDNet-Server.app"))
2009-01-12 20:04:14 +00:00
os.mkdir(serverbundle_content_dir)
os.mkdir(serverbundle_bin_dir)
os.mkdir(serverbundle_resource_dir)
os.mkdir(os.path.join(serverbundle_resource_dir, "data"))
os.mkdir(os.path.join(serverbundle_resource_dir, "data/maps"))
2010-10-06 21:07:35 +00:00
os.mkdir(os.path.join(serverbundle_resource_dir, "data/mapres"))
2009-01-12 20:04:14 +00:00
copydir("data/maps", serverbundle_resource_dir)
2014-03-28 23:24:34 +00:00
shutil.copy("other/icons/DDNet-Server.icns", serverbundle_resource_dir)
shutil.copy(name+"-Server"+exe_ext, serverbundle_bin_dir)
shutil.copy("serverlaunch"+exe_ext, serverbundle_bin_dir + "/"+name+"_server")
2009-01-12 20:04:14 +00:00
file(os.path.join(serverbundle_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>
2014-03-28 23:24:34 +00:00
<string>DDNet_server</string>
2009-01-12 20:04:14 +00:00
<key>CFBundleIconFile</key>
2014-03-28 23:24:34 +00:00
<string>DDNet-Server</string>
2009-01-12 20:04:14 +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(serverbundle_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:
2011-04-02 02:49:14 +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)
#zf.printdir()
2007-08-04 22:51:41 +00:00
zf.close()
if use_gz:
2011-04-02 02:49:14 +00:00
print("making tar.gz archive")
os.system("tar czf %s.tar.gz %s" % (package, package_dir))
if use_dmg:
2011-04-02 02:49:14 +00:00
print("making disk image")
os.system("rm -f %s.dmg %s_temp.dmg" % (package, package))
2014-03-28 23:24:34 +00:00
os.system("hdiutil create -srcfolder %s -volname DDNet -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)
2011-04-02 02:49:14 +00:00
print("done")