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