Removing chinook and mer
[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 .
17 RPN: Stack based math, come on it is fun
18 .
19 Pie Menus: Press them or press-drag them
20 .
21 History: Its such a drag, so drag them around, delete them, etc
22 .
23 Homepage: http://ejpi.garage.maemo.org/
24 """
25 __author__ = "Ed Page"
26 __email__ = "eopage@byu.net"
27 __version__ = constants.__version__
28 __build__ = constants.__build__
29 __changelog__ = """
30 0.9.8
31 * Fixing log support
32
33 0.9.7
34 * Added shortcut to copy result
35 * Shortcuts: Backspace - as expected, Ctrl+Backspace - unpops, Enter - pops
36 * BugFix: Attempt two at bigger X button
37 * Bugfix: Inconsistent location of pie items on the computer section
38 * Added support for creating .deb generic linux package files
39
40 0.9.6
41 * Fullscreen by Ctrl+Enter
42 * "Enter" in number entry causes a push
43 * Reversed stack order to be more proper
44 * Logging support, Ctrl+l to copy the log
45 * Fremantle Support
46
47 0.9.4
48  * Added icons
49  * Minor improvements
50  * Swapping the keyboard positions, seem more friendly to my thumb location this way
51
52 0.9.3 - ""
53  * Added +/-, !, sq, and sqrt functions
54  * Improved Documentation
55  * Copy of calculation result and the corresponding equation
56  * Bug fixes
57
58 0.9.2 - ""
59  * Experimenting with faster startup by including pyc files in package
60  * Minor tweaks and bug fixes
61
62 0.9.1 - "Laziness doesn't always pay off"
63  * Profiled the code with an especial focus on the pie menus
64  * Tried to reduce potential bugs with double clicks
65  * Fixed a visual artifact issue on popup
66
67 0.9.0 - "Feed is for horses, so what about feedback?"
68  * Initial public release
69  * Pie menus for keys
70  * Modifiable history
71  * Supports different number types and bases
72  * Basic trig support
73 """
74
75
76 __postinstall__ = """#!/bin/sh -e
77
78 gtk-update-icon-cache -f /usr/share/icons/hicolor
79 rm -f ~/.ejpi/ejpi.log
80 """
81
82
83 def find_files(path):
84         for root, dirs, files in os.walk(path):
85                 for file in files:
86                         if file.startswith("src-"):
87                                 fileParts = file.split("-")
88                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
89                                 assert unused == "src"
90                                 relPath = os.sep.join(relPathParts)
91                                 yield relPath, file, newName
92
93
94 def unflatten_files(files):
95         d = {}
96         for relPath, oldName, newName in files:
97                 if relPath not in d:
98                         d[relPath] = []
99                 d[relPath].append((oldName, newName))
100         return d
101
102
103 def build_package(distribution):
104         try:
105                 os.chdir(os.path.dirname(sys.argv[0]))
106         except:
107                 pass
108
109         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
110         p = py2deb.Py2deb(__appname__)
111         p.prettyName = constants.__pretty_app_name__
112         p.description = __description__
113         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=ejpi"
114         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
115         p.author = __author__
116         p.mail = __email__
117         p.license = "lgpl"
118         p.depends = ", ".join([
119                 "python2.6 | python2.5",
120                 "python-gtk2 | python2.5-gtk2",
121                 "python-xml | python2.5-xml",
122                 "python-dbus | python2.5-dbus",
123         ])
124         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
125         p.depends += {
126                 "debian": ", python-glade2",
127                 "diablo": maemoSpecificDepends,
128                 "fremantle": maemoSpecificDepends + ", python-glade2",
129         }[distribution]
130         p.section = {
131                 "debian": "math",
132                 "diablo": "user/science",
133                 "fremantle": "user/science",
134         }[distribution]
135         p.arch = "all"
136         p.urgency = "low"
137         p.distribution = "diablo fremantle debian"
138         p.repository = "extras"
139         p.changelog = __changelog__
140         p.postinstall = __postinstall__
141         p.icon = {
142                 "debian": "26x26-ejpi.png",
143                 "diablo": "26x26-ejpi.png",
144                 "fremantle": "64x64-ejpi.png", # Fremantle natively uses 48x48
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])