57a88a534ee4b68718d6e7a8266bb0d0f829a37b
[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/telepathy-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)",
81                 "python-dbus",
82                 "python-gobject",
83                 "python-telepathy",
84         ])
85         p.section = {
86                 "debian": "comm",
87                 "chinook": "communication",
88                 "diablo": "user/network",
89                 "fremantle": "user/network",
90                 "mer": "user/network",
91         }[distribution]
92         p.arch = "all"
93         p.urgency = "low"
94         p.distribution = "chinook diablo fremantle mer debian"
95         p.repository = "extras"
96         p.changelog = __changelog__
97         p.postinstall = __postinstall__
98         p.icon = {
99                 "debian": "26x26-theonering.png",
100                 "chinook": "26x26-theonering.png",
101                 "diablo": "26x26-theonering.png",
102                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
103                 "mer": "64x64-theonering.png",
104         }[distribution]
105         for relPath, files in unflatten_files(find_files(".")).iteritems():
106                 fullPath = "/usr/lib/theonering"
107                 if relPath:
108                         fullPath += os.sep+relPath
109                 p[fullPath] = list(
110                         "|".join((oldName, newName))
111                         for (oldName, newName) in files
112                 )
113         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
114         if distribution == "debian":
115                 p["/usr/share/mission-control/profiles"] = ["theonering.profile"]
116         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
117         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|theonering.png"]
118         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-theonering.png|theonering.png"]
119         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-theonering.png|theonering.png"]
120
121         if distribution == "debian":
122                 print p
123                 print p.generate(
124                         version="%s-%s" % (__version__, __build__),
125                         changelog=__changelog__,
126                         build=True,
127                         tar=False,
128                         changes=False,
129                         dsc=False,
130                 )
131                 print "Building for %s finished" % distribution
132         else:
133                 print p
134                 print p.generate(
135                         version="%s-%s" % (__version__, __build__),
136                         changelog=__changelog__,
137                         build=False,
138                         tar=True,
139                         changes=True,
140                         dsc=True,
141                 )
142                 print "Building for %s finished" % distribution
143
144
145 if __name__ == "__main__":
146         if len(sys.argv) > 1:
147                 try:
148                         import optparse
149                 except ImportError:
150                         optparse = None
151
152                 if optparse is not None:
153                         parser = optparse.OptionParser()
154                         (commandOptions, commandArgs) = parser.parse_args()
155         else:
156                 commandArgs = None
157                 commandArgs = ["diablo"]
158         build_package(commandArgs[0])