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