2e575c5f8dccccefa1282da0ac41420c2dddf29c
[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 0.3.8
25 * Fixed check boxes on Maemo
26
27 0.3.7
28 * Corrected the bug tracker link
29
30 0.3.6
31 * Adding filtering for new and complete in addition to all and active
32
33 0.3.5
34 * Bugfix: Fixing the application launcher
35
36 0.3.4
37 * Making rotation configurable in the Settings window
38 * Persisting full-screen / rotation settings
39
40 0.3.3
41 * Rotation support
42 * Turned the settings dialog into a window
43
44 0.3.2
45 * Massive code cleanup
46 * Re-arrangement of GTK Menus
47 * Added Maemo 5 Menu
48 * Moved Active/All filter to menu
49 * Moved Checkout All to menu
50 * Improved Search bar
51 * Removed unnesary UI elements
52 * Switched to real inconsistent check boxes for tasks
53 * Switching the settings dialog to be more Maemo 5 like
54
55 0.3.1
56 * I18N, extract de.po, add ru.po.
57
58 0.3.0
59 * Initial Release.
60 """
61
62
63 __postinstall__ = """#!/bin/sh -e
64
65 gtk-update-icon-cache -f /usr/share/icons/hicolor
66 rm -f ~/.multilist/multilist.log
67 """
68
69
70 def find_files(path, root):
71         print path, root
72         for unusedRoot, dirs, files in os.walk(path):
73                 for file in files:
74                         if file.startswith(root+"-"):
75                                 print "\t", root, file
76                                 fileParts = file.split("-")
77                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
78                                 assert unused == root
79                                 relPath = os.sep.join(relPathParts)
80                                 yield relPath, file, newName
81
82
83 def unflatten_files(files):
84         d = {}
85         for relPath, oldName, newName in files:
86                 if relPath not in d:
87                         d[relPath] = []
88                 d[relPath].append((oldName, newName))
89         return d
90
91
92 def build_package(distribution):
93         try:
94                 os.chdir(os.path.dirname(sys.argv[0]))
95         except:
96                 pass
97
98         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
99         p = py2deb.Py2deb(__appname__)
100         p.prettyName = constants.__pretty_app_name__
101         p.description = __description__
102         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Multilist"
103         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
104         p.author = __author__
105         p.mail = __email__
106         p.license = "gpl"
107         p.depends = ", ".join([
108                 "python2.6 | python2.5",
109                 "python-gtk2 | python2.5-gtk2",
110                 "python-xml | python2.5-xml",
111                 "python-dbus | python2.5-dbus",
112         ])
113         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
114         p.depends += {
115                 "debian": ", python-glade2",
116                 "diablo": maemoSpecificDepends,
117                 "fremantle": maemoSpecificDepends + ", python-glade2",
118         }[distribution]
119         p.section = {
120                 "debian": "editors",
121                 "diablo": "user/office",
122                 "fremantle": "user/office",
123         }[distribution]
124         p.arch = "all"
125         p.urgency = "low"
126         p.distribution = "diablo fremantle debian"
127         p.repository = "extras"
128         p.changelog = __changelog__
129         p.postinstall = __postinstall__
130         p.icon = {
131                 "debian": "26x26-multilist.png",
132                 "diablo": "26x26-multilist.png",
133                 "fremantle": "40x40-multilist.png", # Fremantle natively uses 48x48
134         }[distribution]
135         p["/usr/bin"] = [ "multilist.py" ]
136         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
137                 fullPath = "/usr/share/locale"
138                 if relPath:
139                         fullPath += os.sep+relPath
140                 p[fullPath] = list(
141                         "|".join((oldName, newName))
142                         for (oldName, newName) in files
143                 )
144         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
145                 fullPath = "/usr/lib/multilist"
146                 if relPath:
147                         fullPath += os.sep+relPath
148                 p[fullPath] = list(
149                         "|".join((oldName, newName))
150                         for (oldName, newName) in files
151                 )
152         p["/usr/share/applications/hildon"] = ["multilist.desktop"]
153         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-multilist.png|multilist.png"]
154         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-multilist.png|multilist.png"]
155         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-multilist.png|multilist.png"]
156
157         if distribution == "debian":
158                 print p
159                 print p.generate(
160                         version="%s-%s" % (__version__, __build__),
161                         changelog=__changelog__,
162                         build=True,
163                         tar=False,
164                         changes=False,
165                         dsc=False,
166                 )
167                 print "Building for %s finished" % distribution
168         else:
169                 print p
170                 print p.generate(
171                         version="%s-%s" % (__version__, __build__),
172                         changelog=__changelog__,
173                         build=False,
174                         tar=True,
175                         changes=True,
176                         dsc=True,
177                 )
178                 print "Building for %s finished" % distribution
179
180
181 if __name__ == "__main__":
182         if len(sys.argv) > 1:
183                 try:
184                         import optparse
185                 except ImportError:
186                         optparse = None
187
188                 if optparse is not None:
189                         parser = optparse.OptionParser()
190                         (commandOptions, commandArgs) = parser.parse_args()
191         else:
192                 commandArgs = None
193                 commandArgs = ["diablo"]
194         build_package(commandArgs[0])