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