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