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