Updating packaing stuff
[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 .
17 Homepage: http://theonering.garage.maemo.org
18 """
19 __author__ = "Ed Page"
20 __email__ = "eopage@byu.net"
21 __version__ = constants.__version__
22 __build__ = constants.__build__
23 __changelog__ = """
24 0.1.0
25 * Initial release
26 """
27
28
29 __postinstall__ = """#!/bin/sh -e
30
31 gtk-update-icon-cache -f /usr/share/icons/hicolor
32 rm -f ~/.theonering/theonering.log
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.prettyName = constants.__pretty_app_name__
64         p.description = __description__
65         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=theonering"
66         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
67         p.author = __author__
68         p.mail = __email__
69         p.license = "lgpl"
70         p.depends = ", ".join([
71                 "python (>= 2.5)",
72                 "python-dbus",
73                 "python-gobject",
74                 "python-telepathy",
75         ])
76         p.section = {
77                 "debian": "comm",
78                 "chinook": "communication",
79                 "diablo": "user/network",
80                 "fremantle": "user/network",
81                 "mer": "user/network",
82         }[distribution]
83         p.arch = "all"
84         p.urgency = "low"
85         p.distribution = "chinook diablo fremantle mer debian"
86         p.repository = "extras"
87         p.changelog = __changelog__
88         p.postinstall = __postinstall__
89         p.icon = {
90                 "debian": "26x26-theonering.png",
91                 "chinook": "26x26-theonering.png",
92                 "diablo": "26x26-theonering.png",
93                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
94                 "mer": "64x64-theonering.png",
95         }[distribution]
96         for relPath, files in unflatten_files(find_files(".")).iteritems():
97                 fullPath = "/usr/lib/theonering"
98                 if relPath:
99                         fullPath += os.sep+relPath
100                 p[fullPath] = list(
101                         "|".join((oldName, newName))
102                         for (oldName, newName) in files
103                 )
104         p["/usr/share/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
105         if distribution == "debian":
106                 p["/usr/share/mission-control/profiles"] = ["theonering.profile"]
107         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
108         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|theonering.png"]
109         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-theonering.png|theonering.png"]
110         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-theonering.png|theonering.png"]
111
112         if distribution == "debian":
113                 print p
114                 print p.generate(
115                         version="%s-%s" % (__version__, __build__),
116                         changelog=__changelog__,
117                         build=True,
118                         tar=False,
119                         changes=False,
120                         dsc=False,
121                 )
122                 print "Building for %s finished" % distribution
123         else:
124                 print p
125                 print p.generate(
126                         version="%s-%s" % (__version__, __build__),
127                         changelog=__changelog__,
128                         build=False,
129                         tar=True,
130                         changes=True,
131                         dsc=True,
132                 )
133                 print "Building for %s finished" % distribution
134
135
136 if __name__ == "__main__":
137         if len(sys.argv) > 1:
138                 try:
139                         import optparse
140                 except ImportError:
141                         optparse = None
142
143                 if optparse is not None:
144                         parser = optparse.OptionParser()
145                         (commandOptions, commandArgs) = parser.parse_args()
146         else:
147                 commandArgs = None
148                 commandArgs = ["diablo"]
149         build_package(commandArgs[0])