Making it easier to distinguish whether my test code is covering backend or frontend
[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 * Shaving 300ms off of startup time
36 * Making the alias code a bit more robust, taken from a fix for an issue that breaks dialcentral
37 * Adding a quit command to the debug prompt
38 * Adding a update_now command to the debug prompt
39 * Fixing a bug with reset_timers debug prompt
40 """.strip()
41
42
43 __postinstall__ = """#!/bin/sh -e
44
45 gtk-update-icon-cache -f /usr/share/icons/hicolor
46 rm -f ~/.telepathy-theonering/theonering.log
47 """
48
49 def find_files(path):
50         for root, dirs, files in os.walk(path):
51                 for file in files:
52                         if file.startswith("src!"):
53                                 fileParts = file.split("!")
54                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
55                                 assert unused == "src"
56                                 relPath = os.sep.join(relPathParts)
57                                 yield relPath, file, newName
58
59
60 def unflatten_files(files):
61         d = {}
62         for relPath, oldName, newName in files:
63                 if relPath not in d:
64                         d[relPath] = []
65                 d[relPath].append((oldName, newName))
66         return d
67
68
69 def build_package(distribution):
70         try:
71                 os.chdir(os.path.dirname(sys.argv[0]))
72         except:
73                 pass
74
75         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
76         p = py2deb.Py2deb(__appname__)
77         if distribution == "debian":
78                 p.prettyName = constants.__pretty_app_name__
79         else:
80                 p.prettyName = "Google Voice plugin for Conversations and Calls"
81         p.description = __description__
82         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=The%%20One%%20Ring"
83         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
84         p.author = __author__
85         p.mail = __email__
86         p.license = "lgpl"
87         p.section = {
88                 "debian": "comm",
89                 "diablo": "user/network",
90                 "fremantle": "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                 "diablo": ", python2.5-conic, account-plugin-haze",
101                 "fremantle": ", account-plugin-haze",
102         }[distribution]
103         p.arch = "all"
104         p.urgency = "low"
105         p.distribution = "diablo fremantle debian"
106         p.repository = "extras"
107         p.changelog = __changelog__
108         p.postinstall = __postinstall__
109         p.icon = "32-tor_handset.png"
110         for relPath, files in unflatten_files(find_files(".")).iteritems():
111                 fullPath = "/opt/theonering/lib"
112                 if relPath:
113                         fullPath += os.sep+relPath
114                 p[fullPath] = list(
115                         "|".join((oldName, newName))
116                         for (oldName, newName) in files
117                 )
118         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
119         if distribution in ("debian", ):
120                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
121         elif distribution in ("diablo", "fremantle"):
122                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
123         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
124         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
125         if distribution in ("debian", ):
126                 iconBasePath = "/usr/share/icons/gnome/%s/apps"
127         elif distribution in ("diablo", "fremantle"):
128                 iconBasePath = "/usr/share/icons/hicolor/%s/hildon"
129         p[iconBasePath % "26x26"] = ["26-tor_handset.png|im-theonering.png"]
130         p[iconBasePath % "32x32"] = ["32-tor_handset.png|im-theonering.png"]
131         p[iconBasePath % "64x64"] = ["64-tor_handset.png|im-theonering.png"]
132         p["/opt/theonering/share"] = [
133                 "32-tor_handset.png|tor_handset.png",
134                 "32-tor_phone.png|tor_phone.png",
135                 "32-tor_question.png|tor_question.png",
136                 "32-tor_self.png|tor_self.png",
137         ]
138
139         if distribution == "debian":
140                 print p
141                 print p.generate(
142                         version="%s-%s" % (__version__, __build__),
143                         changelog=__changelog__,
144                         build=True,
145                         tar=False,
146                         changes=False,
147                         dsc=False,
148                 )
149                 print "Building for %s finished" % distribution
150         else:
151                 print p
152                 print p.generate(
153                         version="%s-%s" % (__version__, __build__),
154                         changelog=__changelog__,
155                         build=False,
156                         tar=True,
157                         changes=True,
158                         dsc=True,
159                 )
160                 print "Building for %s finished" % distribution
161
162
163 if __name__ == "__main__":
164         if len(sys.argv) > 1:
165                 try:
166                         import optparse
167                 except ImportError:
168                         optparse = None
169
170                 if optparse is not None:
171                         parser = optparse.OptionParser()
172                         (commandOptions, commandArgs) = parser.parse_args()
173         else:
174                 commandArgs = None
175                 commandArgs = ["diablo"]
176         build_package(commandArgs[0])