Adding back in scrolling when using arrow keys in the units window
[gonvert] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 import os
4 import sys
5
6 import py2deb
7
8 import constants
9
10
11 __appname__ = constants.__app_name__
12 __description__ = """Unit Conversions
13 A conversion utility that allows conversion between many units like CGS, Ancient, Imperial with many categories like length, mass, numbers, etc. All units converted values shown at once as you type
14 .
15 Homepage: http://www.unihedron.com/projects/gonvert/index.php
16 """
17 __author__ = "Anthony Tekatch"
18 __email__ = "anthony@unihedron.com"
19 __version__ = constants.__version__
20 __build__ = constants.__build__
21 __changelog__ = """
22 * Adding back in scrolling when using arrow keys in Units Window
23 """.strip()
24
25
26 __postinstall__ = """#!/bin/sh -e
27
28 gtk-update-icon-cache -f /usr/share/icons/hicolor
29 rm -f ~/.gonvert/gonvert.log ~/.gonvert/selections.dat ~/.gonvert/window.dat
30 """
31
32 __preremove__ = """#!/bin/sh -e
33 """
34
35
36 def find_files(prefix, path):
37         for root, dirs, files in os.walk(path):
38                 for file in files:
39                         if file.startswith(prefix+"-"):
40                                 fileParts = file.split("-")
41                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
42                                 assert unused == prefix
43                                 relPath = os.sep.join(relPathParts)
44                                 yield relPath, file, newName
45
46
47 def unflatten_files(files):
48         d = {}
49         for relPath, oldName, newName in files:
50                 if relPath not in d:
51                         d[relPath] = []
52                 d[relPath].append((oldName, newName))
53         return d
54
55
56 def build_package(distribution):
57         try:
58                 os.chdir(os.path.dirname(sys.argv[0]))
59         except:
60                 pass
61
62         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
63         p = py2deb.Py2deb(__appname__)
64         p.prettyName = constants.__pretty_app_name__
65         p.description = __description__
66         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Gonvert"
67         p.author = __author__
68         p.mail = __email__
69         p.license = "gpl"
70         p.depends = ", ".join([
71                 "python2.6 | python2.5",
72                 "python-simplejson",
73         ])
74         p.depends += {
75                 "debian": ", python-qt4",
76                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
77                 "fremantle": ", python2.5-qt4-core, python2.5-qt4-gui, python2.5-qt4-maemo5",
78         }[distribution]
79         p.recommends = ", ".join([
80         ])
81         p.section = {
82                 "debian": "science",
83                 "diablo": "user/science",
84                 "fremantle": "user/science",
85         }[distribution]
86         p.arch = "all"
87         p.urgency = "low"
88         p.distribution = "diablo fremantle debian"
89         p.repository = "extras"
90         p.changelog = __changelog__
91         p.postinstall = __postinstall__
92         p.preremove = __preremove__
93         p.icon = {
94                 "debian": "data-pixmaps-gonvert.png",
95                 "diablo": "data-pixmaps-gonvert.png",
96                 "fremantle": "data-pixmaps-gonvert.png", # Fremantle natively uses 48x48
97         }[distribution]
98         p["/opt/gonvert/bin"] = [ "gonvert.py" ]
99         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
100                 fullPath = "/opt/gonvert/lib"
101                 if relPath:
102                         fullPath += os.sep+relPath
103                 p[fullPath] = list(
104                         "|".join((oldName, newName))
105                         for (oldName, newName) in files
106                 )
107         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
108                 fullPath = "/opt/gonvert/share"
109                 if relPath:
110                         fullPath += os.sep+relPath
111                 p[fullPath] = list(
112                         "|".join((oldName, newName))
113                         for (oldName, newName) in files
114                 )
115         p["/usr/share/applications/hildon"] = ["gonvert.desktop"]
116         p["/usr/share/icons/hicolor/26x26/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
117         p["/usr/share/icons/hicolor/64x64/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
118         p["/usr/share/icons/hicolor/scalable/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
119
120         if distribution == "debian":
121                 print p
122                 print p.generate(
123                         version="%s-%s" % (__version__, __build__),
124                         changelog=__changelog__,
125                         build=True,
126                         tar=False,
127                         changes=False,
128                         dsc=False,
129                 )
130                 print "Building for %s finished" % distribution
131         else:
132                 print p
133                 print p.generate(
134                         version="%s-%s" % (__version__, __build__),
135                         changelog=__changelog__,
136                         build=False,
137                         tar=True,
138                         changes=True,
139                         dsc=True,
140                 )
141                 print "Building for %s finished" % distribution
142
143
144 if __name__ == "__main__":
145         if len(sys.argv) > 1:
146                 try:
147                         import optparse
148                 except ImportError:
149                         optparse = None
150
151                 if optparse is not None:
152                         parser = optparse.OptionParser()
153                         (commandOptions, commandArgs) = parser.parse_args()
154         else:
155                 commandArgs = None
156                 commandArgs = ["diablo"]
157         build_package(commandArgs[0])