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