Updating changelist
[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 * First Qt Release (BETA)
34 * Access to call cancel
35 * Divider on various lists (for time ones, tried to balance heavy/light phone users)
36 * Condensed history
37 * Changed SMS Entry letter count style from GV to Nokia
38 * Tabs are cached between launches
39 * Display when history/messages tabs where last refreshed
40 """.strip()
41
42
43 __postinstall__ = """#!/bin/sh -e
44
45 gtk-update-icon-cache -f /usr/share/icons/hicolor
46 rm -f ~/.%(name)s/%(name)s.log
47 rm -f ~/.%(name)s/notifier.log
48 """ % {"name": constants.__app_name__}
49
50 __preremove__ = """#!/bin/sh -e
51
52 python /opt/dialcentral/lib/alarm_handler.py -d || true
53 """
54
55
56 def find_files(prefix, path):
57         for root, dirs, files in os.walk(path):
58                 for file in files:
59                         if file.startswith(prefix+"-"):
60                                 fileParts = file.split("-")
61                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
62                                 assert unused == prefix
63                                 relPath = os.sep.join(relPathParts)
64                                 yield relPath, file, newName
65
66
67 def unflatten_files(files):
68         d = {}
69         for relPath, oldName, newName in files:
70                 if relPath not in d:
71                         d[relPath] = []
72                 d[relPath].append((oldName, newName))
73         return d
74
75
76 def build_package(distribution):
77         try:
78                 os.chdir(os.path.dirname(sys.argv[0]))
79         except:
80                 pass
81
82         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
83         p = py2deb.Py2deb(__appname__)
84         p.prettyName = constants.__pretty_app_name__
85         p.description = __description__
86         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
87         p.author = __author__
88         p.mail = __email__
89         p.license = "lgpl"
90         p.depends = ", ".join([
91                 "python2.6 | python2.5",
92                 "python-gtk2 | python2.5-gtk2",
93                 "python-xml | python2.5-xml",
94                 "python-dbus | python2.5-dbus",
95         ])
96         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
97         p.depends += {
98                 "debian": ", python-glade2",
99                 "diablo": maemoSpecificDepends + ", python2.5-conic",
100                 "fremantle": maemoSpecificDepends + ", python-glade2, python-alarm",
101         }[distribution]
102         p.recommends = ", ".join([
103         ])
104         p.section = {
105                 "debian": "comm",
106                 "diablo": "user/network",
107                 "fremantle": "user/network",
108         }[distribution]
109         p.arch = "all"
110         p.urgency = "low"
111         p.distribution = "diablo fremantle debian"
112         p.repository = "extras"
113         p.changelog = __changelog__
114         p.postinstall = __postinstall__
115         p.preremove = __preremove__
116         p.icon = {
117                 "debian": "26x26-dialcentral.png",
118                 "diablo": "26x26-dialcentral.png",
119                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
120         }[distribution]
121         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
122         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
123                 fullPath = "/opt/%s/lib" % __appname__
124                 if relPath:
125                         fullPath += os.sep+relPath
126                 p[fullPath] = list(
127                         "|".join((oldName, newName))
128                         for (oldName, newName) in files
129                 )
130         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
131         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
132         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
133         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
134
135         if distribution == "debian":
136                 print p
137                 print p.generate(
138                         version="%s-%s" % (__version__, __build__),
139                         changelog=__changelog__,
140                         build=True,
141                         tar=False,
142                         changes=False,
143                         dsc=False,
144                 )
145                 print "Building for %s finished" % distribution
146         else:
147                 print p
148                 print p.generate(
149                         version="%s-%s" % (__version__, __build__),
150                         changelog=__changelog__,
151                         build=False,
152                         tar=True,
153                         changes=True,
154                         dsc=True,
155                 )
156                 print "Building for %s finished" % distribution
157
158
159 if __name__ == "__main__":
160         if len(sys.argv) > 1:
161                 try:
162                         import optparse
163                 except ImportError:
164                         optparse = None
165
166                 if optparse is not None:
167                         parser = optparse.OptionParser()
168                         (commandOptions, commandArgs) = parser.parse_args()
169         else:
170                 commandArgs = None
171                 commandArgs = ["diablo"]
172         build_package(commandArgs[0])