Bumping to -19 and fixing up the notes
[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 .
17 Google Voice Communication Plugin
18 .
19 Features:
20 .
21 * Send Texts and Receive both Texts and Voicemail through your chat window
22 .
23 * Initiate Google Voice callbacks from the dialpad or your contacts (Maemo 4.1 only)
24 .
25 * Access to all of your Google Voice contacts (Maemo 4.1 only)
26 .
27 * Reduce battery drain by setting your status to "Away"
28 .
29 * Block incoming calls by switching your status to "Hidden"
30 .
31 Note: Google and Google Voice are probably trademarks of Google.  This software nor the author has ny affiliation with Google
32 .
33 Homepage: http://theonering.garage.maemo.org
34 """
35 __author__ = "Ed Page"
36 __email__ = "eopage@byu.net"
37 __version__ = constants.__version__
38 __build__ = constants.__build__
39 __changelog__ = """
40 0.1.0
41 * Initial release
42 """
43
44
45 __postinstall__ = """#!/bin/sh -e
46
47 gtk-update-icon-cache -f /usr/share/icons/hicolor
48 rm -f ~/.telepathy-theonering/theonering.log
49 """
50
51 def find_files(path):
52         for root, dirs, files in os.walk(path):
53                 for file in files:
54                         if file.startswith("src!"):
55                                 fileParts = file.split("!")
56                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
57                                 assert unused == "src"
58                                 relPath = os.sep.join(relPathParts)
59                                 yield relPath, file, newName
60
61
62 def unflatten_files(files):
63         d = {}
64         for relPath, oldName, newName in files:
65                 if relPath not in d:
66                         d[relPath] = []
67                 d[relPath].append((oldName, newName))
68         return d
69
70
71 def build_package(distribution):
72         try:
73                 os.chdir(os.path.dirname(sys.argv[0]))
74         except:
75                 pass
76
77         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
78         p = py2deb.Py2deb(__appname__)
79         if distribution == "debian":
80                 p.prettyName = constants.__pretty_app_name__
81         else:
82                 p.prettyName = "Google Voice protocol plugin for Conversations and Calls"
83         p.description = __description__
84         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=theonering"
85         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
86         p.author = __author__
87         p.mail = __email__
88         p.license = "lgpl"
89         p.section = {
90                 "debian": "comm",
91                 "diablo": "user/network",
92                 "fremantle": "user/network",
93                 "mer": "user/network",
94         }[distribution]
95         p.depends = ", ".join([
96                 "python (>= 2.5) | python2.5",
97                 "python-dbus | python2.5-dbus",
98                 "python-gobject | python2.5-gobject",
99                 "python-telepathy | python2.5-telepathy",
100         ])
101         p.depends += {
102                 "debian": "",
103                 "chinook": "",
104                 "diablo": "python2.5-conic, account-plugin-haze",
105                 "fremantle": ", account-plugin-haze",
106                 "mer": "",
107         }[distribution]
108         p.arch = "all"
109         p.urgency = "low"
110         p.distribution = "diablo fremantle mer debian"
111         p.repository = "extras"
112         p.changelog = __changelog__
113         p.postinstall = __postinstall__
114         p.icon = {
115                 "debian": "26x26-theonering.png",
116                 "diablo": "26x26-theonering.png",
117                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
118                 "mer": "64x64-theonering.png",
119         }[distribution]
120         for relPath, files in unflatten_files(find_files(".")).iteritems():
121                 fullPath = "/usr/lib/theonering"
122                 if relPath:
123                         fullPath += os.sep+relPath
124                 p[fullPath] = list(
125                         "|".join((oldName, newName))
126                         for (oldName, newName) in files
127                 )
128         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
129         if distribution in ("debian", ):
130                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
131         elif distribution in ("diablo", "fremantle", "mer"):
132                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
133         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
134         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
135         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|im-theonering.png"]
136
137         if distribution == "debian":
138                 print p
139                 print p.generate(
140                         version="%s-%s" % (__version__, __build__),
141                         changelog=__changelog__,
142                         build=True,
143                         tar=False,
144                         changes=False,
145                         dsc=False,
146                 )
147                 print "Building for %s finished" % distribution
148         else:
149                 print p
150                 print p.generate(
151                         version="%s-%s" % (__version__, __build__),
152                         changelog=__changelog__,
153                         build=False,
154                         tar=True,
155                         changes=True,
156                         dsc=True,
157                 )
158                 print "Building for %s finished" % distribution
159
160
161 if __name__ == "__main__":
162         if len(sys.argv) > 1:
163                 try:
164                         import optparse
165                 except ImportError:
166                         optparse = None
167
168                 if optparse is not None:
169                         parser = optparse.OptionParser()
170                         (commandOptions, commandArgs) = parser.parse_args()
171         else:
172                 commandArgs = None
173                 commandArgs = ["diablo"]
174         build_package(commandArgs[0])