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