Bump to 1.2.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 * Contacts: Providing default focus to contact list for faster searching
34 * Contacts: Expanded support for CSV schemas for contacts
35 * SMS: Reduced log noise / wasted cycles when switching SMS window between single and broadcast mode
36 * SMS: Only clearing SMS window on success so it doesn't get lost
37 * SMS: Was not enabling buttons at all the right times in SMS Window, fixed it
38 """.strip()
39
40
41 __postinstall__ = """#!/bin/sh -e
42
43 gtk-update-icon-cache -f /usr/share/icons/hicolor
44 rm -f ~/.%(name)s/%(name)s.log
45 rm -f ~/.%(name)s/notifier.log
46 """ % {"name": constants.__app_name__}
47
48 __preremove__ = """#!/bin/sh -e
49
50 python /opt/dialcentral/lib/alarm_handler.py -d || true
51 """
52
53
54 def find_files(prefix, path):
55         for root, dirs, files in os.walk(path):
56                 for file in files:
57                         if file.startswith(prefix+"-"):
58                                 fileParts = file.split("-")
59                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
60                                 assert unused == prefix
61                                 relPath = os.sep.join(relPathParts)
62                                 yield relPath, file, newName
63
64
65 def unflatten_files(files):
66         d = {}
67         for relPath, oldName, newName in files:
68                 if relPath not in d:
69                         d[relPath] = []
70                 d[relPath].append((oldName, newName))
71         return d
72
73
74 def build_package(distribution):
75         try:
76                 os.chdir(os.path.dirname(sys.argv[0]))
77         except:
78                 pass
79
80         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
81         p = py2deb.Py2deb(__appname__)
82         p.prettyName = constants.__pretty_app_name__
83         p.description = __description__
84         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
85         p.author = __author__
86         p.mail = __email__
87         p.license = "lgpl"
88         p.depends = ", ".join([
89                 "python2.6 | python2.5",
90                 "python-simplejson",
91         ])
92         p.depends += {
93                 "debian": ", python-qt4",
94                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
95                 "fremantle": ", python2.5-qt4-core, python2.5-qt4-gui, python2.5-qt4-maemo5",
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         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
126                 fullPath = "/opt/%s/share" % __appname__
127                 if relPath:
128                         fullPath += os.sep+relPath
129                 p[fullPath] = list(
130                         "|".join((oldName, newName))
131                         for (oldName, newName) in files
132                 )
133         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
134         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
135         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
136         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
137
138         print p
139         if distribution == "debian":
140                 print p.generate(
141                         version="%s-%s" % (__version__, __build__),
142                         changelog=__changelog__,
143                         build=True,
144                         tar=False,
145                         changes=False,
146                         dsc=False,
147                 )
148         else:
149                 print p.generate(
150                         version="%s-%s" % (__version__, __build__),
151                         changelog=__changelog__,
152                         build=False,
153                         tar=True,
154                         changes=True,
155                         dsc=True,
156                 )
157         print "Building for %s finished" % distribution
158
159
160 if __name__ == "__main__":
161         if len(sys.argv) == 1:
162                 distribution = "fremantle"
163         else:
164                 distribution = sys.argv[1]
165         build_package(distribution)