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