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