summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_deb.bbclass
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:04 +0000
commitf755b07b528e828618141eda402399d791efba4a (patch)
treec5f8bd0ea445192ae7ee1aad15645ae3556f505e /meta/classes/package_deb.bbclass
parent18160442869f56ee71538bc2dc60d7cb6c08c8a2 (diff)
downloadopenembedded-core-contrib-f755b07b528e828618141eda402399d791efba4a.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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_deb.bbclass')
-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 () {
import textwrap
import subprocess
import collections
+ import codecs
oldcwd = os.getcwd()
@@ -121,12 +122,8 @@ python do_package_deb () {
controldir = os.path.join(root, 'DEBIAN')
bb.utils.mkdirhier(controldir)
os.chmod(controldir, 0o755)
- try:
- import codecs
- ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8')
- except OSError:
- bb.utils.unlockfile(lf)
- bb.fatal("unable to open control file for writing")
+
+ ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8')
fields = []
pe = d.getVar('PKGE')
@@ -153,7 +150,7 @@ python do_package_deb () {
for i in l:
data = d.getVar(i)
if data is None:
- raise KeyError(f)
+ raise KeyError(i)
if i == 'DPKG_ARCH' and d.getVar('PACKAGE_ARCH') == 'all':
data = 'all'
elif i == 'PACKAGE_ARCH' or i == 'DPKG_ARCH':
@@ -168,36 +165,26 @@ python do_package_deb () {
if d.getVar('PACKAGE_ARCH') == "all":
ctrlfile.write("Multi-Arch: foreign\n")
# check for required fields
- try:
- for (c, fs) in fields:
- for f in fs:
- if localdata.getVar(f, False) is None:
- raise KeyError(f)
- # Special behavior for description...
- if 'DESCRIPTION' in fs:
- summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "."
- ctrlfile.write('Description: %s\n' % summary)
- description = localdata.getVar('DESCRIPTION') or "."
- description = textwrap.dedent(description).strip()
- if '\\n' in description:
- # Manually indent
- for t in description.split('\\n'):
- # We don't limit the width when manually indent, but we do
- # need the textwrap.fill() to set the initial_indent and
- # subsequent_indent, so set a large width
- ctrlfile.write('%s\n' % textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '))
- else:
- # Auto indent
- ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '))
-
- else:
- ctrlfile.write(c % tuple(pullData(fs, localdata)))
- except KeyError:
- import sys
- (type, value, traceback) = sys.exc_info()
- bb.utils.unlockfile(lf)
- ctrlfile.close()
- bb.fatal("Missing field for deb generation: %s" % value)
+ for (c, fs) in fields:
+ # Special behavior for description...
+ if 'DESCRIPTION' in fs:
+ summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "."
+ ctrlfile.write('Description: %s\n' % summary)
+ description = localdata.getVar('DESCRIPTION') or "."
+ description = textwrap.dedent(description).strip()
+ if '\\n' in description:
+ # Manually indent
+ for t in description.split('\\n'):
+ # We don't limit the width when manually indent, but we do
+ # need the textwrap.fill() to set the initial_indent and
+ # subsequent_indent, so set a large width
+ ctrlfile.write('%s\n' % textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '))
+ else:
+ # Auto indent
+ ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '))
+
+ else:
+ ctrlfile.write(c % tuple(pullData(fs, localdata)))
# more fields
@@ -273,11 +260,7 @@ python do_package_deb () {
if not scriptvar:
continue
scriptvar = scriptvar.strip()
- try:
- scriptfile = open(os.path.join(controldir, script), 'w')
- except OSError:
- bb.utils.unlockfile(lf)
- bb.fatal("unable to open %s script file for writing" % script)
+ scriptfile = open(os.path.join(controldir, script), 'w')
if scriptvar.startswith("#!"):
pos = scriptvar.find("\n") + 1
@@ -297,11 +280,7 @@ python do_package_deb () {
conffiles_str = ' '.join(get_conffiles(pkg, d))
if conffiles_str:
- try:
- conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
- except OSError:
- bb.utils.unlockfile(lf)
- bb.fatal("unable to open conffiles for writing")
+ conffiles = open(os.path.join(controldir, 'conffiles'), 'w')
for f in conffiles_str.split():
if os.path.exists(oe.path.join(root, f)):
conffiles.write('%s\n' % f)