summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-21 14:14:24 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-22 09:05:39 +0000
commit2628a65ffe9cd80a18b49b7821018cf42c31a2d4 (patch)
tree0cdc1759ea9c8d34dc91128bb93782308afe9803
parent596c9eff21ef1197cc72d1eb5e46308f7a10f874 (diff)
downloadpoky-2628a65ffe9cd80a18b49b7821018cf42c31a2d4.tar.gz
package_ipk: 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. (From OE-Core rev: 61390438aec4a1f9beb4d332821cc6cda82e0379) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/package_ipk.bbclass67
1 files changed, 24 insertions, 43 deletions
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 9fb128b82b..a76b23538e 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -104,11 +104,7 @@ python do_package_ipk () {
104 104
105 controldir = os.path.join(root, 'CONTROL') 105 controldir = os.path.join(root, 'CONTROL')
106 bb.utils.mkdirhier(controldir) 106 bb.utils.mkdirhier(controldir)
107 try: 107 ctrlfile = open(os.path.join(controldir, 'control'), 'w')
108 ctrlfile = open(os.path.join(controldir, 'control'), 'w')
109 except OSError:
110 bb.utils.unlockfile(lf)
111 bb.fatal("unable to open control file for writing")
112 108
113 fields = [] 109 fields = []
114 pe = d.getVar('PKGE') 110 pe = d.getVar('PKGE')
@@ -134,35 +130,28 @@ python do_package_ipk () {
134 130
135 ctrlfile.write("Package: %s\n" % pkgname) 131 ctrlfile.write("Package: %s\n" % pkgname)
136 # check for required fields 132 # check for required fields
137 try: 133 for (c, fs) in fields:
138 for (c, fs) in fields: 134 for f in fs:
139 for f in fs: 135 if localdata.getVar(f, False) is None:
140 if localdata.getVar(f, False) is None: 136 raise KeyError(f)
141 raise KeyError(f) 137 # Special behavior for description...
142 # Special behavior for description... 138 if 'DESCRIPTION' in fs:
143 if 'DESCRIPTION' in fs: 139 summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "."
144 summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "." 140 ctrlfile.write('Description: %s\n' % summary)
145 ctrlfile.write('Description: %s\n' % summary) 141 description = localdata.getVar('DESCRIPTION') or "."
146 description = localdata.getVar('DESCRIPTION') or "." 142 description = textwrap.dedent(description).strip()
147 description = textwrap.dedent(description).strip() 143 if '\\n' in description:
148 if '\\n' in description: 144 # Manually indent
149 # Manually indent 145 for t in description.split('\\n'):
150 for t in description.split('\\n'): 146 # We don't limit the width when manually indent, but we do
151 # We don't limit the width when manually indent, but we do 147 # need the textwrap.fill() to set the initial_indent and
152 # need the textwrap.fill() to set the initial_indent and 148 # subsequent_indent, so set a large width
153 # subsequent_indent, so set a large width 149 ctrlfile.write('%s\n' % textwrap.fill(t.strip(), width=100000, initial_indent=' ', subsequent_indent=' '))
154 ctrlfile.write('%s\n' % textwrap.fill(t.strip(), width=100000, initial_indent=' ', subsequent_indent=' '))
155 else:
156 # Auto indent
157 ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' '))
158 else: 150 else:
159 ctrlfile.write(c % tuple(pullData(fs, localdata))) 151 # Auto indent
160 except KeyError: 152 ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' '))
161 import sys 153 else:
162 (type, value, traceback) = sys.exc_info() 154 ctrlfile.write(c % tuple(pullData(fs, localdata)))
163 ctrlfile.close()
164 bb.utils.unlockfile(lf)
165 bb.fatal("Missing field for ipk generation: %s" % value)
166 # more fields 155 # more fields
167 156
168 custom_fields_chunk = get_package_additional_metadata("ipk", localdata) 157 custom_fields_chunk = get_package_additional_metadata("ipk", localdata)
@@ -222,22 +211,14 @@ python do_package_ipk () {
222 scriptvar = localdata.getVar('pkg_%s' % script) 211 scriptvar = localdata.getVar('pkg_%s' % script)
223 if not scriptvar: 212 if not scriptvar:
224 continue 213 continue
225 try: 214 scriptfile = open(os.path.join(controldir, script), 'w')
226 scriptfile = open(os.path.join(controldir, script), 'w')
227 except OSError:
228 bb.utils.unlockfile(lf)
229 bb.fatal("unable to open %s script file for writing" % script)
230 scriptfile.write(scriptvar) 215 scriptfile.write(scriptvar)
231 scriptfile.close() 216 scriptfile.close()
232 os.chmod(os.path.join(controldir, script), 0o755) 217 os.chmod(os.path.join(controldir, script), 0o755)
233 218
234 conffiles_str = ' '.join(get_conffiles(pkg, d)) 219 conffiles_str = ' '.join(get_conffiles(pkg, d))
235 if conffiles_str: 220 if conffiles_str:
236 try: 221 conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
237 conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
238 except OSError:
239 bb.utils.unlockfile(lf)
240 bb.fatal("unable to open conffiles for writing")
241 for f in conffiles_str.split(): 222 for f in conffiles_str.split():
242 if os.path.exists(oe.path.join(root, f)): 223 if os.path.exists(oe.path.join(root, f)):
243 conffiles.write('%s\n' % f) 224 conffiles.write('%s\n' % f)