mirror of
https://git.yoctoproject.org/poky
synced 2026-04-20 00:32:13 +02:00
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>
This commit is contained in:
@@ -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=' '))
|
||||
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)))
|
||||
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)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user