aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2015-08-17 07:10:13 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 17:57:53 +0100
commit4096f3c5d309161999adc996fdfa7526e5504366 (patch)
treee25e6d0e0c06035624e79e69a77c0888bd217f5c /meta/classes
parent98c4a3ffb8dca10739be600e8d6df7fb6aa4958f (diff)
downloadopenembedded-core-contrib-4096f3c5d309161999adc996fdfa7526e5504366.tar.gz
package_deb.bbclass: Allow UTF-8 characters on control files
Allow UTF-8 characters on control files. Also handle an expection in case of invalid characters (non UTF-8). [YOCTO #6693] Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/package_deb.bbclass18
1 files changed, 11 insertions, 7 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index 9e1ed28c3ae..398ceeeb28d 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -96,9 +96,8 @@ python do_package_deb () {
bb.utils.mkdirhier(controldir)
os.chmod(controldir, 0755)
try:
- ctrlfile = open(os.path.join(controldir, 'control'), 'w')
- # import codecs
- # ctrlfile = codecs.open("someFile", "w", "utf-8")
+ import codecs
+ ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8')
except OSError:
bb.utils.unlockfile(lf)
raise bb.build.FuncFailed("unable to open control file for writing.")
@@ -149,7 +148,7 @@ python do_package_deb () {
# Special behavior for description...
if 'DESCRIPTION' in fs:
summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "."
- ctrlfile.write('Description: %s\n' % unicode(summary))
+ ctrlfile.write('Description: %s\n' % unicode(summary,'utf-8'))
description = localdata.getVar('DESCRIPTION', True) or "."
description = textwrap.dedent(description).strip()
if '\\n' in description:
@@ -158,19 +157,24 @@ python do_package_deb () {
# 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' % unicode(textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' ')))
+ ctrlfile.write('%s\n' % unicode(textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '),'utf-8'))
else:
# Auto indent
- ctrlfile.write('%s\n' % unicode(textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' ')))
+ ctrlfile.write('%s\n' % unicode(textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '),'utf-8'))
else:
- ctrlfile.write(unicode(c % tuple(pullData(fs, localdata))))
+ ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)),'utf-8'))
except KeyError:
import sys
(type, value, traceback) = sys.exc_info()
bb.utils.unlockfile(lf)
ctrlfile.close()
raise bb.build.FuncFailed("Missing field for deb generation: %s" % value)
+ except UnicodeDecodeError:
+ bb.utils.unlockfile(lf)
+ ctrlfile.close()
+ raise bb.build.FuncFailed("Non UTF-8 characters found in one of the fields")
+
# more fields
custom_fields_chunk = get_package_additional_metadata("deb", localdata)