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