| 1 |
import os, sys |
| 2 |
import zipfile |
| 3 |
import packagewindows |
| 4 |
|
| 5 |
def AddFile(zip, path, zipPath): |
| 6 |
print 'Adding ' + path |
| 7 |
zip.write(path, zipPath, zipfile.ZIP_DEFLATED) |
| 8 |
|
| 9 |
def AddDirectory(zip, root, zipPath): |
| 10 |
for path, dirs, files in os.walk(root): |
| 11 |
if '.svn' in dirs: |
| 12 |
dirs.remove('.svn') |
| 13 |
for name in files: |
| 14 |
thisZipPath = zipPath |
| 15 |
if os.path.abspath(root) != os.path.abspath(path): |
| 16 |
thisZipPath = os.path.join(thisZipPath, os.path.relpath(path, root)) |
| 17 |
AddFile(zip, os.path.join(path, name), os.path.join(thisZipPath, name)) |
| 18 |
|
| 19 |
def PackageZip(info): |
| 20 |
|
| 21 |
if not os.path.exists(info.packagePath): |
| 22 |
os.mkdir(info.packagePath) |
| 23 |
|
| 24 |
zipFileName = info.installerFileName + '.zip' |
| 25 |
zipFilePath = os.path.join(info.packagePath, zipFileName) |
| 26 |
if os.path.exists(zipFilePath): |
| 27 |
os.unlink(zipFilePath) |
| 28 |
|
| 29 |
print 'Generating ' + zipFilePath |
| 30 |
zip = zipfile.ZipFile(zipFilePath, 'w') |
| 31 |
AddFile(zip, os.path.join(info.installPath, 'openmsx-debugger.exe'), 'openmsx-debugger.exe') |
| 32 |
zip.close() |
| 33 |
|
| 34 |
zipFileName = info.installerFileName + '-pdb.zip' |
| 35 |
zipFilePath = os.path.join(info.packagePath, zipFileName) |
| 36 |
if os.path.exists(zipFilePath): |
| 37 |
os.unlink(zipFilePath) |
| 38 |
|
| 39 |
print 'Generating ' + zipFilePath |
| 40 |
zip = zipfile.ZipFile(zipFilePath, 'w') |
| 41 |
AddFile(zip, os.path.join(info.installPath, 'openmsx-debugger.pdb'), 'openmsx-debugger.pdb') |
| 42 |
zip.close() |
| 43 |
|
| 44 |
if __name__ == '__main__': |
| 45 |
if len(sys.argv) != 4: |
| 46 |
print >> sys.stderr, 'Usage: python packagezip.py platform configuration version' |
| 47 |
|
| 48 |
sys.exit(2) |
| 49 |
else: |
| 50 |
info = packagewindows.PackageInfo(sys.argv[1], sys.argv[2], sys.argv[3], '') |
| 51 |
PackageZip(info) |