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