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