Cleaning up the import style
[ejpi] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 import os
4 import sys
5
6 import py2deb
7
8 import constants
9
10
11 __appname__ = constants.__app_name__
12 __description__ = "A Touch Screen Optimized RPN Calculator using Pie Menus"
13 __author__ = "Ed Page"
14 __email__ = "eopage@byu.net"
15 __version__ = constants.__version__
16 __build__ = 0
17 __changelog__ = '''
18 0.9.4
19  * Added icons
20  * Minor improvements
21  * Swapping the keyboard positions, seem more friendly to my thumb location this way
22
23 0.9.3 - ""
24  * Added +/-, !, sq, and sqrt functions
25  * Improved Documentation
26  * Copy of calculation result and the corresponding equation
27  * Bug fixes
28
29 0.9.2 - ""
30  * Experimenting with faster startup by including pyc files in package
31  * Minor tweaks and bug fixes
32
33 0.9.1 - "Laziness doesn't always pay off"
34  * Profiled the code with an especial focus on the pie menus
35  * Tried to reduce potential bugs with double clicks
36  * Fixed a visual artifact issue on popup
37
38 0.9.0 - "Feed is for horses, so what about feedback?"
39  * Initial public release
40  * Pie menus for keys
41  * Modifiable history
42  * Supports different number types and bases
43  * Basic trig support
44 '''
45
46
47 __postinstall__ = '''#!/bin/sh
48
49 gtk-update-icon-cache /usr/share/icons/hicolor
50 '''
51
52
53 def find_files(path):
54         for root, dirs, files in os.walk(path):
55                 for file in files:
56                         if file.startswith("src-"):
57                                 fileParts = file.split("-")
58                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
59                                 assert unused == "src"
60                                 relPath = os.sep.join(relPathParts)
61                                 yield relPath, file, newName
62
63
64 def unflatten_files(files):
65         d = {}
66         for relPath, oldName, newName in files:
67                 if relPath not in d:
68                         d[relPath] = []
69                 d[relPath].append((oldName, newName))
70         return d
71
72
73 if __name__ == "__main__":
74         try:
75                 os.chdir(os.path.dirname(sys.argv[0]))
76         except:
77                 pass
78
79         p = py2deb.Py2deb(__appname__)
80         p.description = __description__
81         p.author = __author__
82         p.mail = __email__
83         p.license = "lgpl"
84         p.depends = "python2.5, python2.5-gtk2"
85         p.section = "user/accessories"
86         p.arch = "all"
87         p.urgency = "low"
88         p.distribution = "chinook diablo"
89         p.repository = "extras"
90         p.changelog = __changelog__
91         p.postinstall = __postinstall__
92         p.icon="26x26-ejpi.png"
93         p["/usr/bin"] = [ "ejpi.py" ]
94         for relPath, files in unflatten_files(find_files(".")).iteritems():
95                 fullPath = "/usr/lib/ejpi"
96                 if relPath:
97                         fullPath += os.sep+relPath
98                 p[fullPath] = list(
99                         "|".join((oldName, newName))
100                         for (oldName, newName) in files
101                 )
102         p["/usr/share/applications/hildon"] = ["ejpi.desktop"]
103         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-ejpi.png|ejpi.png"]
104         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-ejpi.png|ejpi.png"]
105
106         print p
107         print p.generate(
108                 __version__, __build__, changelog=__changelog__,
109                 tar=True, dsc=True, changes=True, build=False, src=True
110         )