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