]> code.ossystems Code Review - openembedded-core.git/commitdiff
license: don't assume source files are UTF-8
authorRoss Burton <ross.burton@intel.com>
Wed, 8 Mar 2017 14:30:13 +0000 (14:30 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 10 Mar 2017 10:15:45 +0000 (10:15 +0000)
We can't assume that source files are entirely UTF-8, so when copying the
license blocks open the file as binary instead of text.

[ YOCTO #11135 ]

Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/license.bbclass

index 0ff6560a138875521ea3f7c1047efbd17fdaaac2..81458e797b81c6a4d200b396cc2633f1109c5420 100644 (file)
@@ -386,9 +386,9 @@ def copy_license_files(lic_files_paths, destdir):
                 if begin_idx is None and end_idx is None:
                     shutil.copyfile(src, dst)
                 else:
-                    with open(src, 'r') as src_f:
-                        with open(dst, 'w') as dst_f:
-                            dst_f.write(''.join(src_f.readlines()[begin_idx:end_idx]))
+                    with open(src, 'rb') as src_f:
+                        with open(dst, 'wb') as dst_f:
+                            dst_f.write(b''.join(src_f.readlines()[begin_idx:end_idx]))
 
         except Exception as e:
             bb.warn("Could not copy license file %s to %s: %s" % (src, dst, e))