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