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