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