I showed I can't be trusted, deleting the cache on install
[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 -Rf ~/.telepathy-theonering/cache
45 rm -f ~/.telepathy-theonering/theonering.log
46 """
47
48 def find_files(path):
49         for root, dirs, files in os.walk(path):
50                 for file in files:
51                         if file.startswith("src!"):
52                                 fileParts = file.split("!")
53                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
54                                 assert unused == "src"
55                                 relPath = os.sep.join(relPathParts)
56                                 yield relPath, file, newName
57
58
59 def unflatten_files(files):
60         d = {}
61         for relPath, oldName, newName in files:
62                 if relPath not in d:
63                         d[relPath] = []
64                 d[relPath].append((oldName, newName))
65         return d
66
67
68 def build_package(distribution):
69         try:
70                 os.chdir(os.path.dirname(sys.argv[0]))
71         except:
72                 pass
73
74         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
75         p = py2deb.Py2deb(__appname__)
76         if distribution == "debian":
77                 p.prettyName = constants.__pretty_app_name__
78         else:
79                 p.prettyName = "Google Voice protocol plugin for Conversations and Contacts"
80         p.description = __description__
81         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=theonering"
82         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
83         p.author = __author__
84         p.mail = __email__
85         p.license = "lgpl"
86         p.section = {
87                 "debian": "comm",
88                 "diablo": "user/network",
89                 "fremantle": "user/network",
90                 "mer": "user/network",
91         }[distribution]
92         p.depends = ", ".join([
93                 "python (>= 2.5) | python2.5",
94                 "python-dbus | python2.5-dbus",
95                 "python-gobject | python2.5-gobject",
96                 "python-telepathy | python2.5-telepathy",
97         ])
98         p.depends += {
99                 "debian": "",
100                 "chinook": "",
101                 "diablo": ", account-plugin-haze",
102                 "fremantle": ", account-plugin-haze",
103                 "mer": "",
104         }[distribution]
105         p.arch = "all"
106         p.urgency = "low"
107         p.distribution = "diablo fremantle mer debian"
108         p.repository = "extras"
109         p.changelog = __changelog__
110         p.postinstall = __postinstall__
111         p.icon = {
112                 "debian": "26x26-theonering.png",
113                 "diablo": "26x26-theonering.png",
114                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
115                 "mer": "64x64-theonering.png",
116         }[distribution]
117         for relPath, files in unflatten_files(find_files(".")).iteritems():
118                 fullPath = "/usr/lib/theonering"
119                 if relPath:
120                         fullPath += os.sep+relPath
121                 p[fullPath] = list(
122                         "|".join((oldName, newName))
123                         for (oldName, newName) in files
124                 )
125         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
126         if distribution in ("debian", ):
127                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
128         elif distribution in ("diablo", "fremantle", "mer"):
129                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
130         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
131         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
132         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|im-theonering.png"]
133
134         if distribution == "debian":
135                 print p
136                 print p.generate(
137                         version="%s-%s" % (__version__, __build__),
138                         changelog=__changelog__,
139                         build=True,
140                         tar=False,
141                         changes=False,
142                         dsc=False,
143                 )
144                 print "Building for %s finished" % distribution
145         else:
146                 print p
147                 print p.generate(
148                         version="%s-%s" % (__version__, __build__),
149                         changelog=__changelog__,
150                         build=False,
151                         tar=True,
152                         changes=True,
153                         dsc=True,
154                 )
155                 print "Building for %s finished" % distribution
156
157
158 if __name__ == "__main__":
159         if len(sys.argv) > 1:
160                 try:
161                         import optparse
162                 except ImportError:
163                         optparse = None
164
165                 if optparse is not None:
166                         parser = optparse.OptionParser()
167                         (commandOptions, commandArgs) = parser.parse_args()
168         else:
169                 commandArgs = None
170                 commandArgs = ["diablo"]
171         build_package(commandArgs[0])