Bump to 1.0.3
[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 RPN: Stack based math, come on it is fun
18 .
19 Pie Menus: Press them or press-drag them
20 .
21 History: Its such a drag, so drag them around, delete them, etc
22 .
23 Homepage: http://ejpi.garage.maemo.org/
24 """
25 __author__ = "Ed Page"
26 __email__ = "eopage@byu.net"
27 __version__ = constants.__version__
28 __build__ = constants.__build__
29 __changelog__ = """
30 * Cleaning up the display of the pie buttons
31 * Fixing the size of the pie menus on Maemo 5
32 * Adding rotation support with a custom portrait layout
33 * Minor UI Polish
34 """.strip()
35
36
37 __postinstall__ = """#!/bin/sh -e
38
39 gtk-update-icon-cache -f /usr/share/icons/hicolor
40 rm -f ~/.%(name)s/%(name)s.log
41 """ % {"name": constants.__app_name__}
42
43 __preremove__ = """#!/bin/sh -e
44 """
45
46
47 def find_files(prefix, path):
48         for root, dirs, files in os.walk(path):
49                 for file in files:
50                         if file.startswith(prefix+"-"):
51                                 fileParts = file.split("-")
52                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
53                                 assert unused == prefix
54                                 relPath = os.sep.join(relPathParts)
55                                 yield relPath, file, newName
56
57
58 def unflatten_files(files):
59         d = {}
60         for relPath, oldName, newName in files:
61                 if relPath not in d:
62                         d[relPath] = []
63                 d[relPath].append((oldName, newName))
64         return d
65
66
67 def build_package(distribution):
68         try:
69                 os.chdir(os.path.dirname(sys.argv[0]))
70         except:
71                 pass
72
73         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
74         p = py2deb.Py2deb(__appname__)
75         p.prettyName = constants.__pretty_app_name__
76         p.description = __description__
77         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=ejpi"
78         p.author = __author__
79         p.mail = __email__
80         p.license = "lgpl"
81         p.depends = ", ".join([
82                 "python2.6 | python2.5",
83         ])
84         p.depends += {
85                 "debian": ", python-qt4",
86                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
87                 "fremantle": ", python2.5-qt4-core, python2.5-qt4-gui, python2.5-qt4-maemo5",
88         }[distribution]
89         p.section = {
90                 "debian": "math",
91                 "diablo": "user/science",
92                 "fremantle": "user/science",
93         }[distribution]
94         p.arch = "all"
95         p.urgency = "low"
96         p.distribution = "diablo fremantle debian"
97         p.repository = "extras"
98         p.changelog = __changelog__
99         p.postinstall = __postinstall__
100         p.icon = {
101                 "debian": "26x26-ejpi.png",
102                 "diablo": "26x26-ejpi.png",
103                 "fremantle": "64x64-ejpi.png", # Fremantle natively uses 48x48
104         }[distribution]
105         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
106         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
107                 fullPath = "/opt/%s/lib" % __appname__
108                 if relPath:
109                         fullPath += os.sep+relPath
110                 p[fullPath] = list(
111                         "|".join((oldName, newName))
112                         for (oldName, newName) in files
113                 )
114         p["/usr/share/applications/hildon"] = ["%s.desktop" % __appname__]
115         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-ejpi.png|ejpi.png"]
116         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-ejpi.png|ejpi.png"]
117         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-ejpi.png|ejpi.png"]
118
119         if distribution == "debian":
120                 print p
121                 print p.generate(
122                         version="%s-%s" % (__version__, __build__),
123                         changelog=__changelog__,
124                         build=True,
125                         tar=False,
126                         changes=False,
127                         dsc=False,
128                 )
129                 print "Building for %s finished" % distribution
130         else:
131                 print p
132                 print p.generate(
133                         version="%s-%s" % (__version__, __build__),
134                         changelog=__changelog__,
135                         build=False,
136                         tar=True,
137                         changes=True,
138                         dsc=True,
139                 )
140                 print "Building for %s finished" % distribution
141
142
143 if __name__ == "__main__":
144         if len(sys.argv) > 1:
145                 try:
146                         import optparse
147                 except ImportError:
148                         optparse = None
149
150                 if optparse is not None:
151                         parser = optparse.OptionParser()
152                         (commandOptions, commandArgs) = parser.parse_args()
153         else:
154                 commandArgs = None
155                 commandArgs = ["diablo"]
156         build_package(commandArgs[0])