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