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