-
Notifications
You must be signed in to change notification settings - Fork 15
/
make-package.py
executable file
·134 lines (105 loc) · 4.94 KB
/
make-package.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
#!/usr/bin/env python
import glob, logging, os, shutil, sys, tarfile
mainDir = os.getcwd()
VERSIONSTRING = ""
f = open("Makefile.local", "r")
while 1:
line = f.readline()
if not line:
break;
# VERSION=...
if line.startswith("VERSION"):
VERSIONSTRING = line.split('=')[1].strip()
break;
f.close()
if VERSIONSTRING == "":
print("couldn't get VERSIONSTRING")
sys.exit(1)
packageDir = os.path.join("package-release", "wolfcamql%s" % VERSIONSTRING)
if os.path.exists(packageDir):
shutil.rmtree(packageDir)
os.makedirs(packageDir)
packageFilesDir = "package-files"
files = os.listdir(packageFilesDir)
for f in files:
fpath = os.path.join(packageFilesDir, f)
print("copying package file: " + fpath)
if os.path.isdir(fpath):
shutil.copytree(fpath, os.path.join(packageDir, f))
else:
shutil.copy2(fpath, packageDir)
baseFiles = ["COPYING.txt", "COPYING-backtrace.txt", "CREDITS-wolfcam.txt", "CREDITS-openarena.txt", "README-ioquake3.txt", "README-wolfcam.txt", "opengl2-readme.md", "version.txt", "unifont-LICENSE.txt", "voip-readme.txt"]
for f in baseFiles:
print("copying base file: " + f)
shutil.copy(f, packageDir)
libDir = os.path.join("code", "libs", "win64")
buildDir = os.path.join("build", "release-mingw32-x86_64")
wolfcamDir = os.path.join(packageDir, "wolfcam-ql")
print("copying Windows binaries...")
try:
shutil.copy2(os.path.join(libDir, "SDL264.dll"), packageDir)
shutil.copy2(os.path.join(libDir, "backtrace64.dll"), packageDir)
shutil.copy2(os.path.join(buildDir, "ioquake3.x86_64.exe"), packageDir)
shutil.move(os.path.join(packageDir, "ioquake3.x86_64.exe"), os.path.join(packageDir, "wolfcamql.exe"))
shutil.copy2(os.path.join(buildDir, "renderer_opengl1_x86_64.dll"), packageDir)
shutil.copy2(os.path.join(buildDir, "renderer_opengl2_x86_64.dll"), packageDir)
shutil.copy2(os.path.join(buildDir, "baseq3", "cgamex86_64.dll"), wolfcamDir)
shutil.copy2(os.path.join(buildDir, "baseq3", "qagamex86_64.dll"), wolfcamDir)
shutil.copy2(os.path.join(buildDir, "baseq3", "uix86_64.dll"), wolfcamDir)
except IOError as err:
print(err)
buildDir = os.path.join("build", "release-linux-x86_64")
wolfcamDir = os.path.join(packageDir, "wolfcam-ql")
print("copying Linux binaries...")
try:
shutil.copy2(os.path.join(buildDir, "ioquake3.x86_64"), packageDir)
shutil.move(os.path.join(packageDir, "ioquake3.x86_64"), os.path.join(packageDir, "wolfcamql.x86_64"))
shutil.copy2(os.path.join(buildDir, "renderer_opengl1_x86_64.so"), packageDir)
shutil.copy2(os.path.join(buildDir, "renderer_opengl2_x86_64.so"), packageDir)
shutil.copy2(os.path.join(buildDir, "baseq3", "cgamex86_64.so"), wolfcamDir)
shutil.copy2(os.path.join(buildDir, "baseq3", "qagamex86_64.so"), wolfcamDir)
shutil.copy2(os.path.join(buildDir, "baseq3", "uix86_64.so"), wolfcamDir)
except IOError as err:
print(err)
libDir = os.path.join("code", "libs", "macosx")
buildDir = "mac-binaries"
wolfcamDir = os.path.join(packageDir, "wolfcam-ql")
print("copying Mac OS X binaries...")
try:
shutil.copy2(os.path.join(buildDir, "wolfcamqlmac"), packageDir)
shutil.copy2(os.path.join(buildDir, "renderer_opengl1_x86_64.dylib"), packageDir)
shutil.copy2(os.path.join(buildDir, "renderer_opengl2_x86_64.dylib"), packageDir)
shutil.copy2(os.path.join(buildDir, "cgamex86_64.dylib"), wolfcamDir)
shutil.copy2(os.path.join(buildDir, "qagamex86_64.dylib"), wolfcamDir)
shutil.copy2(os.path.join(buildDir, "uix86_64.dylib"), wolfcamDir)
# last so that it's not copied if the above ones don't exist
shutil.copy2(os.path.join(libDir, "libSDL2-2.0.0.dylib"), packageDir)
except IOError as err:
print(err)
print("copying misc files...")
shutil.copy2(os.path.join("ui", "wcmenudef.h"), os.path.join(packageDir, "wolfcam-ql", "ui"))
print("building source...")
ignoreFiles = [ ".hg", ".hgignore", "build", "package-files", "package-release", os.path.join("code", "libs"), "macwolfcambuild", "update-mac-binaries.sh", os.path.join("backtrace", "build"), "mac-binaries" ]
for f in glob.glob(os.path.join("backtrace", "binutils*gz")):
ignoreFiles.append(f)
tar = tarfile.open(os.path.join(packageDir, "wolfcamql-src.tar.bz2"), "w:bz2")
def tarFilter(tarinfo):
#print("tar file: " + tarinfo.name)
if tarinfo.name in ignoreFiles:
print("skipping " + tarinfo.name)
return None
if os.path.isdir(tarinfo.name):
print("adding dir: " + tarinfo.name)
return tarinfo
topFiles = os.listdir(".")
for f in topFiles:
tar.add(f, filter=tarFilter)
tar.close()
print("creating package zip...")
log = logging.getLogger("make-package")
osh = logging.StreamHandler(sys.stdout)
osh.setFormatter(logging.Formatter("zip: %(message)s"))
osh.setLevel(logging.INFO)
log.addHandler(osh)
log.setLevel(logging.INFO)
shutil.make_archive(os.path.join("package-release", "wolfcamql-%s" % VERSIONSTRING), "zip", "package-release", "wolfcamql%s" % VERSIONSTRING, logger=log )