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