Setting up support for branches and tags
[quicknote] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 import os
4
5 try:
6         import py2deb
7 except ImportError:
8         import fake_py2deb as py2deb
9
10
11 __appname__ = "quicknote"
12 __description__ = "Simple note taking application in a similar vein as PalmOS Memos"
13 __author__ = "Christoph Wurstle"
14 __email__ = "n800@axique.net"
15 __version__ = "0.7.6"
16 __build__ = 1
17 __changelog__ = '''\
18 0.7.6
19   * Line-wrap
20   * Zoom
21
22 0.7.4
23   * fixed small bugs
24   * move category
25
26 0.7.3
27   * fixed small bugs
28   * move category
29
30 0.7.2
31   * improved sync, fixed a small bug
32
33 0.7.1
34   * improved sync
35
36 0.7.0
37   * Initial Release.
38 '''
39
40
41 __postinstall__ = '''#!/bin/sh -e
42
43 gtk-update-icon-cache -f /usr/share/icons/hicolor
44 exit 0
45 '''
46
47
48 def find_files(path, root):
49         print path, root
50         for unusedRoot, dirs, files in os.walk(path):
51                 for file in files:
52                         if file.startswith(root+"-"):
53                                 print "\t", root, file
54                                 fileParts = file.split("-")
55                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
56                                 assert unused == root
57                                 relPath = os.sep.join(relPathParts)
58                                 yield relPath, file, newName
59
60
61 def unflatten_files(files):
62         d = {}
63         for relPath, oldName, newName in files:
64                 if relPath not in d:
65                         d[relPath] = []
66                 d[relPath].append((oldName, newName))
67         return d
68
69
70 if __name__ == "__main__":
71         try:
72                 os.chdir(os.path.dirname(sys.argv[0]))
73         except:
74                 pass
75
76         p = py2deb.Py2deb(__appname__)
77         p.description = __description__
78         p.author = __author__
79         p.mail = __email__
80         p.license = "lgpl"
81         p.depends = "python2.5, python2.5-gtk2"
82         p.section = "user/other"
83         p.arch = "all"
84         p.urgency = "low"
85         p.distribution = "chinook diablo"
86         p.repository = "extras-devel"
87         p.changelog = __changelog__
88         p.postinstall = __postinstall__
89         p.icon = "26x26-quicknote.png"
90         p["/usr/bin"] = [ "quicknote.py" ]
91         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
92                 fullPath = "/usr/share/locale"
93                 if relPath:
94                         fullPath += os.sep+relPath
95                 p[fullPath] = list(
96                         "|".join((oldName, newName))
97                         for (oldName, newName) in files
98                 )
99         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
100                 fullPath = "/usr/lib/quicknote"
101                 if relPath:
102                         fullPath += os.sep+relPath
103                 p[fullPath] = list(
104                         "|".join((oldName, newName))
105                         for (oldName, newName) in files
106                 )
107         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
108         p["/usr/share/dbus-1/services"] = ["quicknote.service"]
109         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-quicknote.png|quicknote.png"]
110         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-quicknote.png|quicknote.png"]
111         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-quicknote.png|quicknote.png"]
112         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-quicknote.png|quicknote.png"]
113
114         print p
115         print p.generate(
116                 __version__, __build__, changelog=__changelog__,
117                 tar=True, dsc=True, changes=True, build=False, src=True
118         )