Fixing up the categories
[ejpi] / 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__ = """A Touch Screen Optimized RPN Calculator using Pie Menus
16 RPN: Stack based math, come on it is fun
17 Pie Menus: Press them or press-drag them
18 History: Its such a drag, so drag them around, delete them, etc
19 .
20 Homepage: http://ejpi.garage.maemo.org/
21 """
22 __author__ = "Ed Page"
23 __email__ = "eopage@byu.net"
24 __version__ = constants.__version__
25 __build__ = constants.__build__
26 __changelog__ = """
27 0.9.6
28 * Fullscreen by Ctrl+Enter
29 * "Enter" in number entry causes a push
30
31 0.9.4
32  * Added icons
33  * Minor improvements
34  * Swapping the keyboard positions, seem more friendly to my thumb location this way
35
36 0.9.3 - ""
37  * Added +/-, !, sq, and sqrt functions
38  * Improved Documentation
39  * Copy of calculation result and the corresponding equation
40  * Bug fixes
41
42 0.9.2 - ""
43  * Experimenting with faster startup by including pyc files in package
44  * Minor tweaks and bug fixes
45
46 0.9.1 - "Laziness doesn't always pay off"
47  * Profiled the code with an especial focus on the pie menus
48  * Tried to reduce potential bugs with double clicks
49  * Fixed a visual artifact issue on popup
50
51 0.9.0 - "Feed is for horses, so what about feedback?"
52  * Initial public release
53  * Pie menus for keys
54  * Modifiable history
55  * Supports different number types and bases
56  * Basic trig support
57 """
58
59
60 __postinstall__ = """#!/bin/sh -e
61
62 gtk-update-icon-cache -f /usr/share/icons/hicolor
63 """
64
65
66 def find_files(path):
67         for root, dirs, files in os.walk(path):
68                 for file in files:
69                         if file.startswith("src-"):
70                                 fileParts = file.split("-")
71                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
72                                 assert unused == "src"
73                                 relPath = os.sep.join(relPathParts)
74                                 yield relPath, file, newName
75
76
77 def unflatten_files(files):
78         d = {}
79         for relPath, oldName, newName in files:
80                 if relPath not in d:
81                         d[relPath] = []
82                 d[relPath].append((oldName, newName))
83         return d
84
85
86 def build_package(distribution):
87         try:
88                 os.chdir(os.path.dirname(sys.argv[0]))
89         except:
90                 pass
91
92         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
93         p = py2deb.Py2deb(__appname__)
94         p.prettyName = constants.__pretty_app_name__
95         p.description = __description__
96         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
97         p.author = __author__
98         p.mail = __email__
99         p.license = "lgpl"
100         p.depends = ", ".join([
101                 "python2.6 | python2.5",
102                 "python-gtk2 | python2.5-gtk2",
103                 "python-xml | python2.5-xml",
104         ])
105         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
106         p.depends += {
107                 "debian": ", python-glade2",
108                 "chinook": maemoSpecificDepends,
109                 "diablo": maemoSpecificDepends,
110                 "fremantle": maemoSpecificDepends + ", python-glade2",
111                 "mer": maemoSpecificDepends + ", python-glade2",
112         }[distribution]
113         p.section = {
114                 "debian": "accessories",
115                 "chinook": "accessories",
116                 "diablo": "user/science",
117                 "fremantle": "user/science",
118                 "mer": "user/science",
119         }[distribution]
120         p.arch = "all"
121         p.urgency = "low"
122         p.distribution = "chinook diablo fremantle mer debian"
123         p.repository = "extras"
124         p.changelog = __changelog__
125         p.postinstall = __postinstall__
126         p.icon = {
127                 "debian": "26x26-ejpi.png",
128                 "chinook": "26x26-ejpi.png",
129                 "diablo": "26x26-ejpi.png",
130                 "fremantle": "64x64-ejpi.png", # Fremantle natively uses 48x48
131                 "mer": "64x64-ejpi.png",
132         }[distribution]
133         p["/usr/bin"] = [ "ejpi.py" ]
134         for relPath, files in unflatten_files(find_files(".")).iteritems():
135                 fullPath = "/usr/lib/ejpi"
136                 if relPath:
137                         fullPath += os.sep+relPath
138                 p[fullPath] = list(
139                         "|".join((oldName, newName))
140                         for (oldName, newName) in files
141                 )
142         p["/usr/share/applications/hildon"] = ["ejpi.desktop"]
143         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-ejpi.png|ejpi.png"]
144         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-ejpi.png|ejpi.png"]
145         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-ejpi.png|ejpi.png"]
146
147         print p
148         print p.generate(
149                 version="%s-%s" % (__version__, __build__),
150                 changelog=__changelog__,
151                 build=False,
152                 tar=True,
153                 changes=True,
154                 dsc=True,
155         )
156         print "Building for %s finished" % distribution
157
158
159 if __name__ == "__main__":
160         if len(sys.argv) > 1:
161                 try:
162                         import optparse
163                 except ImportError:
164                         optparse = None
165
166                 if optparse is not None:
167                         parser = optparse.OptionParser()
168                         (commandOptions, commandArgs) = parser.parse_args()
169         else:
170                 commandArgs = None
171                 commandArgs = ["diablo"]
172         build_package(commandArgs[0])