Adding support for building .deb
[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 1.0.8
34 * Sped up login time by delay loading contact list
35 * Sped up login when you do not have a cookie file (first launch)
36 * Ability to narrow down messages either by type or status
37 * Fremantle: Notification Support including testing of custom notifications
38 * UI Tweak: Cut down the number of times the login dialog is needlessly displayed
39 * Bug Fix: Switching to accounts tab when callback is blank
40 * Bug Fix: Corrupt cookie files prevent login
41 * Bug Fix: Logging in without credentials through cookies
42 * Debugging: Log contents now accessible through Ctrl+l
43
44 1.0.7
45 * Sped up various login cases
46 * Added descriptions to the callback numbers
47 * Collapsed conversations in the messages tab
48 * Give access to all of a contacts numbers when launching dialog from Recent or Messages tabs
49 * UI Tweak: Added more login status notifications
50 * UI Tweak: When no characters are entered, you can't send a text
51 * UI Tweak: Trying to consolidate dialogs by combining phone selection and SMS entry
52 * UI Tweak: Removed "Select" button from SMS Dialog
53 * UI Tweak: Increased the size of the SMS dialog
54 * UI Tweak: Disable "Dial" when a text has started to be entered
55 * UI Tweak: Move the sms history scroll bars around the whole sms conversation, giving more room to see with
56 * UI Tweak: Trying to be clearer by switching the login dialog from "Close" to "Cancel"
57 * UI Tweak: Remove auto-cancel of login after X attempts
58 * Bug Fix: Expanded the types of the Enter key that are supported for going to full screen
59 * Bug Fix: Random people were reporting login issues
60 * Bug Fix: Hardened against issues with grabbing possible callback numbers
61 * Bug Fix: Fremantle GTK doesn't allow TreeView rows to be selected, so row-activated handlers have to read their path
62 * Bug Fix: Fremantle PyMaemo doesn't provide a function Mer PyMaemo does, created a hack to be workable on both
63 * Bug Fix: Once PyMaemo supports thumb button sizes, setting that for all of the random buttons
64 * Bug Fix: When debugging hildonization, dialogs weren't closing
65 * Bug Fix: Not properly hildonizing some code
66 * Bug Fix: Attempting a hack to fix redirect issues for people
67 * Debugging: Improved logging output
68 * Debugging: Printing page when can't get a callback number
69 * Debugging: Included stuff to create all the debug files
70
71 1.0.6
72 * Fremantle Prep: Simplified menus in prep for no menu or the Fremantle App Menu
73 * Fremantle Prep: Implemented a work around for https://bugs.maemo.org/show_bug.cgi?id=4957
74 * Fremantle Prep: Switched to touch selectors for notification time, callback number, and contact addressbook
75 * Fremantle Prep: Making various widgets pannable rather than scrollable
76 * Fremantle Prep: CTRL-V added for paste for Dialpad
77 * Fremantle Prep: CTRL-Enter added for fullscreen
78 * UI Tweak: Phone selection and SMS Message dialogs now highlight the last message and are easier to scroll
79 * UI Tweak: Tweaked sizes of stuff on recent tab
80 * UI Tweak: Added notifcations for various things like login and dialing
81 * UI Tweak: Switch to accounts tab when logging in and callback is blank as a sublte hint to configure it
82 * UI Tweak: Switch to accounts tab on failed login to remind the user they are not logged in
83 * Packaging: Disables notifications on uninstall
84 * Packaging: Including a vastly improved py2deb for better packages (icons on package, etc)
85 * Debugging: Adding seperator between dialcentral launches in log
86 * Bug Fix: Made startup more error resistant
87 * Bug Fix: some dependencies for Diablo
88 * Bug Fix: Error on refreshing tabs when not logged in
89 * Bug Fix: #4471 Notification Checkbox Won't Stay Checked (hour roll over error)
90 * Bug Fix: Phone numbers in voicemails wouldn't appear
91 * Bug Fix: category for Fremantle/Diablo
92 * Bug Fix: needing to manually create "~/.dialcentral" due to earlier logging changes
93 * Bug Fix: dependencies for fremantle
94 * Bug Fix: Issues when trying to stack error messages
95 * Bug Fix: Python2.6 deprecates some stuff I did
96 * Bug Fix: On refreshing the Accounts tab, the callback number resets to the number from startup
97
98 1.0.5
99 * Contacts Tab remembers the last address book viewed on restart
100 * Applied some suggested changes for being more thumb friendly
101 * Messaging Dialog auto-scrolls to bottom
102 * Removed GrandCentral support
103 * Numbers can now be entered immediately, before login
104 * Bug Fix: Not clearing the entered number on sending an SMS
105 * Bug Fix: Disabling SMS button when logged off
106 * Bug Fix: Trying to make SMS and phone selection dialogs more readable
107 * Bug Fix: Adding some more thumb scrollbars
108
109 1.0.4
110 * "Back" button and tabs now visually indicate when they've entered a "hold" state
111 * Fixed the duplicate title on Maemo
112 * Removing some device connection observer code due to high bug to low benefit ratio
113 * Notification support
114 * Fixed a bug from 1.0.3 where once you refreshed a tab by holding on it, every tab would then be forced to refresh
115
116 1.0.3
117 * Holding down a tab for a second will now force a refresh
118 * Fixed a bug dealing with overzealously refreshing the contacts tab
119 * Finding some undescriptive errors and made them more descriptive
120 * Swapped the order GrandCentral and GoogleVoice appear in login window
121 * Fixed the "Recent" and "Message" tabs, google changed things on me again
122
123 1.0.2
124 * Random bug fixes
125 * Random performance improvements
126
127 1.0.1
128 * Fixed a voicemail transcripts due to a GoogleVoice change
129
130 1.0.0
131 * Added names to the recent tab for GoogleVoice
132
133 0.9.9
134 * SMS From Dialpad
135 * Display of names for messages tab
136 * Condensed messages/recent's date column
137
138 0.9.8
139  * Added columns to recent view and messages view to help seperate messages
140  * Attempted refreshing session on dial/sms send
141  * Fixed a GC Bug
142  * Minor bug fixes as usual
143
144 0.9.7
145  * Switched to Force Refresh for when wanting to check for more messages
146  * Removed timeouts that forced refreshes on various tabs
147  * Added support for a settings file, fairly primitive right now
148  * Fixed Maemo Support
149  * Lots of major and minor bug fixes
150
151 0.9.6
152  * Experimenting with the tabs being on the side
153  * Now the phone selector is used always, even if there is just one phone number
154  * Added a Messages Tab, which displays SMS and Voicemail messages
155  * Added option to send SMS messages
156
157 0.9.5
158  * Fixed a login issue due to Google changing their webpage
159
160 0.9.4 - ""
161  * Misc Bug fixes and experiments
162
163 0.9.3 - ""
164  * Removed the much disliked contact source ID
165  * Added saving of callback number when using GoogleVoice
166  * Got proper formatting on things ("&" rather than "&")
167  * Misc Bug fixes
168
169 0.9.2 - "Two heads are better than one"
170  * Adding of UI to switch between GC and GV
171  * Minimized flashing the dial button between grayed out and not on startup
172  * Bug fixes
173
174 0.9.1 - "Get your hands off that"
175  * GoogleVoice Support, what a pain
176  * More flexible CSV support.  It now checks the header row for what column name/number are in
177  * Experimenting with faster startup by caching PYC files with the package
178  * Fixing of some bad error handling
179  * More debug output for when people run into issues
180
181 0.9.0 - "Slick as snot"
182  * Caching of contacts
183  * Refactoring to make working with the code easier
184  * Filesystem backed contacts but currently only supporting a specific csv format
185  * Gracefully handle lack of connection and connection transitions
186  * Gracefully handle failed login
187  * A tiny bit better error reporting
188
189 0.8.3 - "Extras Love"
190  * Version bump fighting the extras autobuilder, I hope this works
191
192 0.8.2 - "Feed is for horses, so what about feedback?"
193  * Merged addressbook
194  * many more smaller fixes
195
196 0.8.1 - "Two Beers"
197  * Thumb scrollbars ( Kudos Khertan )
198
199 0.8.0 - "Spit and polish"
200  * Addressbook support
201  * threaded networking for better interactivity
202  * Hold down back to clear number
203  * Standard about dialog
204  * many more smaller fixes
205 """
206
207
208 __postinstall__ = """#!/bin/sh -e
209
210 gtk-update-icon-cache -f /usr/share/icons/hicolor
211 rm -f ~/.dialcentral/dialcentral.log
212 """
213
214 __preremove__ = """#!/bin/sh -e
215
216 python /usr/lib/dialcentral/alarm_handler.py -d || true
217 """
218
219
220 def find_files(path):
221         for root, dirs, files in os.walk(path):
222                 for file in files:
223                         if file.startswith("src-"):
224                                 fileParts = file.split("-")
225                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
226                                 assert unused == "src"
227                                 relPath = os.sep.join(relPathParts)
228                                 yield relPath, file, newName
229
230
231 def unflatten_files(files):
232         d = {}
233         for relPath, oldName, newName in files:
234                 if relPath not in d:
235                         d[relPath] = []
236                 d[relPath].append((oldName, newName))
237         return d
238
239
240 def build_package(distribution):
241         try:
242                 os.chdir(os.path.dirname(sys.argv[0]))
243         except:
244                 pass
245
246         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
247         p = py2deb.Py2deb(__appname__)
248         p.prettyName = constants.__pretty_app_name__
249         p.description = __description__
250         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
251         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
252         p.author = __author__
253         p.mail = __email__
254         p.license = "lgpl"
255         p.depends = ", ".join([
256                 "python2.6 | python2.5",
257                 "python-gtk2 | python2.5-gtk2",
258                 "python-xml | python2.5-xml",
259                 "python-dbus | python2.5-dbus",
260         ])
261         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
262         p.depends += {
263                 "debian": ", python-glade2",
264                 "chinook": maemoSpecificDepends,
265                 "diablo": maemoSpecificDepends,
266                 "fremantle": maemoSpecificDepends + ", python-glade2, python-alarm",
267                 "mer": maemoSpecificDepends + ", python-glade2",
268         }[distribution]
269         p.recommends = ", ".join([
270         ])
271         p.section = {
272                 "debian": "comm",
273                 "chinook": "communication",
274                 "diablo": "user/network",
275                 "fremantle": "user/network",
276                 "mer": "user/network",
277         }[distribution]
278         p.arch = "all"
279         p.urgency = "low"
280         p.distribution = "chinook diablo fremantle mer debian"
281         p.repository = "extras"
282         p.changelog = __changelog__
283         p.postinstall = __postinstall__
284         p.preremove = __preremove__
285         p.icon = {
286                 "debian": "26x26-dialcentral.png",
287                 "chinook": "26x26-dialcentral.png",
288                 "diablo": "26x26-dialcentral.png",
289                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
290                 "mer": "64x64-dialcentral.png",
291         }[distribution]
292         p["/usr/bin"] = [ "dialcentral.py" ]
293         for relPath, files in unflatten_files(find_files(".")).iteritems():
294                 fullPath = "/usr/lib/dialcentral"
295                 if relPath:
296                         fullPath += os.sep+relPath
297                 p[fullPath] = list(
298                         "|".join((oldName, newName))
299                         for (oldName, newName) in files
300                 )
301         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
302         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
303         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
304         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
305
306         print p
307         print p.generate(
308                 version="%s-%s" % (__version__, __build__),
309                 changelog=__changelog__,
310                 build=True,
311                 tar=True,
312                 changes=True,
313                 dsc=True,
314         )
315         print "Building for %s finished" % distribution
316
317
318 if __name__ == "__main__":
319         if len(sys.argv) > 1:
320                 try:
321                         import optparse
322                 except ImportError:
323                         optparse = None
324
325                 if optparse is not None:
326                         parser = optparse.OptionParser()
327                         (commandOptions, commandArgs) = parser.parse_args()
328         else:
329                 commandArgs = None
330                 commandArgs = ["diablo"]
331         build_package(commandArgs[0])