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