Pulling in skeleton changes
[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.author = __author__
69         p.mail = __email__
70         p.license = "gpl"
71         p.depends = ", ".join([
72                 "python2.6 | python2.5",
73                 "python-gtk2 | python2.5-gtk2",
74                 "python-xml | python2.5-xml",
75                 "python-dbus | python2.5-dbus",
76         ])
77         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
78         p.depends += {
79                 "debian": ", python-glade2",
80                 "diablo": maemoSpecificDepends,
81                 "fremantle": maemoSpecificDepends + ", python-glade2",
82         }[distribution]
83         p.section = {
84                 "debian": "editors",
85                 "diablo": "user/office",
86                 "fremantle": "user/office",
87         }[distribution]
88         p.arch = "all"
89         p.urgency = "low"
90         p.distribution = "diablo fremantle debian"
91         p.repository = "extras"
92         p.changelog = __changelog__
93         p.postinstall = __postinstall__
94         p.icon = {
95                 "debian": "24_quicknote.png",
96                 "diablo": "32_quicknote.png",
97                 "fremantle": "48_quicknote.png", # Fremantle natively uses 48x48
98         }[distribution]
99         p["/usr/bin"] = [ "quicknote.py" ]
100         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
101                 fullPath = "/usr/share/locale"
102                 if relPath:
103                         fullPath += os.sep+relPath
104                 p[fullPath] = list(
105                         "|".join((oldName, newName))
106                         for (oldName, newName) in files
107                 )
108         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
109                 fullPath = "/usr/lib/quicknote"
110                 if relPath:
111                         fullPath += os.sep+relPath
112                 p[fullPath] = list(
113                         "|".join((oldName, newName))
114                         for (oldName, newName) in files
115                 )
116         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
117         p["/usr/share/icons/hicolor/24x24/hildon"] = ["24_quicknote.png|quicknote.png"]
118         p["/usr/share/icons/hicolor/32x32/hildon"] = ["32_quicknote.png|quicknote.png"]
119         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48_quicknote.png|quicknote.png"]
120         p["/usr/share/icons/hicolor/72x72/hildon"] = ["72_quicknote.png|quicknote.png"]
121
122         if distribution == "debian":
123                 print p
124                 print p.generate(
125                         version="%s-%s" % (__version__, __build__),
126                         changelog=__changelog__,
127                         build=True,
128                         tar=False,
129                         changes=False,
130                         dsc=False,
131                 )
132                 print "Building for %s finished" % distribution
133         else:
134                 print p
135                 print p.generate(
136                         version="%s-%s" % (__version__, __build__),
137                         changelog=__changelog__,
138                         build=False,
139                         tar=True,
140                         changes=True,
141                         dsc=True,
142                 )
143                 print "Building for %s finished" % distribution
144
145
146 if __name__ == "__main__":
147         if len(sys.argv) > 1:
148                 try:
149                         import optparse
150                 except ImportError:
151                         optparse = None
152
153                 if optparse is not None:
154                         parser = optparse.OptionParser()
155                         (commandOptions, commandArgs) = parser.parse_args()
156         else:
157                 commandArgs = None
158                 commandArgs = ["diablo"]
159         build_package(commandArgs[0])