summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-21 14:08:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-22 09:05:39 +0000
commitfdb52ade904e2d6c379f7f6859eef7dba26874b6 (patch)
treedd4088bc798d02efd3dccbf543fb293dfd4b70f0 /meta/classes
parent53a3c5877458678732e43ec92798f0b3f6f9bac6 (diff)
downloadpoky-fdb52ade904e2d6c379f7f6859eef7dba26874b6.tar.gz
package_deb: Clean up pointless exception handling
The exception handling in this function seemed mildly crazy. Python will given perfectly good or in several cases better information if we let its standard traceback/exception handling happen. Remove the pointless code along with the duplicated key checking which was broken in the inner loop by usage of the wrong variable. (From OE-Core rev: f755b07b528e828618141eda402399d791efba4a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/package_deb.bbclass73
1 files changed, 26 insertions, 47 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 2a70b50c9f..47fcd6b8b5 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -53,6 +53,7 @@ python do_package_deb () {
53 import textwrap 53 import textwrap
54 import subprocess 54 import subprocess
55 import collections 55 import collections
56 import codecs
56 57
57 oldcwd = os.getcwd() 58 oldcwd = os.getcwd()
58 59
@@ -121,12 +122,8 @@ python do_package_deb () {
121 controldir = os.path.join(root, 'DEBIAN') 122 controldir = os.path.join(root, 'DEBIAN')
122 bb.utils.mkdirhier(controldir) 123 bb.utils.mkdirhier(controldir)
123 os.chmod(controldir, 0o755) 124 os.chmod(controldir, 0o755)
124 try: 125
125 import codecs 126 ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8')
126 ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8')
127 except OSError:
128 bb.utils.unlockfile(lf)
129 bb.fatal("unable to open control file for writing")
130 127
131 fields = [] 128 fields = []
132 pe = d.getVar('PKGE') 129 pe = d.getVar('PKGE')
@@ -153,7 +150,7 @@ python do_package_deb () {
153 for i in l: 150 for i in l:
154 data = d.getVar(i) 151 data = d.getVar(i)
155 if data is None: 152 if data is None:
156 raise KeyError(f) 153 raise KeyError(i)
157 if i == 'DPKG_ARCH' and d.getVar('PACKAGE_ARCH') == 'all': 154 if i == 'DPKG_ARCH' and d.getVar('PACKAGE_ARCH') == 'all':
158 data = 'all' 155 data = 'all'
159 elif i == 'PACKAGE_ARCH' or i == 'DPKG_ARCH': 156 elif i == 'PACKAGE_ARCH' or i == 'DPKG_ARCH':
@@ -168,36 +165,26 @@ python do_package_deb () {
168 if d.getVar('PACKAGE_ARCH') == "all": 165 if d.getVar('PACKAGE_ARCH') == "all":
169 ctrlfile.write("Multi-Arch: foreign\n") 166 ctrlfile.write("Multi-Arch: foreign\n")
170 # check for required fields 167 # check for required fields
171 try: 168 for (c, fs) in fields:
172 for (c, fs) in fields: 169 # Special behavior for description...
173 for f in fs: 170 if 'DESCRIPTION' in fs:
174 if localdata.getVar(f, False) is None: 171 summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "."
175 raise KeyError(f) 172 ctrlfile.write('Description: %s\n' % summary)
176 # Special behavior for description... 173 description = localdata.getVar('DESCRIPTION') or "."
177 if 'DESCRIPTION' in fs: 174 description = textwrap.dedent(description).strip()
178 summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "." 175 if '\\n' in description:
179 ctrlfile.write('Description: %s\n' % summary) 176 # Manually indent
180 description = localdata.getVar('DESCRIPTION') or "." 177 for t in description.split('\\n'):
181 description = textwrap.dedent(description).strip() 178 # We don't limit the width when manually indent, but we do
182 if '\\n' in description: 179 # need the textwrap.fill() to set the initial_indent and
183 # Manually indent 180 # subsequent_indent, so set a large width
184 for t in description.split('\\n'): 181 ctrlfile.write('%s\n' % textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '))
185 # We don't limit the width when manually indent, but we do 182 else:
186 # need the textwrap.fill() to set the initial_indent and 183 # Auto indent
187 # subsequent_indent, so set a large width 184 ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '))
188 ctrlfile.write('%s\n' % textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' ')) 185
189 else: 186 else:
190 # Auto indent 187 ctrlfile.write(c % tuple(pullData(fs, localdata)))
191 ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '))
192
193 else:
194 ctrlfile.write(c % tuple(pullData(fs, localdata)))
195 except KeyError:
196 import sys
197 (type, value, traceback) = sys.exc_info()
198 bb.utils.unlockfile(lf)
199 ctrlfile.close()
200 bb.fatal("Missing field for deb generation: %s" % value)
201 188
202 # more fields 189 # more fields
203 190
@@ -273,11 +260,7 @@ python do_package_deb () {
273 if not scriptvar: 260 if not scriptvar:
274 continue 261 continue
275 scriptvar = scriptvar.strip() 262 scriptvar = scriptvar.strip()
276 try: 263 scriptfile = open(os.path.join(controldir, script), 'w')
277 scriptfile = open(os.path.join(controldir, script), 'w')
278 except OSError:
279 bb.utils.unlockfile(lf)
280 bb.fatal("unable to open %s script file for writing" % script)
281 264
282 if scriptvar.startswith("#!"): 265 if scriptvar.startswith("#!"):
283 pos = scriptvar.find("\n") + 1 266 pos = scriptvar.find("\n") + 1
@@ -297,11 +280,7 @@ python do_package_deb () {
297 280
298 conffiles_str = ' '.join(get_conffiles(pkg, d)) 281 conffiles_str = ' '.join(get_conffiles(pkg, d))
299 if conffiles_str: 282 if conffiles_str:
300 try: 283 conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
301 conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
302 except OSError:
303 bb.utils.unlockfile(lf)
304 bb.fatal("unable to open conffiles for writing")
305 for f in conffiles_str.split(): 284 for f in conffiles_str.split():
306 if os.path.exists(oe.path.join(root, f)): 285 if os.path.exists(oe.path.join(root, f)):
307 conffiles.write('%s\n' % f) 286 conffiles.write('%s\n' % f)