Bump to 0.8.23
[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 * Providing a more descriptive error message on most failed calls
36 * Working around an issue when pulling data from GV
37 """.strip()
38
39
40 __postinstall__ = """#!/bin/sh -e
41
42 gtk-update-icon-cache -f /usr/share/icons/hicolor
43 rm -f ~/.telepathy-theonering/theonering.log
44 """
45
46 def find_files(path):
47         for root, dirs, files in os.walk(path):
48                 for file in files:
49                         if file.startswith("src!"):
50                                 fileParts = file.split("!")
51                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
52                                 assert unused == "src"
53                                 relPath = os.sep.join(relPathParts)
54                                 yield relPath, file, newName
55
56
57 def unflatten_files(files):
58         d = {}
59         for relPath, oldName, newName in files:
60                 if relPath not in d:
61                         d[relPath] = []
62                 d[relPath].append((oldName, newName))
63         return d
64
65
66 def build_package(distribution):
67         try:
68                 os.chdir(os.path.dirname(sys.argv[0]))
69         except:
70                 pass
71
72         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
73         p = py2deb.Py2deb(__appname__)
74         if distribution == "debian":
75                 p.prettyName = constants.__pretty_app_name__
76         else:
77                 p.prettyName = "Google Voice plugin for Conversations and Calls"
78         p.description = __description__
79         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=The%%20One%%20Ring"
80         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
81         p.author = __author__
82         p.mail = __email__
83         p.license = "lgpl"
84         p.section = {
85                 "debian": "comm",
86                 "diablo": "user/network",
87                 "fremantle": "user/network",
88         }[distribution]
89         p.depends = ", ".join([
90                 "python (>= 2.5) | python2.5",
91                 "python-dbus | python2.5-dbus",
92                 "python-gobject | python2.5-gobject",
93                 "python-telepathy | python2.5-telepathy",
94         ])
95         p.depends += {
96                 "debian": "",
97                 "diablo": ", python2.5-conic, account-plugin-haze",
98                 "fremantle": ", account-plugin-haze",
99         }[distribution]
100         p.arch = "all"
101         p.urgency = "low"
102         p.distribution = "diablo fremantle debian"
103         p.repository = "extras"
104         p.changelog = __changelog__
105         p.postinstall = __postinstall__
106         p.icon = "32-tor_handset.png"
107         for relPath, files in unflatten_files(find_files(".")).iteritems():
108                 fullPath = "/opt/theonering/lib"
109                 if relPath:
110                         fullPath += os.sep+relPath
111                 p[fullPath] = list(
112                         "|".join((oldName, newName))
113                         for (oldName, newName) in files
114                 )
115         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
116         if distribution in ("debian", ):
117                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
118         elif distribution in ("diablo", "fremantle"):
119                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
120         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
121         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
122         if distribution in ("debian", ):
123                 iconBasePath = "/usr/share/icons/gnome/%s/apps"
124         elif distribution in ("diablo", "fremantle"):
125                 iconBasePath = "/usr/share/icons/hicolor/%s/hildon"
126         p[iconBasePath % "26x26"] = ["26-tor_handset.png|im-theonering.png"]
127         p[iconBasePath % "32x32"] = ["32-tor_handset.png|im-theonering.png"]
128         p[iconBasePath % "64x64"] = ["64-tor_handset.png|im-theonering.png"]
129         p["/opt/theonering/share"] = [
130                 "32-tor_handset.png|tor_handset.png",
131                 "32-tor_phone.png|tor_phone.png",
132                 "32-tor_question.png|tor_question.png",
133                 "32-tor_self.png|tor_self.png",
134         ]
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])