Bump to -20, fixing Maemo 4.1 depends, cleaning up descriptions
[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__ = """Note: This is jealous of new technology and will eat the kittens of n900 owners.
16 Google Voice Communication Plugin
17 .
18 Features:
19 .
20 * Send Texts and Receive both Texts and Voicemail through your chat window
21 .
22 * Initiate Google Voice callbacks from the dialpad or your contacts (Maemo 4.1 only)
23 .
24 * Access to all of your Google Voice contacts (Maemo 4.1 only)
25 .
26 * Reduce battery drain by setting your status to "Away"
27 .
28 * Block incoming calls by switching your status to "Hidden"
29 .
30 Note: Google and Google Voice are probably trademarks of Google.  This software nor the author has any affiliation with Google
31 .
32 Homepage: http://theonering.garage.maemo.org
33 """
34 __author__ = "Ed Page"
35 __email__ = "eopage@byu.net"
36 __version__ = constants.__version__
37 __build__ = constants.__build__
38 __changelog__ = """
39 0.1.0
40 * Initial release
41 """
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=theonering"
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                 "mer": "user/network",
93         }[distribution]
94         p.depends = ", ".join([
95                 "python (>= 2.5) | python2.5",
96                 "python-dbus | python2.5-dbus",
97                 "python-gobject | python2.5-gobject",
98                 "python-telepathy | python2.5-telepathy",
99         ])
100         p.depends += {
101                 "debian": "",
102                 "chinook": "",
103                 "diablo": ", python2.5-conic, account-plugin-haze",
104                 "fremantle": ", account-plugin-haze",
105                 "mer": "",
106         }[distribution]
107         p.arch = "all"
108         p.urgency = "low"
109         p.distribution = "diablo fremantle mer debian"
110         p.repository = "extras"
111         p.changelog = __changelog__
112         p.postinstall = __postinstall__
113         p.icon = {
114                 "debian": "26x26-theonering.png",
115                 "diablo": "26x26-theonering.png",
116                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
117                 "mer": "64x64-theonering.png",
118         }[distribution]
119         for relPath, files in unflatten_files(find_files(".")).iteritems():
120                 fullPath = "/usr/lib/theonering"
121                 if relPath:
122                         fullPath += os.sep+relPath
123                 p[fullPath] = list(
124                         "|".join((oldName, newName))
125                         for (oldName, newName) in files
126                 )
127         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
128         if distribution in ("debian", ):
129                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
130         elif distribution in ("diablo", "fremantle", "mer"):
131                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
132         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
133         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
134         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|im-theonering.png"]
135
136         if distribution == "debian":
137                 print p
138                 print p.generate(
139                         version="%s-%s" % (__version__, __build__),
140                         changelog=__changelog__,
141                         build=True,
142                         tar=False,
143                         changes=False,
144                         dsc=False,
145                 )
146                 print "Building for %s finished" % distribution
147         else:
148                 print p
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                 try:
163                         import optparse
164                 except ImportError:
165                         optparse = None
166
167                 if optparse is not None:
168                         parser = optparse.OptionParser()
169                         (commandOptions, commandArgs) = parser.parse_args()
170         else:
171                 commandArgs = None
172                 commandArgs = ["diablo"]
173         build_package(commandArgs[0])