aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create_buildsys.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-27 09:22:11 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-29 15:11:21 +1200
commit7c749720e8f23828d5312b040be0b0451f2fd009 (patch)
tree7d85ed5b4d53166fdd2d7649e4e37a9d010a4d7c /scripts/lib/recipetool/create_buildsys.py
parent646c366c2566bd8dd6f73681cea9f5b021589a56 (diff)
downloadopenembedded-core-contrib-7c749720e8f23828d5312b040be0b0451f2fd009.tar.gz
recipetool: create: avoid decoding errors with Python 3
We're opening source files with the default encoding (utf-8) but we can't necessarily be sure that they are UTF-8 clean - for example, recipetool create ftp://mama.indstate.edu/linux/tree/tree-1.7.0.tgz prior to this patch resulted in a UnicodeDecodeError. Use the "surrogateescape" mode to avoid this. Fixes [YOCTO #9822]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'scripts/lib/recipetool/create_buildsys.py')
-rw-r--r--scripts/lib/recipetool/create_buildsys.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/scripts/lib/recipetool/create_buildsys.py b/scripts/lib/recipetool/create_buildsys.py
index 78ae4bcdec..b54cb17e3e 100644
--- a/scripts/lib/recipetool/create_buildsys.py
+++ b/scripts/lib/recipetool/create_buildsys.py
@@ -173,7 +173,7 @@ class CmakeRecipeHandler(RecipeHandler):
def parse_cmake_file(fn, paths=None):
searchpaths = (paths or []) + [os.path.dirname(fn)]
logger.debug('Parsing file %s' % fn)
- with open(fn, 'r') as f:
+ with open(fn, 'r', errors='surrogateescape') as f:
for line in f:
line = line.strip()
for handler in handlers:
@@ -354,7 +354,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
conffile = RecipeHandler.checkfiles(srctree, ['configure'])
if conffile:
# Check if this is just a pre-generated autoconf configure script
- with open(conffile[0], 'r') as f:
+ with open(conffile[0], 'r', errors='surrogateescape') as f:
for i in range(1, 10):
if 'Generated by GNU Autoconf' in f.readline():
autoconf = True
@@ -364,7 +364,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
# Last resort
conffile = RecipeHandler.checkfiles(srctree, ['configure'])
if conffile:
- with open(conffile[0], 'r') as f:
+ with open(conffile[0], 'r', errors='surrogateescape') as f:
for line in f:
line = line.strip()
if line.startswith('VERSION=') or line.startswith('PACKAGE_VERSION='):
@@ -654,7 +654,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
nesting = 0
in_keyword = ''
partial = ''
- with open(srcfile, 'r') as f:
+ with open(srcfile, 'r', errors='surrogateescape') as f:
for line in f:
if in_keyword:
partial += ' ' + line.strip()
@@ -780,7 +780,7 @@ class MakefileRecipeHandler(RecipeHandler):
if installtarget:
func.append('# This is a guess; additional arguments may be required')
makeargs = ''
- with open(makefile[0], 'r') as f:
+ with open(makefile[0], 'r', errors='surrogateescape') as f:
for i in range(1, 100):
if 'DESTDIR' in f.readline():
makeargs += " 'DESTDIR=${D}'"
@@ -809,7 +809,7 @@ class VersionFileRecipeHandler(RecipeHandler):
version = None
for fileitem in filelist:
linecount = 0
- with open(fileitem, 'r') as f:
+ with open(fileitem, 'r', errors='surrogateescape') as f:
for line in f:
line = line.rstrip().strip('"\'')
linecount += 1
@@ -838,7 +838,7 @@ class SpecFileRecipeHandler(RecipeHandler):
foundvalues = {}
for fileitem in filelist:
linecount = 0
- with open(fileitem, 'r') as f:
+ with open(fileitem, 'r', errors='surrogateescape') as f:
for line in f:
for value, varname in valuemap.items():
if line.startswith(value + ':') and not varname in foundvalues: