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