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