Fixed bug with Move To Category
[quicknote] / 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 note taking application in a similar vein as PalmOS Memos
16 .
17 Homepage: http://quicknote.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.7.9
25  * UI Tweak: Removed "New Note..." due to weirdness and duplicated behavior
26  * Bugfix: Move To Category
27
28 0.7.8
29  * Spell checking
30  * Fixing the application title
31  * Fremantle Support
32  * Ctrl+i and Ctrl+o to zoom in/out the interface
33  * Ctrl+enter to fullscreen app
34  * Ctrl+l to copy to clipboard the application debug log
35
36 0.7.7
37  * Slight modifications to the note history and SQL dialogs
38  * On zoom, also hiding the history status and button
39  * Touched up the note list, making it ellipsize at the end rather than scroll
40  * Storing of zoom, wordwrap, and fullscreen settings
41
42 0.7.6
43   * Line-wrap
44   * Zoom
45
46 0.7.4
47   * fixed small bugs
48   * move category
49
50 0.7.3
51   * fixed small bugs
52   * move category
53
54 0.7.2
55   * improved sync, fixed a small bug
56
57 0.7.1
58   * improved sync
59
60 0.7.0
61   * Initial Release.
62 """
63
64
65 __postinstall__ = """#!/bin/sh -e
66
67 gtk-update-icon-cache -f /usr/share/icons/hicolor
68 rm -f ~/.quicknote/quicknote.log
69 """
70
71
72 def find_files(path, root):
73         print path, root
74         for unusedRoot, dirs, files in os.walk(path):
75                 for file in files:
76                         if file.startswith(root+"-"):
77                                 print "\t", root, file
78                                 fileParts = file.split("-")
79                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
80                                 assert unused == root
81                                 relPath = os.sep.join(relPathParts)
82                                 yield relPath, file, newName
83
84
85 def unflatten_files(files):
86         d = {}
87         for relPath, oldName, newName in files:
88                 if relPath not in d:
89                         d[relPath] = []
90                 d[relPath].append((oldName, newName))
91         return d
92
93
94 def build_package(distribution):
95         try:
96                 os.chdir(os.path.dirname(sys.argv[0]))
97         except:
98                 pass
99
100         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
101         p = py2deb.Py2deb(__appname__)
102         p.prettyName = constants.__pretty_app_name__
103         p.description = __description__
104         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=quicknote"
105         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
106         p.author = __author__
107         p.mail = __email__
108         p.license = "gpl"
109         p.depends = ", ".join([
110                 "python2.6 | python2.5",
111                 "python-gtk2 | python2.5-gtk2",
112                 "python-xml | python2.5-xml",
113         ])
114         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
115         p.depends += {
116                 "debian": ", python-glade2",
117                 "chinook": maemoSpecificDepends,
118                 "diablo": maemoSpecificDepends,
119                 "fremantle": maemoSpecificDepends + ", python-glade2",
120                 "mer": maemoSpecificDepends + ", python-glade2",
121         }[distribution]
122         p.section = {
123                 "debian": "accessories",
124                 "chinook": "accessories",
125                 "diablo": "user/office",
126                 "fremantle": "user/office",
127                 "mer": "user/office",
128         }[distribution]
129         p.arch = "all"
130         p.urgency = "low"
131         p.distribution = "chinook diablo fremantle mer debian"
132         p.repository = "extras"
133         p.changelog = __changelog__
134         p.postinstall = __postinstall__
135         p.icon = {
136                 "debian": "26x26-quicknote.png",
137                 "chinook": "26x26-quicknote.png",
138                 "diablo": "26x26-quicknote.png",
139                 "fremantle": "48x48-quicknote.png", # Fremantle natively uses 48x48
140                 "mer": "48x48-quicknote.png",
141         }[distribution]
142         p["/usr/bin"] = [ "quicknote.py" ]
143         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
144                 fullPath = "/usr/share/locale"
145                 if relPath:
146                         fullPath += os.sep+relPath
147                 p[fullPath] = list(
148                         "|".join((oldName, newName))
149                         for (oldName, newName) in files
150                 )
151         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
152                 fullPath = "/usr/lib/quicknote"
153                 if relPath:
154                         fullPath += os.sep+relPath
155                 p[fullPath] = list(
156                         "|".join((oldName, newName))
157                         for (oldName, newName) in files
158                 )
159         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
160         #p["/usr/share/dbus-1/services"] = ["quicknote.service"]
161         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-quicknote.png|quicknote.png"]
162         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-quicknote.png|quicknote.png"]
163         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-quicknote.png|quicknote.png"]
164         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-quicknote.png|quicknote.png"]
165
166         print p
167         print p.generate(
168                 version="%s-%s" % (__version__, __build__),
169                 changelog=__changelog__,
170                 build=False,
171                 tar=True,
172                 changes=True,
173                 dsc=True,
174         )
175         print "Building for %s finished" % distribution
176
177
178 if __name__ == "__main__":
179         if len(sys.argv) > 1:
180                 try:
181                         import optparse
182                 except ImportError:
183                         optparse = None
184
185                 if optparse is not None:
186                         parser = optparse.OptionParser()
187                         (commandOptions, commandArgs) = parser.parse_args()
188         else:
189                 commandArgs = None
190                 commandArgs = ["diablo"]
191         build_package(commandArgs[0])