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