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