mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
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] (From OE-Core rev: 4096f3c5d309161999adc996fdfa7526e5504366) Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3898cc33d1
commit
1019d8c802
@@ -96,9 +96,8 @@ python do_package_deb () {
|
|||||||
bb.utils.mkdirhier(controldir)
|
bb.utils.mkdirhier(controldir)
|
||||||
os.chmod(controldir, 0755)
|
os.chmod(controldir, 0755)
|
||||||
try:
|
try:
|
||||||
ctrlfile = open(os.path.join(controldir, 'control'), 'w')
|
import codecs
|
||||||
# import codecs
|
ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8')
|
||||||
# ctrlfile = codecs.open("someFile", "w", "utf-8")
|
|
||||||
except OSError:
|
except OSError:
|
||||||
bb.utils.unlockfile(lf)
|
bb.utils.unlockfile(lf)
|
||||||
raise bb.build.FuncFailed("unable to open control file for writing.")
|
raise bb.build.FuncFailed("unable to open control file for writing.")
|
||||||
@@ -149,7 +148,7 @@ python do_package_deb () {
|
|||||||
# Special behavior for description...
|
# Special behavior for description...
|
||||||
if 'DESCRIPTION' in fs:
|
if 'DESCRIPTION' in fs:
|
||||||
summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "."
|
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 = localdata.getVar('DESCRIPTION', True) or "."
|
||||||
description = textwrap.dedent(description).strip()
|
description = textwrap.dedent(description).strip()
|
||||||
if '\\n' in description:
|
if '\\n' in description:
|
||||||
@@ -158,19 +157,24 @@ python do_package_deb () {
|
|||||||
# We don't limit the width when manually indent, but we do
|
# We don't limit the width when manually indent, but we do
|
||||||
# need the textwrap.fill() to set the initial_indent and
|
# need the textwrap.fill() to set the initial_indent and
|
||||||
# subsequent_indent, so set a large width
|
# 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:
|
else:
|
||||||
# Auto indent
|
# 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:
|
else:
|
||||||
ctrlfile.write(unicode(c % tuple(pullData(fs, localdata))))
|
ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)),'utf-8'))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
import sys
|
import sys
|
||||||
(type, value, traceback) = sys.exc_info()
|
(type, value, traceback) = sys.exc_info()
|
||||||
bb.utils.unlockfile(lf)
|
bb.utils.unlockfile(lf)
|
||||||
ctrlfile.close()
|
ctrlfile.close()
|
||||||
raise bb.build.FuncFailed("Missing field for deb generation: %s" % value)
|
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
|
# more fields
|
||||||
|
|
||||||
custom_fields_chunk = get_package_additional_metadata("deb", localdata)
|
custom_fields_chunk = get_package_additional_metadata("deb", localdata)
|
||||||
|
|||||||
Reference in New Issue
Block a user