Bump to 0.7.12
[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 .
17 Homepage: http://quicknote.garage.maemo.org/
18 """
19 __author__ = "Christoph Wurstle"
20 __email__ = "n800@axique.net"
21 __version__ = constants.__version__
22 __build__ = constants.__build__
23 __changelog__ = """
24  * Small bugfix for launch
25  * Some code cleanup
26 """.strip()
27
28
29 __postinstall__ = """#!/bin/sh -e
30
31 gtk-update-icon-cache -f /usr/share/icons/hicolor
32 rm -f ~/.quicknote/quicknote.log
33 """
34
35
36 def find_files(path, root):
37         print path, root
38         for unusedRoot, dirs, files in os.walk(path):
39                 for file in files:
40                         if file.startswith(root+"-"):
41                                 print "\t", root, file
42                                 fileParts = file.split("-")
43                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
44                                 assert unused == root
45                                 relPath = os.sep.join(relPathParts)
46                                 yield relPath, file, newName
47
48
49 def unflatten_files(files):
50         d = {}
51         for relPath, oldName, newName in files:
52                 if relPath not in d:
53                         d[relPath] = []
54                 d[relPath].append((oldName, newName))
55         return d
56
57
58 def build_package(distribution):
59         try:
60                 os.chdir(os.path.dirname(sys.argv[0]))
61         except:
62                 pass
63
64         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
65         p = py2deb.Py2deb(__appname__)
66         p.prettyName = constants.__pretty_app_name__
67         p.description = __description__
68         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=quicknote"
69         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
70         p.author = __author__
71         p.mail = __email__
72         p.license = "gpl"
73         p.depends = ", ".join([
74                 "python2.6 | python2.5",
75                 "python-gtk2 | python2.5-gtk2",
76                 "python-xml | python2.5-xml",
77                 "python-dbus | python2.5-dbus",
78         ])
79         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
80         p.depends += {
81                 "debian": ", python-glade2",
82                 "diablo": maemoSpecificDepends,
83                 "fremantle": maemoSpecificDepends + ", python-glade2",
84         }[distribution]
85         p.section = {
86                 "debian": "editors",
87                 "diablo": "user/office",
88                 "fremantle": "user/office",
89         }[distribution]
90         p.arch = "all"
91         p.urgency = "low"
92         p.distribution = "diablo fremantle debian"
93         p.repository = "extras"
94         p.changelog = __changelog__
95         p.postinstall = __postinstall__
96         p.icon = {
97                 "debian": "26x26-quicknote.png",
98                 "diablo": "26x26-quicknote.png",
99                 "fremantle": "48x48-quicknote.png", # Fremantle natively uses 48x48
100         }[distribution]
101         p["/usr/bin"] = [ "quicknote.py" ]
102         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
103                 fullPath = "/usr/share/locale"
104                 if relPath:
105                         fullPath += os.sep+relPath
106                 p[fullPath] = list(
107                         "|".join((oldName, newName))
108                         for (oldName, newName) in files
109                 )
110         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
111                 fullPath = "/usr/lib/quicknote"
112                 if relPath:
113                         fullPath += os.sep+relPath
114                 p[fullPath] = list(
115                         "|".join((oldName, newName))
116                         for (oldName, newName) in files
117                 )
118         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
119         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-quicknote.png|quicknote.png"]
120         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-quicknote.png|quicknote.png"]
121         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-quicknote.png|quicknote.png"]
122         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-quicknote.png|quicknote.png"]
123
124         if distribution == "debian":
125                 print p
126                 print p.generate(
127                         version="%s-%s" % (__version__, __build__),
128                         changelog=__changelog__,
129                         build=True,
130                         tar=False,
131                         changes=False,
132                         dsc=False,
133                 )
134                 print "Building for %s finished" % distribution
135         else:
136                 print p
137                 print p.generate(
138                         version="%s-%s" % (__version__, __build__),
139                         changelog=__changelog__,
140                         build=False,
141                         tar=True,
142                         changes=True,
143                         dsc=True,
144                 )
145                 print "Building for %s finished" % distribution
146
147
148 if __name__ == "__main__":
149         if len(sys.argv) > 1:
150                 try:
151                         import optparse
152                 except ImportError:
153                         optparse = None
154
155                 if optparse is not None:
156                         parser = optparse.OptionParser()
157                         (commandOptions, commandArgs) = parser.parse_args()
158         else:
159                 commandArgs = None
160                 commandArgs = ["diablo"]
161         build_package(commandArgs[0])