Pulling in changes from skeleton
[multilist] / 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__ = """Simple list management application
16 .
17 Homepage: http://multilist.garage.maemo.org/
18 """
19 __author__ = "Christoph Wurstle"
20 __email__ = "n800@axique.net"
21 __version__ = constants.__version__
22 __build__ = constants.__build__
23 __changelog__ = """
24 * Updated the icon to something slightly better
25 """.strip()
26
27
28 __postinstall__ = """#!/bin/sh -e
29
30 gtk-update-icon-cache -f /usr/share/icons/hicolor
31 rm -f ~/.multilist/multilist.log
32 """
33
34
35 def find_files(path, root):
36         print path, root
37         for unusedRoot, dirs, files in os.walk(path):
38                 for file in files:
39                         if file.startswith(root+"-"):
40                                 print "\t", root, file
41                                 fileParts = file.split("-")
42                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
43                                 assert unused == root
44                                 relPath = os.sep.join(relPathParts)
45                                 yield relPath, file, newName
46
47
48 def unflatten_files(files):
49         d = {}
50         for relPath, oldName, newName in files:
51                 if relPath not in d:
52                         d[relPath] = []
53                 d[relPath].append((oldName, newName))
54         return d
55
56
57 def build_package(distribution):
58         try:
59                 os.chdir(os.path.dirname(sys.argv[0]))
60         except:
61                 pass
62
63         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
64         p = py2deb.Py2deb(__appname__)
65         p.prettyName = constants.__pretty_app_name__
66         p.description = __description__
67         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Multilist"
68         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
69         p.author = __author__
70         p.mail = __email__
71         p.license = "gpl"
72         p.depends = ", ".join([
73                 "python2.6 | python2.5",
74                 "python-gtk2 | python2.5-gtk2",
75                 "python-xml | python2.5-xml",
76                 "python-dbus | python2.5-dbus",
77         ])
78         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
79         p.depends += {
80                 "debian": ", python-glade2",
81                 "diablo": maemoSpecificDepends,
82                 "fremantle": maemoSpecificDepends + ", python-glade2",
83         }[distribution]
84         p.section = {
85                 "debian": "editors",
86                 "diablo": "user/office",
87                 "fremantle": "user/office",
88         }[distribution]
89         p.arch = "all"
90         p.urgency = "low"
91         p.distribution = "diablo fremantle debian"
92         p.repository = "extras"
93         p.changelog = __changelog__
94         p.postinstall = __postinstall__
95         p.icon = {
96                 "debian": "26x26-multilist.png",
97                 "diablo": "26x26-multilist.png",
98                 "fremantle": "48x48-multilist.png", # Fremantle natively uses 48x48
99         }[distribution]
100         p["/usr/bin"] = [ "multilist.py" ]
101         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
102                 fullPath = "/usr/share/locale"
103                 if relPath:
104                         fullPath += os.sep+relPath
105                 p[fullPath] = list(
106                         "|".join((oldName, newName))
107                         for (oldName, newName) in files
108                 )
109         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
110                 fullPath = "/usr/lib/multilist"
111                 if relPath:
112                         fullPath += os.sep+relPath
113                 p[fullPath] = list(
114                         "|".join((oldName, newName))
115                         for (oldName, newName) in files
116                 )
117         p["/usr/share/applications/hildon"] = ["multilist.desktop"]
118         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-multilist.png|multilist.png"]
119         p["/usr/share/icons/hicolor/32x32/hildon"] = ["32x32-multilist.png|multilist.png"]
120         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-multilist.png|multilist.png"]
121
122         if distribution == "debian":
123                 print p
124                 print p.generate(
125                         version="%s-%s" % (__version__, __build__),
126                         changelog=__changelog__,
127                         build=True,
128                         tar=False,
129                         changes=False,
130                         dsc=False,
131                 )
132                 print "Building for %s finished" % distribution
133         else:
134                 print p
135                 print p.generate(
136                         version="%s-%s" % (__version__, __build__),
137                         changelog=__changelog__,
138                         build=False,
139                         tar=True,
140                         changes=True,
141                         dsc=True,
142                 )
143                 print "Building for %s finished" % distribution
144
145
146 if __name__ == "__main__":
147         if len(sys.argv) > 1:
148                 try:
149                         import optparse
150                 except ImportError:
151                         optparse = None
152
153                 if optparse is not None:
154                         parser = optparse.OptionParser()
155                         (commandOptions, commandArgs) = parser.parse_args()
156         else:
157                 commandArgs = None
158                 commandArgs = ["diablo"]
159         build_package(commandArgs[0])