3a2f7931b583c4c88b6719d733faf6cd8893f1bf
[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 __author__ = "Christoph Wurstle"
17 __email__ = "n800@axique.net"
18 __version__ = constants.__version__
19 __build__ = 0
20 __changelog__ = '''
21 0.7.8
22  * Spell checking
23  * Fixing the application title
24
25 0.7.7
26  * Slight modifications to the note history and SQL dialogs
27  * On zoom, also hiding the history status and button
28  * Touched up the note list, making it ellipsize at the end rather than scroll
29  * Storing of zoom, wordwrap, and fullscreen settings
30
31 0.7.6
32   * Line-wrap
33   * Zoom
34
35 0.7.4
36   * fixed small bugs
37   * move category
38
39 0.7.3
40   * fixed small bugs
41   * move category
42
43 0.7.2
44   * improved sync, fixed a small bug
45
46 0.7.1
47   * improved sync
48
49 0.7.0
50   * Initial Release.
51 '''
52
53
54 __postinstall__ = '''#!/bin/sh -e
55
56 gtk-update-icon-cache -f /usr/share/icons/hicolor
57 exit 0
58 '''
59
60
61 def find_files(path, root):
62         print path, root
63         for unusedRoot, dirs, files in os.walk(path):
64                 for file in files:
65                         if file.startswith(root+"-"):
66                                 print "\t", root, file
67                                 fileParts = file.split("-")
68                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
69                                 assert unused == root
70                                 relPath = os.sep.join(relPathParts)
71                                 yield relPath, file, newName
72
73
74 def unflatten_files(files):
75         d = {}
76         for relPath, oldName, newName in files:
77                 if relPath not in d:
78                         d[relPath] = []
79                 d[relPath].append((oldName, newName))
80         return d
81
82
83 def build_package(distribution):
84         try:
85                 os.chdir(os.path.dirname(sys.argv[0]))
86         except:
87                 pass
88
89         p = py2deb.Py2deb(__appname__)
90         p.description = __description__
91         p.author = __author__
92         p.mail = __email__
93         p.license = "lgpl"
94         p.depends = {
95                 "diablo": "python2.5, python2.5-gtk2",
96                 "mer": "python2.6, python-gtk2",
97         }[distribution]
98         p.section = "user/other"
99         p.arch = "all"
100         p.urgency = "low"
101         p.distribution = "chinook diablo fremantle mer"
102         p.repository = "extras"
103         p.changelog = __changelog__
104         p.postinstall = __postinstall__
105         p.icon = "26x26-quicknote.png"
106         p["/usr/bin"] = [ "quicknote.py" ]
107         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
108                 fullPath = "/usr/share/locale"
109                 if relPath:
110                         fullPath += os.sep+relPath
111                 p[fullPath] = list(
112                         "|".join((oldName, newName))
113                         for (oldName, newName) in files
114                 )
115         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
116                 fullPath = "/usr/lib/quicknote"
117                 if relPath:
118                         fullPath += os.sep+relPath
119                 p[fullPath] = list(
120                         "|".join((oldName, newName))
121                         for (oldName, newName) in files
122                 )
123         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
124         p["/usr/share/dbus-1/services"] = ["quicknote.service"]
125         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-quicknote.png|quicknote.png"]
126         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-quicknote.png|quicknote.png"]
127         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-quicknote.png|quicknote.png"]
128         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-quicknote.png|quicknote.png"]
129
130         print p
131         print p.generate(
132                 __version__, __build__, changelog=__changelog__,
133                 tar=True, dsc=True, changes=True, build=False, src=True
134         )
135         print "Building for %s finished" % distribution
136
137
138 if __name__ == "__main__":
139         if len(sys.argv) > 1:
140                 try:
141                         import optparse
142                 except ImportError:
143                         optparse = None
144
145                 if optparse is not None:
146                         parser = optparse.OptionParser()
147                         (commandOptions, commandArgs) = parser.parse_args()
148         else:
149                 commandArgs = None
150                 commandArgs = ["diablo"]
151         build_package(commandArgs[0])