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