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