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