4d5911cdb123af66a08d6694cb44e9214e6271aa
[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 account dialog buttons on Maemo 5
34 """.strip()
35
36
37 __postinstall__ = """#!/bin/sh -e
38
39 gtk-update-icon-cache -f /usr/share/icons/hicolor
40 """ % {"name": constants.__app_name__}
41
42 __preremove__ = """#!/bin/sh -e
43
44 python /opt/dialcentral/lib/alarm_handler.py -d || true
45 """
46
47
48 def find_files(prefix, path):
49         for root, dirs, files in os.walk(path):
50                 for file in files:
51                         if file.startswith(prefix+"-"):
52                                 fileParts = file.split("-")
53                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
54                                 assert unused == prefix
55                                 relPath = os.sep.join(relPathParts)
56                                 yield relPath, file, newName
57
58
59 def unflatten_files(files):
60         d = {}
61         for relPath, oldName, newName in files:
62                 if relPath not in d:
63                         d[relPath] = []
64                 d[relPath].append((oldName, newName))
65         return d
66
67
68 def build_package(distribution):
69         try:
70                 os.chdir(os.path.dirname(sys.argv[0]))
71         except:
72                 pass
73
74         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
75         p = py2deb.Py2deb(__appname__)
76         p.prettyName = constants.__pretty_app_name__
77         p.description = __description__
78         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
79         p.author = __author__
80         p.mail = __email__
81         p.license = "lgpl"
82         p.depends = ", ".join([
83                 "python2.6 | python2.5",
84                 "python-xml | python2.5-xml",
85                 "python-dbus | python2.5-dbus",
86                 "python-simplejson",
87         ])
88         p.depends += {
89                 "debian": ", python-qt4",
90                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
91                 "fremantle": ", python-pyside.qtgui, python-pyside.qtcore, python-pyside.qtmaemo5, python-qtmobility.contacts",
92         }[distribution]
93         p.recommends = ", ".join([
94         ])
95         p.section = {
96                 "debian": "comm",
97                 "diablo": "user/network",
98                 "fremantle": "user/network",
99         }[distribution]
100         p.arch = "all"
101         p.urgency = "low"
102         p.distribution = "diablo fremantle debian"
103         p.repository = "extras"
104         p.changelog = __changelog__
105         p.postinstall = __postinstall__
106         p.preremove = __preremove__
107         p.icon = {
108                 "debian": "26x26-dialcentral.png",
109                 "diablo": "26x26-dialcentral.png",
110                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
111         }[distribution]
112         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
113         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
114                 fullPath = "/opt/%s/lib" % __appname__
115                 if relPath:
116                         fullPath += os.sep+relPath
117                 p[fullPath] = list(
118                         "|".join((oldName, newName))
119                         for (oldName, newName) in files
120                 )
121         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
122                 fullPath = "/opt/%s/share" % __appname__
123                 if relPath:
124                         fullPath += os.sep+relPath
125                 p[fullPath] = list(
126                         "|".join((oldName, newName))
127                         for (oldName, newName) in files
128                 )
129         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
130         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
131         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
132         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
133
134         print p
135         if distribution == "debian":
136                 print p.generate(
137                         version="%s-%s" % (__version__, __build__),
138                         changelog=__changelog__,
139                         build=True,
140                         tar=False,
141                         changes=False,
142                         dsc=False,
143                 )
144         else:
145                 print p.generate(
146                         version="%s-%s" % (__version__, __build__),
147                         changelog=__changelog__,
148                         build=False,
149                         tar=True,
150                         changes=True,
151                         dsc=True,
152                 )
153         print "Building for %s finished" % distribution
154
155
156 if __name__ == "__main__":
157         if len(sys.argv) == 1:
158                 distribution = "fremantle"
159         else:
160                 distribution = sys.argv[1]
161         build_package(distribution)