Some cleanup on the auto-accept code
[theonering] / 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__ = """Send/receive texts and initiate GV callbacks all through Conversations and Phone
16 Features:
17 .
18 * Send Texts and Receive both Texts and Voicemail through your chat window (buggy on Maemo 4.1)
19 .
20 * Initiate Google Voice callbacks from the dialpad or your contacts
21 .
22 * Access to all of your Google Voice contacts (Maemo 4.1 only for now)
23 .
24 * Reduce battery drain by setting your status to "Away"
25 .
26 * Block incoming calls by switching your status to "Hidden"
27 .
28 Note: Google and Google Voice are probably trademarks of Google.  This software nor the author has any affiliation with Google
29 .
30 Homepage: http://theonering.garage.maemo.org
31 """
32 __author__ = "Ed Page"
33 __email__ = "eopage@byu.net"
34 __version__ = constants.__version__
35 __build__ = constants.__build__
36 __changelog__ = """
37 0.7.6
38 * On login, polling now starts at the max time rather than the min, reducing overhead
39 * Bugfix: Polling configuration wasn't actually hooked up to anything
40 * Debug Prompt: Made it so you can either reset one or all state machines (Rather than just all)
41
42 0.7.5
43 * Fixing a polling time bug introduced when making polling configurable
44
45 0.7.4
46 * Fixing a bug with deny-lists
47
48 0.7.3
49 * Fixing bug with being able to configure polling times
50
51 0.7.2
52 * Added a Deny list
53 * Added option to make GV Contacts optional
54 * Added a limit, where if a state machine period is longer than it, than we set the period to infinite
55 * Delayed when we say the connection is disconnected to hopefully help random issues
56 * Tweaked how The One Ring shows up in the addressbook (Maemo 5)
57 * Made polling configurable
58 * Delayed auto-disconnect in case the user is just switching network connections (Maemo 4.1)
59 * Bugfix: Removed superfluous blank message from debug prompt
60 * Bugfix: Moved some more (very minor, very rarely used) timeouts to second resolution reducing overhead
61 * Bugfix: debug prompt commands handled command validation poorly
62 * Debug Prompt: Added a "version" command
63 * Debug Prompt: Added a "get_polling" command to find out what the actual polling periods are
64 * Debug Prompt: Added a "grab_log" command which is a broken but means to offer the log file through a file transfer
65 * Debug Prompt: Added a "save_log" command to help till grab_log works and for where file transfers aren't supported by clients
66
67 0.7.1
68 * Reducing the race window where GV will mark messages as read accidently
69 * Modified some things blindly "because thats what Butterfly does"
70 * Modified some support files to mimic other plugins on Maemo 5 PR1.1
71 * Added link to bug tracker and moved all bugs and enhancements to it
72 * Switched contacts to being away by default upon user feedback
73 * Adjusting handling of call states to at least allow the option of clients to provide clearer information to the user
74 * Fixing some bugs with handling a variety of phone number formats
75 * Removed a hack that changed the number being called, most likely put in place in a bygone era
76
77 0.7.0
78 * Initial beta release for Maemo 5
79 * Late Alpha for Maemo 4.1 with horrible consequences like crashing RTComm
80
81 0.1.0
82 * Pre-Alpha Development Release
83 """
84
85
86 __postinstall__ = """#!/bin/sh -e
87
88 gtk-update-icon-cache -f /usr/share/icons/hicolor
89 rm -f ~/.telepathy-theonering/theonering.log
90 """
91
92 def find_files(path):
93         for root, dirs, files in os.walk(path):
94                 for file in files:
95                         if file.startswith("src!"):
96                                 fileParts = file.split("!")
97                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
98                                 assert unused == "src"
99                                 relPath = os.sep.join(relPathParts)
100                                 yield relPath, file, newName
101
102
103 def unflatten_files(files):
104         d = {}
105         for relPath, oldName, newName in files:
106                 if relPath not in d:
107                         d[relPath] = []
108                 d[relPath].append((oldName, newName))
109         return d
110
111
112 def build_package(distribution):
113         try:
114                 os.chdir(os.path.dirname(sys.argv[0]))
115         except:
116                 pass
117
118         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
119         p = py2deb.Py2deb(__appname__)
120         if distribution == "debian":
121                 p.prettyName = constants.__pretty_app_name__
122         else:
123                 p.prettyName = "Google Voice plugin for Conversations and Calls"
124         p.description = __description__
125         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=The%%20One%%20Ring"
126         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
127         p.author = __author__
128         p.mail = __email__
129         p.license = "lgpl"
130         p.section = {
131                 "debian": "comm",
132                 "diablo": "user/network",
133                 "fremantle": "user/network",
134                 "mer": "user/network",
135         }[distribution]
136         p.depends = ", ".join([
137                 "python (>= 2.5) | python2.5",
138                 "python-dbus | python2.5-dbus",
139                 "python-gobject | python2.5-gobject",
140                 "python-telepathy | python2.5-telepathy",
141         ])
142         p.depends += {
143                 "debian": "",
144                 "diablo": ", python2.5-conic, account-plugin-haze",
145                 "fremantle": ", account-plugin-haze",
146                 "mer": "",
147         }[distribution]
148         p.arch = "all"
149         p.urgency = "low"
150         p.distribution = "diablo fremantle mer debian"
151         p.repository = "extras"
152         p.changelog = __changelog__
153         p.postinstall = __postinstall__
154         p.icon = {
155                 "debian": "26x26-theonering.png",
156                 "diablo": "26x26-theonering.png",
157                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
158                 "mer": "64x64-theonering.png",
159         }[distribution]
160         for relPath, files in unflatten_files(find_files(".")).iteritems():
161                 fullPath = "/usr/lib/theonering"
162                 if relPath:
163                         fullPath += os.sep+relPath
164                 p[fullPath] = list(
165                         "|".join((oldName, newName))
166                         for (oldName, newName) in files
167                 )
168         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
169         if distribution in ("debian", ):
170                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
171         elif distribution in ("diablo", "fremantle", "mer"):
172                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
173         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
174         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
175         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|im-theonering.png"]
176
177         if distribution == "debian":
178                 print p
179                 print p.generate(
180                         version="%s-%s" % (__version__, __build__),
181                         changelog=__changelog__,
182                         build=True,
183                         tar=False,
184                         changes=False,
185                         dsc=False,
186                 )
187                 print "Building for %s finished" % distribution
188         else:
189                 print p
190                 print p.generate(
191                         version="%s-%s" % (__version__, __build__),
192                         changelog=__changelog__,
193                         build=False,
194                         tar=True,
195                         changes=True,
196                         dsc=True,
197                 )
198                 print "Building for %s finished" % distribution
199
200
201 if __name__ == "__main__":
202         if len(sys.argv) > 1:
203                 try:
204                         import optparse
205                 except ImportError:
206                         optparse = None
207
208                 if optparse is not None:
209                         parser = optparse.OptionParser()
210                         (commandOptions, commandArgs) = parser.parse_args()
211         else:
212                 commandArgs = None
213                 commandArgs = ["diablo"]
214         build_package(commandArgs[0])