54d331ca1bfb5060d9238c4c17486d62dfa94b8b
[theonering] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 """
4 @bug In update desrcription stuff
5 """
6
7 import os
8 import sys
9
10 try:
11         import py2deb
12 except ImportError:
13         import fake_py2deb as py2deb
14
15 import constants
16
17
18 __appname__ = constants.__app_name__
19 __description__ = "Google Voice Communication Plugin"
20 __author__ = "Ed Page"
21 __email__ = "eopage@byu.net"
22 __version__ = constants.__version__
23 __build__ = constants.__build__
24 __changelog__ = """
25 0.1.0
26 * Initial release
27 """
28
29
30 __postinstall__ = """#!/bin/sh -e
31
32 gtk-update-icon-cache -f /usr/share/icons/hicolor
33 """
34
35 def find_files(path):
36         for root, dirs, files in os.walk(path):
37                 for file in files:
38                         if file.startswith("src-"):
39                                 fileParts = file.split("-")
40                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
41                                 assert unused == "src"
42                                 relPath = os.sep.join(relPathParts)
43                                 yield relPath, file, newName
44
45
46 def unflatten_files(files):
47         d = {}
48         for relPath, oldName, newName in files:
49                 if relPath not in d:
50                         d[relPath] = []
51                 d[relPath].append((oldName, newName))
52         return d
53
54
55 def build_package(distribution):
56         try:
57                 os.chdir(os.path.dirname(sys.argv[0]))
58         except:
59                 pass
60
61         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
62         p = py2deb.Py2deb(__appname__)
63         p.description = __description__
64         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
65         p.author = __author__
66         p.mail = __email__
67         p.license = "lgpl"
68         p.depends = ", ".join([
69                 "python2.6 | python2.5",
70                 "python-gtk2 | python2.5-gtk2",
71                 "python-xml | python2.5-xml",
72                 "python-dbus | python2.5-dbus",
73         ])
74         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
75         p.depends += {
76                 "debian": ", python-glade2",
77                 "chinook": maemoSpecificDepends,
78                 "diablo": maemoSpecificDepends,
79                 "fremantle": maemoSpecificDepends + ", python-glade2",
80                 "mer": maemoSpecificDepends + ", python-glade2",
81         }[distribution]
82         p.recommends = ", ".join([
83         ])
84         p.section = {
85                 "debian": "comm",
86                 "chinook": "communication",
87                 "diablo": "user/network",
88                 "fremantle": "user/network",
89                 "mer": "user/network",
90         }[distribution]
91         p.arch = "all"
92         p.urgency = "low"
93         p.distribution = "chinook diablo fremantle mer debian"
94         p.repository = "extras"
95         p.changelog = __changelog__
96         p.postinstall = __postinstall__
97         p.icon = {
98                 "debian": "26x26-theonering.png",
99                 "chinook": "26x26-theonering.png",
100                 "diablo": "26x26-theonering.png",
101                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
102                 "mer": "64x64-theonering.png",
103         }[distribution]
104         p["/usr/bin"] = [ "theonering.py" ]
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.ConnectionManagers.theonering.service.in"]
114         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
115         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|theonering.png"]
116         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-theonering.png|theonering.png"]
117         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-theonering.png|theonering.png"]
118
119         print p
120         print p.generate(
121                 version="%s-%s" % (__version__, __build__),
122                 changelog=__changelog__,
123                 build=False,
124                 tar=True,
125                 changes=True,
126                 dsc=True,
127         )
128         print "Building for %s finished" % distribution
129
130
131 if __name__ == "__main__":
132         if len(sys.argv) > 1:
133                 try:
134                         import optparse
135                 except ImportError:
136                         optparse = None
137
138                 if optparse is not None:
139                         parser = optparse.OptionParser()
140                         (commandOptions, commandArgs) = parser.parse_args()
141         else:
142                 commandArgs = None
143                 commandArgs = ["diablo"]
144         build_package(commandArgs[0])