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