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