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