summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-29 15:12:03 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-08 09:57:24 +0100
commit75f1a0ed422669734081f394187c28ef0258dfc2 (patch)
treedbb026543f557ec3c391d41fc03be9b72196dbe7 /scripts
parent74c5cd0c2c98c0fb80c834b514afacb598ad7073 (diff)
downloadpoky-75f1a0ed422669734081f394187c28ef0258dfc2.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]. (From OE-Core rev: 50fcd9d1b9a20d49bc873467a82a071f2f2f8b5a) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/recipetool/create.py6
-rw-r--r--scripts/lib/recipetool/create_buildsys.py14
-rw-r--r--scripts/lib/recipetool/create_kernel.py2
-rw-r--r--scripts/lib/recipetool/create_kmod.py4
-rw-r--r--scripts/lib/recipetool/create_npm.py2
5 files changed, 14 insertions, 14 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 129742807f..042e7009cb 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -390,7 +390,7 @@ def create_recipe(args):
390 srcsubdir = dirlist[0] 390 srcsubdir = dirlist[0]
391 srctree = os.path.join(srctree, srcsubdir) 391 srctree = os.path.join(srctree, srcsubdir)
392 else: 392 else:
393 with open(singleitem, 'r') as f: 393 with open(singleitem, 'r', errors='surrogateescape') as f:
394 if '<html' in f.read(100).lower(): 394 if '<html' in f.read(100).lower():
395 logger.error('Fetching "%s" returned a single HTML page - check the URL is correct and functional' % fetchuri) 395 logger.error('Fetching "%s" returned a single HTML page - check the URL is correct and functional' % fetchuri)
396 sys.exit(1) 396 sys.exit(1)
@@ -840,7 +840,7 @@ def crunch_license(licfile):
840 # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3 840 # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3
841 crunched_md5sums['2ebfb3bb49b9a48a075cc1425e7f4129'] = 'LGPLv3' 841 crunched_md5sums['2ebfb3bb49b9a48a075cc1425e7f4129'] = 'LGPLv3'
842 lictext = [] 842 lictext = []
843 with open(licfile, 'r') as f: 843 with open(licfile, 'r', errors='surrogateescape') as f:
844 for line in f: 844 for line in f:
845 # Drop opening statements 845 # Drop opening statements
846 if copyright_re.match(line): 846 if copyright_re.match(line):
@@ -978,7 +978,7 @@ def convert_debian(debpath):
978 978
979 values = {} 979 values = {}
980 depends = [] 980 depends = []
981 with open(os.path.join(debpath, 'control')) as f: 981 with open(os.path.join(debpath, 'control'), 'r', errors='surrogateescape') as f:
982 indesc = False 982 indesc = False
983 for line in f: 983 for line in f:
984 if indesc: 984 if indesc:
diff --git a/scripts/lib/recipetool/create_buildsys.py b/scripts/lib/recipetool/create_buildsys.py
index e08ad277d7..f784f9468a 100644
--- a/scripts/lib/recipetool/create_buildsys.py
+++ b/scripts/lib/recipetool/create_buildsys.py
@@ -173,7 +173,7 @@ class CmakeRecipeHandler(RecipeHandler):
173 def parse_cmake_file(fn, paths=None): 173 def parse_cmake_file(fn, paths=None):
174 searchpaths = (paths or []) + [os.path.dirname(fn)] 174 searchpaths = (paths or []) + [os.path.dirname(fn)]
175 logger.debug('Parsing file %s' % fn) 175 logger.debug('Parsing file %s' % fn)
176 with open(fn, 'r') as f: 176 with open(fn, 'r', errors='surrogateescape') as f:
177 for line in f: 177 for line in f:
178 line = line.strip() 178 line = line.strip()
179 for handler in handlers: 179 for handler in handlers:
@@ -354,7 +354,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
354 conffile = RecipeHandler.checkfiles(srctree, ['configure']) 354 conffile = RecipeHandler.checkfiles(srctree, ['configure'])
355 if conffile: 355 if conffile:
356 # Check if this is just a pre-generated autoconf configure script 356 # Check if this is just a pre-generated autoconf configure script
357 with open(conffile[0], 'r') as f: 357 with open(conffile[0], 'r', errors='surrogateescape') as f:
358 for i in range(1, 10): 358 for i in range(1, 10):
359 if 'Generated by GNU Autoconf' in f.readline(): 359 if 'Generated by GNU Autoconf' in f.readline():
360 autoconf = True 360 autoconf = True
@@ -364,7 +364,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
364 # Last resort 364 # Last resort
365 conffile = RecipeHandler.checkfiles(srctree, ['configure']) 365 conffile = RecipeHandler.checkfiles(srctree, ['configure'])
366 if conffile: 366 if conffile:
367 with open(conffile[0], 'r') as f: 367 with open(conffile[0], 'r', errors='surrogateescape') as f:
368 for line in f: 368 for line in f:
369 line = line.strip() 369 line = line.strip()
370 if line.startswith('VERSION=') or line.startswith('PACKAGE_VERSION='): 370 if line.startswith('VERSION=') or line.startswith('PACKAGE_VERSION='):
@@ -654,7 +654,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
654 nesting = 0 654 nesting = 0
655 in_keyword = '' 655 in_keyword = ''
656 partial = '' 656 partial = ''
657 with open(srcfile, 'r') as f: 657 with open(srcfile, 'r', errors='surrogateescape') as f:
658 for line in f: 658 for line in f:
659 if in_keyword: 659 if in_keyword:
660 partial += ' ' + line.strip() 660 partial += ' ' + line.strip()
@@ -780,7 +780,7 @@ class MakefileRecipeHandler(RecipeHandler):
780 if installtarget: 780 if installtarget:
781 func.append('# This is a guess; additional arguments may be required') 781 func.append('# This is a guess; additional arguments may be required')
782 makeargs = '' 782 makeargs = ''
783 with open(makefile[0], 'r') as f: 783 with open(makefile[0], 'r', errors='surrogateescape') as f:
784 for i in range(1, 100): 784 for i in range(1, 100):
785 if 'DESTDIR' in f.readline(): 785 if 'DESTDIR' in f.readline():
786 makeargs += " 'DESTDIR=${D}'" 786 makeargs += " 'DESTDIR=${D}'"
@@ -809,7 +809,7 @@ class VersionFileRecipeHandler(RecipeHandler):
809 version = None 809 version = None
810 for fileitem in filelist: 810 for fileitem in filelist:
811 linecount = 0 811 linecount = 0
812 with open(fileitem, 'r') as f: 812 with open(fileitem, 'r', errors='surrogateescape') as f:
813 for line in f: 813 for line in f:
814 line = line.rstrip().strip('"\'') 814 line = line.rstrip().strip('"\'')
815 linecount += 1 815 linecount += 1
@@ -838,7 +838,7 @@ class SpecFileRecipeHandler(RecipeHandler):
838 foundvalues = {} 838 foundvalues = {}
839 for fileitem in filelist: 839 for fileitem in filelist:
840 linecount = 0 840 linecount = 0
841 with open(fileitem, 'r') as f: 841 with open(fileitem, 'r', errors='surrogateescape') as f:
842 for line in f: 842 for line in f:
843 for value, varname in valuemap.items(): 843 for value, varname in valuemap.items():
844 if line.startswith(value + ':') and not varname in foundvalues: 844 if line.startswith(value + ':') and not varname in foundvalues:
diff --git a/scripts/lib/recipetool/create_kernel.py b/scripts/lib/recipetool/create_kernel.py
index c6e86bd2b9..7dac59fd03 100644
--- a/scripts/lib/recipetool/create_kernel.py
+++ b/scripts/lib/recipetool/create_kernel.py
@@ -59,7 +59,7 @@ class KernelRecipeHandler(RecipeHandler):
59 kpatchlevel = -1 59 kpatchlevel = -1
60 ksublevel = -1 60 ksublevel = -1
61 kextraversion = '' 61 kextraversion = ''
62 with open(makefile, 'r') as f: 62 with open(makefile, 'r', errors='surrogateescape') as f:
63 for i, line in enumerate(f): 63 for i, line in enumerate(f):
64 if i > 10: 64 if i > 10:
65 break 65 break
diff --git a/scripts/lib/recipetool/create_kmod.py b/scripts/lib/recipetool/create_kmod.py
index fe39edb288..7cf188db21 100644
--- a/scripts/lib/recipetool/create_kmod.py
+++ b/scripts/lib/recipetool/create_kmod.py
@@ -53,7 +53,7 @@ class KernelModuleRecipeHandler(RecipeHandler):
53 break 53 break
54 else: 54 else:
55 continue 55 continue
56 with open(cfile, 'r') as f: 56 with open(cfile, 'r', errors='surrogateescape') as f:
57 for line in f: 57 for line in f:
58 if module_inc_re.match(line.strip()): 58 if module_inc_re.match(line.strip()):
59 is_module = True 59 is_module = True
@@ -73,7 +73,7 @@ class KernelModuleRecipeHandler(RecipeHandler):
73 in_install = False 73 in_install = False
74 in_compile = False 74 in_compile = False
75 install_target = None 75 install_target = None
76 with open(makefile, 'r') as f: 76 with open(makefile, 'r', errors='surrogateescape') as f:
77 for line in f: 77 for line in f:
78 if line.startswith('install:'): 78 if line.startswith('install:'):
79 if not install_lines: 79 if not install_lines:
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index fcc0172af8..e5aaa60bf8 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -92,7 +92,7 @@ class NpmRecipeHandler(RecipeHandler):
92 return False 92 return False
93 93
94 def read_package_json(fn): 94 def read_package_json(fn):
95 with open(fn, 'r') as f: 95 with open(fn, 'r', errors='surrogateescape') as f:
96 return json.loads(f.read()) 96 return json.loads(f.read())
97 97
98 files = RecipeHandler.checkfiles(srctree, ['package.json']) 98 files = RecipeHandler.checkfiles(srctree, ['package.json'])