Bumping Qt branch to 1.1.98
[gc-dialer] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 import os
4 import sys
5
6 try:
7         import py2deb
8 except ImportError:
9         import fake_py2deb as py2deb
10
11 import constants
12
13
14 __appname__ = constants.__app_name__
15 __description__ = """Touch screen enhanced interface to the GoogleVoice phone service"
16 Features:
17 .
18 * Dialpad for quick call
19 .
20 * Checking voicemails, texts, call history
21 .
22 * Sending texts
23 .
24 * Notification support for texts, voicemail, and/or missed calls
25 .
26 Homepage: http://gc-dialer.garage.maemo.org/
27 """
28 __author__ = "Ed Page"
29 __email__ = "eopage@byu.net"
30 __version__ = constants.__version__
31 __build__ = constants.__build__
32 __changelog__ = """
33 * Fixing a bug where a failed login would cause problems
34 * Fixing a bug preventing failed logins to be reported to the user
35 * Adding some more detail to the log
36 """.strip()
37
38
39 __postinstall__ = """#!/bin/sh -e
40
41 gtk-update-icon-cache -f /usr/share/icons/hicolor
42 rm -f ~/.%(name)s/%(name)s.log
43 rm -f ~/.%(name)s/notifier.log
44 """ % {"name": constants.__app_name__}
45
46 __preremove__ = """#!/bin/sh -e
47
48 python /opt/dialcentral/lib/alarm_handler.py -d || true
49 """
50
51
52 def find_files(prefix, path):
53         for root, dirs, files in os.walk(path):
54                 for file in files:
55                         if file.startswith(prefix+"-"):
56                                 fileParts = file.split("-")
57                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
58                                 assert unused == prefix
59                                 relPath = os.sep.join(relPathParts)
60                                 yield relPath, file, newName
61
62
63 def unflatten_files(files):
64         d = {}
65         for relPath, oldName, newName in files:
66                 if relPath not in d:
67                         d[relPath] = []
68                 d[relPath].append((oldName, newName))
69         return d
70
71
72 def build_package(distribution):
73         try:
74                 os.chdir(os.path.dirname(sys.argv[0]))
75         except:
76                 pass
77
78         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
79         p = py2deb.Py2deb(__appname__)
80         p.prettyName = constants.__pretty_app_name__
81         p.description = __description__
82         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
83         p.author = __author__
84         p.mail = __email__
85         p.license = "lgpl"
86         p.depends = ", ".join([
87                 "python2.6 | python2.5",
88                 "python-gtk2 | python2.5-gtk2",
89                 "python-xml | python2.5-xml",
90                 "python-dbus | python2.5-dbus",
91         ])
92         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
93         p.depends += {
94                 "debian": ", python-glade2",
95                 "diablo": maemoSpecificDepends + ", python2.5-conic",
96                 "fremantle": maemoSpecificDepends + ", python-glade2, python-alarm",
97         }[distribution]
98         p.recommends = ", ".join([
99         ])
100         p.section = {
101                 "debian": "comm",
102                 "diablo": "user/network",
103                 "fremantle": "user/network",
104         }[distribution]
105         p.arch = "all"
106         p.urgency = "low"
107         p.distribution = "diablo fremantle debian"
108         p.repository = "extras"
109         p.changelog = __changelog__
110         p.postinstall = __postinstall__
111         p.preremove = __preremove__
112         p.icon = {
113                 "debian": "26x26-dialcentral.png",
114                 "diablo": "26x26-dialcentral.png",
115                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
116         }[distribution]
117         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
118         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
119                 fullPath = "/opt/%s/lib" % __appname__
120                 if relPath:
121                         fullPath += os.sep+relPath
122                 p[fullPath] = list(
123                         "|".join((oldName, newName))
124                         for (oldName, newName) in files
125                 )
126         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
127         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
128         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
129         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
130
131         if distribution == "debian":
132                 print p
133                 print p.generate(
134                         version="%s-%s" % (__version__, __build__),
135                         changelog=__changelog__,
136                         build=True,
137                         tar=False,
138                         changes=False,
139                         dsc=False,
140                 )
141                 print "Building for %s finished" % distribution
142         else:
143                 print p
144                 print p.generate(
145                         version="%s-%s" % (__version__, __build__),
146                         changelog=__changelog__,
147                         build=False,
148                         tar=True,
149                         changes=True,
150                         dsc=True,
151                 )
152                 print "Building for %s finished" % distribution
153
154
155 if __name__ == "__main__":
156         if len(sys.argv) > 1:
157                 try:
158                         import optparse
159                 except ImportError:
160                         optparse = None
161
162                 if optparse is not None:
163                         parser = optparse.OptionParser()
164                         (commandOptions, commandArgs) = parser.parse_args()
165         else:
166                 commandArgs = None
167                 commandArgs = ["diablo"]
168         build_package(commandArgs[0])