summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_deb.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-20 11:17:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:00 +0100
commita7309d5790f5dac46e84d3c14959943eb2496fda (patch)
tree48e1fcb886b8ef2974bade09694356f3230fb8a8 /meta/classes/package_deb.bbclass
parent297438e965053b2eb56cc8ef3e59465642f10a24 (diff)
downloadpoky-a7309d5790f5dac46e84d3c14959943eb2496fda.tar.gz
classes/lib: Update to use python3 command pipeline decoding
In python3, strings are unicode by default. We need to encode/decode from command pipelines and other places where we interface with the real world using the correct locales. This patch updates various call sites to use the correct encoding/decodings. (From OE-Core rev: bb4685af1bffe17b3aa92a6d21398f38a44ea874) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_deb.bbclass')
-rw-r--r--meta/classes/package_deb.bbclass26
1 files changed, 11 insertions, 15 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass
index bb5220ed00..e35f427ea2 100644
--- a/meta/classes/package_deb.bbclass
+++ b/meta/classes/package_deb.bbclass
@@ -173,7 +173,7 @@ python do_package_deb () {
173 # Special behavior for description... 173 # Special behavior for description...
174 if 'DESCRIPTION' in fs: 174 if 'DESCRIPTION' in fs:
175 summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "." 175 summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "."
176 ctrlfile.write('Description: %s\n' % unicode(summary,'utf-8')) 176 ctrlfile.write('Description: %s\n' % summary)
177 description = localdata.getVar('DESCRIPTION', True) or "." 177 description = localdata.getVar('DESCRIPTION', True) or "."
178 description = textwrap.dedent(description).strip() 178 description = textwrap.dedent(description).strip()
179 if '\\n' in description: 179 if '\\n' in description:
@@ -182,29 +182,25 @@ python do_package_deb () {
182 # We don't limit the width when manually indent, but we do 182 # We don't limit the width when manually indent, but we do
183 # need the textwrap.fill() to set the initial_indent and 183 # need the textwrap.fill() to set the initial_indent and
184 # subsequent_indent, so set a large width 184 # subsequent_indent, so set a large width
185 ctrlfile.write('%s\n' % unicode(textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '),'utf-8')) 185 ctrlfile.write('%s\n' % textwrap.fill(t, width=100000, initial_indent=' ', subsequent_indent=' '))
186 else: 186 else:
187 # Auto indent 187 # Auto indent
188 ctrlfile.write('%s\n' % unicode(textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '),'utf-8')) 188 ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' '))
189 189
190 else: 190 else:
191 ctrlfile.write(unicode(c % tuple(pullData(fs, localdata)),'utf-8')) 191 ctrlfile.write(c % tuple(pullData(fs, localdata)))
192 except KeyError: 192 except KeyError:
193 import sys 193 import sys
194 (type, value, traceback) = sys.exc_info() 194 (type, value, traceback) = sys.exc_info()
195 bb.utils.unlockfile(lf) 195 bb.utils.unlockfile(lf)
196 ctrlfile.close() 196 ctrlfile.close()
197 raise bb.build.FuncFailed("Missing field for deb generation: %s" % value) 197 raise bb.build.FuncFailed("Missing field for deb generation: %s" % value)
198 except UnicodeDecodeError:
199 bb.utils.unlockfile(lf)
200 ctrlfile.close()
201 raise bb.build.FuncFailed("Non UTF-8 characters found in one of the fields")
202 198
203 # more fields 199 # more fields
204 200
205 custom_fields_chunk = get_package_additional_metadata("deb", localdata) 201 custom_fields_chunk = get_package_additional_metadata("deb", localdata)
206 if custom_fields_chunk is not None: 202 if custom_fields_chunk is not None:
207 ctrlfile.write(unicode(custom_fields_chunk)) 203 ctrlfile.write(custom_fields_chunk)
208 ctrlfile.write("\n") 204 ctrlfile.write("\n")
209 205
210 mapping_rename_hook(localdata) 206 mapping_rename_hook(localdata)
@@ -255,17 +251,17 @@ python do_package_deb () {
255 rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS", True) or "") 251 rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS", True) or "")
256 debian_cmp_remap(rconflicts) 252 debian_cmp_remap(rconflicts)
257 if rdepends: 253 if rdepends:
258 ctrlfile.write("Depends: %s\n" % unicode(bb.utils.join_deps(rdepends))) 254 ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends))
259 if rsuggests: 255 if rsuggests:
260 ctrlfile.write("Suggests: %s\n" % unicode(bb.utils.join_deps(rsuggests))) 256 ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests))
261 if rrecommends: 257 if rrecommends:
262 ctrlfile.write("Recommends: %s\n" % unicode(bb.utils.join_deps(rrecommends))) 258 ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends))
263 if rprovides: 259 if rprovides:
264 ctrlfile.write("Provides: %s\n" % unicode(bb.utils.join_deps(rprovides))) 260 ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides))
265 if rreplaces: 261 if rreplaces:
266 ctrlfile.write("Replaces: %s\n" % unicode(bb.utils.join_deps(rreplaces))) 262 ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces))
267 if rconflicts: 263 if rconflicts:
268 ctrlfile.write("Conflicts: %s\n" % unicode(bb.utils.join_deps(rconflicts))) 264 ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts))
269 ctrlfile.close() 265 ctrlfile.close()
270 266
271 for script in ["preinst", "postinst", "prerm", "postrm"]: 267 for script in ["preinst", "postinst", "prerm", "postrm"]: