Bump to 0.8.19
[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
19 .
20 * Initiate Google Voice callbacks from the dialpad or your contacts
21 .
22 * Access to all of your Google Voice contacts
23 .
24 * Reduce battery drain by setting your status to "Away"
25 .
26 Note: Google and Google Voice are probably trademarks of Google.  This software nor the author has any affiliation with Google
27 .
28 Homepage: http://theonering.garage.maemo.org
29 """
30 __author__ = "Ed Page"
31 __email__ = "eopage@byu.net"
32 __version__ = constants.__version__
33 __build__ = constants.__build__
34 __changelog__ = """
35 * Shaving 300ms off of startup time
36 * Making the alias code a bit more robust, taken from a fix for an issue that breaks dialcentral
37 * Adding a quit command to the debug prompt
38 * Adding a update_now command to the debug prompt
39 * Fixing a bug with reset_timers debug prompt
40 * Adding a utility to send debug commands from the command prompt
41 """.strip()
42
43
44 __postinstall__ = """#!/bin/sh -e
45
46 gtk-update-icon-cache -f /usr/share/icons/hicolor
47 rm -f ~/.telepathy-theonering/theonering.log
48 """
49
50 def find_files(path):
51         for root, dirs, files in os.walk(path):
52                 for file in files:
53                         if file.startswith("src!"):
54                                 fileParts = file.split("!")
55                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
56                                 assert unused == "src"
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         if distribution == "debian":
79                 p.prettyName = constants.__pretty_app_name__
80         else:
81                 p.prettyName = "Google Voice plugin for Conversations and Calls"
82         p.description = __description__
83         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=The%%20One%%20Ring"
84         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
85         p.author = __author__
86         p.mail = __email__
87         p.license = "lgpl"
88         p.section = {
89                 "debian": "comm",
90                 "diablo": "user/network",
91                 "fremantle": "user/network",
92         }[distribution]
93         p.depends = ", ".join([
94                 "python (>= 2.5) | python2.5",
95                 "python-dbus | python2.5-dbus",
96                 "python-gobject | python2.5-gobject",
97                 "python-telepathy | python2.5-telepathy",
98         ])
99         p.depends += {
100                 "debian": "",
101                 "diablo": ", python2.5-conic, account-plugin-haze",
102                 "fremantle": ", account-plugin-haze",
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.icon = "32-tor_handset.png"
111         for relPath, files in unflatten_files(find_files(".")).iteritems():
112                 fullPath = "/opt/theonering/lib"
113                 if relPath:
114                         fullPath += os.sep+relPath
115                 p[fullPath] = list(
116                         "|".join((oldName, newName))
117                         for (oldName, newName) in files
118                 )
119         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
120         if distribution in ("debian", ):
121                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
122         elif distribution in ("diablo", "fremantle"):
123                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
124         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
125         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
126         if distribution in ("debian", ):
127                 iconBasePath = "/usr/share/icons/gnome/%s/apps"
128         elif distribution in ("diablo", "fremantle"):
129                 iconBasePath = "/usr/share/icons/hicolor/%s/hildon"
130         p[iconBasePath % "26x26"] = ["26-tor_handset.png|im-theonering.png"]
131         p[iconBasePath % "32x32"] = ["32-tor_handset.png|im-theonering.png"]
132         p[iconBasePath % "64x64"] = ["64-tor_handset.png|im-theonering.png"]
133         p["/opt/theonering/share"] = [
134                 "32-tor_handset.png|tor_handset.png",
135                 "32-tor_phone.png|tor_phone.png",
136                 "32-tor_question.png|tor_question.png",
137                 "32-tor_self.png|tor_self.png",
138         ]
139
140         if distribution == "debian":
141                 print p
142                 print p.generate(
143                         version="%s-%s" % (__version__, __build__),
144                         changelog=__changelog__,
145                         build=True,
146                         tar=False,
147                         changes=False,
148                         dsc=False,
149                 )
150                 print "Building for %s finished" % distribution
151         else:
152                 print p
153                 print p.generate(
154                         version="%s-%s" % (__version__, __build__),
155                         changelog=__changelog__,
156                         build=False,
157                         tar=True,
158                         changes=True,
159                         dsc=True,
160                 )
161                 print "Building for %s finished" % distribution
162
163
164 if __name__ == "__main__":
165         if len(sys.argv) > 1:
166                 try:
167                         import optparse
168                 except ImportError:
169                         optparse = None
170
171                 if optparse is not None:
172                         parser = optparse.OptionParser()
173                         (commandOptions, commandArgs) = parser.parse_args()
174         else:
175                 commandArgs = None
176                 commandArgs = ["diablo"]
177         build_package(commandArgs[0])