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