8c2531f9b2244b26af468042d4da172699b58ab8
[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                 "chinook": maemoSpecificDepends,
134                 "diablo": maemoSpecificDepends,
135                 "fremantle": maemoSpecificDepends + ", python-glade2",
136                 "mer": maemoSpecificDepends + ", python-glade2",
137         }[distribution]
138         p.section = {
139                 "debian": "editors",
140                 "chinook": "accessories",
141                 "diablo": "user/office",
142                 "fremantle": "user/office",
143                 "mer": "user/office",
144         }[distribution]
145         p.arch = "all"
146         p.urgency = "low"
147         p.distribution = "chinook diablo fremantle mer debian"
148         p.repository = "extras"
149         p.changelog = __changelog__
150         p.postinstall = __postinstall__
151         p.icon = {
152                 "debian": "26x26-quicknote.png",
153                 "chinook": "26x26-quicknote.png",
154                 "diablo": "26x26-quicknote.png",
155                 "fremantle": "48x48-quicknote.png", # Fremantle natively uses 48x48
156                 "mer": "48x48-quicknote.png",
157         }[distribution]
158         p["/usr/bin"] = [ "quicknote.py" ]
159         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
160                 fullPath = "/usr/share/locale"
161                 if relPath:
162                         fullPath += os.sep+relPath
163                 p[fullPath] = list(
164                         "|".join((oldName, newName))
165                         for (oldName, newName) in files
166                 )
167         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
168                 fullPath = "/usr/lib/quicknote"
169                 if relPath:
170                         fullPath += os.sep+relPath
171                 p[fullPath] = list(
172                         "|".join((oldName, newName))
173                         for (oldName, newName) in files
174                 )
175         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
176         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-quicknote.png|quicknote.png"]
177         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-quicknote.png|quicknote.png"]
178         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-quicknote.png|quicknote.png"]
179         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-quicknote.png|quicknote.png"]
180
181         if distribution == "debian":
182                 print p
183                 print p.generate(
184                         version="%s-%s" % (__version__, __build__),
185                         changelog=__changelog__,
186                         build=True,
187                         tar=False,
188                         changes=False,
189                         dsc=False,
190                 )
191                 print "Building for %s finished" % distribution
192         else:
193                 print p
194                 print p.generate(
195                         version="%s-%s" % (__version__, __build__),
196                         changelog=__changelog__,
197                         build=False,
198                         tar=True,
199                         changes=True,
200                         dsc=True,
201                 )
202                 print "Building for %s finished" % distribution
203
204
205 if __name__ == "__main__":
206         if len(sys.argv) > 1:
207                 try:
208                         import optparse
209                 except ImportError:
210                         optparse = None
211
212                 if optparse is not None:
213                         parser = optparse.OptionParser()
214                         (commandOptions, commandArgs) = parser.parse_args()
215         else:
216                 commandArgs = None
217                 commandArgs = ["diablo"]
218         build_package(commandArgs[0])