removing debug output
[quassel.git] / scripts / build / macosx_makebundle.py
1 #!/usr/bin/python
2 # -*- coding: iso-8859-1 -*-
3
4 ################################################################################
5 #                                                                              #
6 # 2008 June 27th by Marcus 'EgS' Eggenberger <egs@quassel-irc.org>             #
7 #                                                                              #
8 # The author disclaims copyright to this source code.                          #
9 # This Python Script is in the PUBLIC DOMAIN.                                  #
10 #                                                                              #
11 ################################################################################
12
13 # ==============================
14 #  Imports
15 # ==============================
16 import os
17 import os.path
18 import sys
19
20 # ==============================
21 #  Constants
22 # ==============================
23 if len(sys.argv) < 2:
24     sys.exit(1)
25
26 SOURCE_DIR = sys.argv[1]
27
28 if len(sys.argv) < 4:
29     BUNDLE_NAME= "Quassel Client"
30     EXE_NAME = "quasselclient"
31 else:
32     EXE_NAME = sys.argv[3]
33     BUNDLE_NAME = sys.argv[2]
34
35 # make the dir of the exe the target dir
36 if(os.path.dirname(EXE_NAME)):
37     CONTENTS_DIR = os.path.dirname(EXE_NAME) + "/"
38 CONTENTS_DIR += BUNDLE_NAME + ".app/Contents/"
39
40 BUNDLE_VERSION = "0.3.0"
41 ICON_FILE = "pics/quassel.icns"
42
43 def createBundle():
44     try:
45         os.makedirs(CONTENTS_DIR + "MacOS")
46         os.makedirs(CONTENTS_DIR + "Resources")
47     except:
48         pass
49
50 def copyFiles(exeFile, iconFile):
51     os.system("cp %s %sMacOs/%s" % (exeFile, CONTENTS_DIR.replace(' ', '\ '), BUNDLE_NAME.replace(' ', '\ ')))
52     os.system("cp %s/%s %s/Resources" % (SOURCE_DIR, iconFile, CONTENTS_DIR.replace(' ', '\ ')))
53
54 def createPlist(bundleName, iconFile, bundleVersion):
55     templateFile = file(SOURCE_DIR + "/scripts/build/Info.plist", 'r')
56     template = templateFile.read()
57     templateFile.close()
58
59     plistFile = file(CONTENTS_DIR + "Info.plist", 'w')
60     plistFile.write(template % {"BUNDLE_NAME" : bundleName,
61                                 "ICON_FILE" : iconFile[iconFile.rfind("/")+1:],
62                                 "BUNDLE_VERSION" : bundleVersion})
63     plistFile.close()
64
65 if __name__ == "__main__":
66     createBundle()
67     createPlist(BUNDLE_NAME, ICON_FILE, BUNDLE_VERSION)
68     copyFiles(EXE_NAME, ICON_FILE)
69     pass