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