Fixing the map, adding some shortcut keys
[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.7
28 * Added shortcut to copy result
29 * Shortcuts: Backspace - as expected, Ctrl+Backspace - unpops, Enter - pops
30 * BugFix: Attempt two at bigger X button
31 * Bugfix: Inconsistent location of pie items on the computer section
32 * Added support for creating .deb generic linux package files
33
34 0.9.6
35 * Fullscreen by Ctrl+Enter
36 * "Enter" in number entry causes a push
37 * Reversed stack order to be more proper
38 * Logging support, Ctrl+l to copy the log
39 * Fremantle Support
40
41 0.9.4
42  * Added icons
43  * Minor improvements
44  * Swapping the keyboard positions, seem more friendly to my thumb location this way
45
46 0.9.3 - ""
47  * Added +/-, !, sq, and sqrt functions
48  * Improved Documentation
49  * Copy of calculation result and the corresponding equation
50  * Bug fixes
51
52 0.9.2 - ""
53  * Experimenting with faster startup by including pyc files in package
54  * Minor tweaks and bug fixes
55
56 0.9.1 - "Laziness doesn't always pay off"
57  * Profiled the code with an especial focus on the pie menus
58  * Tried to reduce potential bugs with double clicks
59  * Fixed a visual artifact issue on popup
60
61 0.9.0 - "Feed is for horses, so what about feedback?"
62  * Initial public release
63  * Pie menus for keys
64  * Modifiable history
65  * Supports different number types and bases
66  * Basic trig support
67 """
68
69
70 __postinstall__ = """#!/bin/sh -e
71
72 gtk-update-icon-cache -f /usr/share/icons/hicolor
73 rm -f ~/.ejpi/ejpi.log
74 """
75
76
77 def find_files(path):
78         for root, dirs, files in os.walk(path):
79                 for file in files:
80                         if file.startswith("src-"):
81                                 fileParts = file.split("-")
82                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
83                                 assert unused == "src"
84                                 relPath = os.sep.join(relPathParts)
85                                 yield relPath, file, newName
86
87
88 def unflatten_files(files):
89         d = {}
90         for relPath, oldName, newName in files:
91                 if relPath not in d:
92                         d[relPath] = []
93                 d[relPath].append((oldName, newName))
94         return d
95
96
97 def build_package(distribution):
98         try:
99                 os.chdir(os.path.dirname(sys.argv[0]))
100         except:
101                 pass
102
103         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
104         p = py2deb.Py2deb(__appname__)
105         p.prettyName = constants.__pretty_app_name__
106         p.description = __description__
107         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=ejpi"
108         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
109         p.author = __author__
110         p.mail = __email__
111         p.license = "lgpl"
112         p.depends = ", ".join([
113                 "python2.6 | python2.5",
114                 "python-gtk2 | python2.5-gtk2",
115                 "python-xml | python2.5-xml",
116                 "python-dbus | python2.5-dbus",
117         ])
118         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
119         p.depends += {
120                 "debian": ", python-glade2",
121                 "chinook": maemoSpecificDepends,
122                 "diablo": maemoSpecificDepends,
123                 "fremantle": maemoSpecificDepends + ", python-glade2",
124                 "mer": maemoSpecificDepends + ", python-glade2",
125         }[distribution]
126         p.section = {
127                 "debian": "math",
128                 "chinook": "accessories",
129                 "diablo": "user/science",
130                 "fremantle": "user/science",
131                 "mer": "user/science",
132         }[distribution]
133         p.arch = "all"
134         p.urgency = "low"
135         p.distribution = "chinook diablo fremantle mer debian"
136         p.repository = "extras"
137         p.changelog = __changelog__
138         p.postinstall = __postinstall__
139         p.icon = {
140                 "debian": "26x26-ejpi.png",
141                 "chinook": "26x26-ejpi.png",
142                 "diablo": "26x26-ejpi.png",
143                 "fremantle": "64x64-ejpi.png", # Fremantle natively uses 48x48
144                 "mer": "64x64-ejpi.png",
145         }[distribution]
146         p["/usr/bin"] = [ "ejpi.py" ]
147         for relPath, files in unflatten_files(find_files(".")).iteritems():
148                 fullPath = "/usr/lib/ejpi"
149                 if relPath:
150                         fullPath += os.sep+relPath
151                 p[fullPath] = list(
152                         "|".join((oldName, newName))
153                         for (oldName, newName) in files
154                 )
155         p["/usr/share/applications/hildon"] = ["ejpi.desktop"]
156         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-ejpi.png|ejpi.png"]
157         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-ejpi.png|ejpi.png"]
158         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-ejpi.png|ejpi.png"]
159
160         if distribution == "debian":
161                 print p
162                 print p.generate(
163                         version="%s-%s" % (__version__, __build__),
164                         changelog=__changelog__,
165                         build=True,
166                         tar=False,
167                         changes=False,
168                         dsc=False,
169                 )
170                 print "Building for %s finished" % distribution
171         else:
172                 print p
173                 print p.generate(
174                         version="%s-%s" % (__version__, __build__),
175                         changelog=__changelog__,
176                         build=False,
177                         tar=True,
178                         changes=True,
179                         dsc=True,
180                 )
181                 print "Building for %s finished" % distribution
182
183
184 if __name__ == "__main__":
185         if len(sys.argv) > 1:
186                 try:
187                         import optparse
188                 except ImportError:
189                         optparse = None
190
191                 if optparse is not None:
192                         parser = optparse.OptionParser()
193                         (commandOptions, commandArgs) = parser.parse_args()
194         else:
195                 commandArgs = None
196                 commandArgs = ["diablo"]
197         build_package(commandArgs[0])