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