Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] A couple of fixes for recipetool
@ 2016-06-29  3:12 Paul Eggleton
  2016-06-29  3:12 ` [PATCH 1/2] recipetool: create: avoid decoding errors with Python 3 Paul Eggleton
  2016-06-29  3:12 ` [PATCH 2/2] recipetool: create: drop unused convert_pkginfo() function Paul Eggleton
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Eggleton @ 2016-06-29  3:12 UTC (permalink / raw)
  To: openembedded-core

The following changes since commit 646c366c2566bd8dd6f73681cea9f5b021589a56:

  gst-player: upgrade to latest HEAD (2016-06-27 14:08:37 +0100)

are available in the git repository at:

  git://git.openembedded.org/openembedded-core-contrib paule/recipetool-fixes3
  http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/recipetool-fixes3

Paul Eggleton (2):
  recipetool: create: avoid decoding errors with Python 3
  recipetool: create: drop unused convert_pkginfo() function

 scripts/lib/recipetool/create.py          | 35 +++----------------------------
 scripts/lib/recipetool/create_buildsys.py | 14 ++++++-------
 scripts/lib/recipetool/create_kernel.py   |  2 +-
 scripts/lib/recipetool/create_kmod.py     |  4 ++--
 scripts/lib/recipetool/create_npm.py      |  2 +-
 5 files changed, 14 insertions(+), 43 deletions(-)

-- 
2.5.5



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] recipetool: create: avoid decoding errors with Python 3
  2016-06-29  3:12 [PATCH 0/2] A couple of fixes for recipetool Paul Eggleton
@ 2016-06-29  3:12 ` Paul Eggleton
  2016-06-29  3:12 ` [PATCH 2/2] recipetool: create: drop unused convert_pkginfo() function Paul Eggleton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2016-06-29  3:12 UTC (permalink / raw)
  To: openembedded-core

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>
---
 scripts/lib/recipetool/create.py          |  6 +++---
 scripts/lib/recipetool/create_buildsys.py | 14 +++++++-------
 scripts/lib/recipetool/create_kernel.py   |  2 +-
 scripts/lib/recipetool/create_kmod.py     |  4 ++--
 scripts/lib/recipetool/create_npm.py      |  2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 1297428..042e700 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -390,7 +390,7 @@ def create_recipe(args):
                 srcsubdir = dirlist[0]
                 srctree = os.path.join(srctree, srcsubdir)
             else:
-                with open(singleitem, 'r') as f:
+                with open(singleitem, 'r', errors='surrogateescape') as f:
                     if '<html' in f.read(100).lower():
                         logger.error('Fetching "%s" returned a single HTML page - check the URL is correct and functional' % fetchuri)
                         sys.exit(1)
@@ -840,7 +840,7 @@ def crunch_license(licfile):
     # https://github.com/FFmpeg/FFmpeg/blob/master/COPYING.LGPLv3
     crunched_md5sums['2ebfb3bb49b9a48a075cc1425e7f4129'] = 'LGPLv3'
     lictext = []
-    with open(licfile, 'r') as f:
+    with open(licfile, 'r', errors='surrogateescape') as f:
         for line in f:
             # Drop opening statements
             if copyright_re.match(line):
@@ -978,7 +978,7 @@ def convert_debian(debpath):
 
     values = {}
     depends = []
-    with open(os.path.join(debpath, 'control')) as f:
+    with open(os.path.join(debpath, 'control'), 'r', errors='surrogateescape') as f:
         indesc = False
         for line in f:
             if indesc:
diff --git a/scripts/lib/recipetool/create_buildsys.py b/scripts/lib/recipetool/create_buildsys.py
index 78ae4bc..b54cb17 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:
diff --git a/scripts/lib/recipetool/create_kernel.py b/scripts/lib/recipetool/create_kernel.py
index c6e86bd..7dac59f 100644
--- a/scripts/lib/recipetool/create_kernel.py
+++ b/scripts/lib/recipetool/create_kernel.py
@@ -59,7 +59,7 @@ class KernelRecipeHandler(RecipeHandler):
                     kpatchlevel = -1
                     ksublevel = -1
                     kextraversion = ''
-                    with open(makefile, 'r') as f:
+                    with open(makefile, 'r', errors='surrogateescape') as f:
                         for i, line in enumerate(f):
                             if i > 10:
                                 break
diff --git a/scripts/lib/recipetool/create_kmod.py b/scripts/lib/recipetool/create_kmod.py
index fe39edb..7cf188d 100644
--- a/scripts/lib/recipetool/create_kmod.py
+++ b/scripts/lib/recipetool/create_kmod.py
@@ -53,7 +53,7 @@ class KernelModuleRecipeHandler(RecipeHandler):
                             break
                 else:
                     continue
-                with open(cfile, 'r') as f:
+                with open(cfile, 'r', errors='surrogateescape') as f:
                     for line in f:
                         if module_inc_re.match(line.strip()):
                             is_module = True
@@ -73,7 +73,7 @@ class KernelModuleRecipeHandler(RecipeHandler):
             in_install = False
             in_compile = False
             install_target = None
-            with open(makefile, 'r') as f:
+            with open(makefile, 'r', errors='surrogateescape') as f:
                 for line in f:
                     if line.startswith('install:'):
                         if not install_lines:
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py
index fcc0172..e5aaa60 100644
--- a/scripts/lib/recipetool/create_npm.py
+++ b/scripts/lib/recipetool/create_npm.py
@@ -92,7 +92,7 @@ class NpmRecipeHandler(RecipeHandler):
             return False
 
         def read_package_json(fn):
-            with open(fn, 'r') as f:
+            with open(fn, 'r', errors='surrogateescape') as f:
                 return json.loads(f.read())
 
         files = RecipeHandler.checkfiles(srctree, ['package.json'])
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] recipetool: create: drop unused convert_pkginfo() function
  2016-06-29  3:12 [PATCH 0/2] A couple of fixes for recipetool Paul Eggleton
  2016-06-29  3:12 ` [PATCH 1/2] recipetool: create: avoid decoding errors with Python 3 Paul Eggleton
@ 2016-06-29  3:12 ` Paul Eggleton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2016-06-29  3:12 UTC (permalink / raw)
  To: openembedded-core

Code cleanup, no functional changes - this code was never used.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 scripts/lib/recipetool/create.py | 29 -----------------------------
 1 file changed, 29 deletions(-)

diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 042e700..430f5bb 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -937,35 +937,6 @@ def read_pkgconfig_provides(d):
                         recipemap[pc] = line.split(':', 1)[1].strip()
     return recipemap
 
-def convert_pkginfo(pkginfofile):
-    values = {}
-    with open(pkginfofile, 'r') as f:
-        indesc = False
-        for line in f:
-            if indesc:
-                if line.strip():
-                    values['DESCRIPTION'] += ' ' + line.strip()
-                else:
-                    indesc = False
-            else:
-                splitline = line.split(': ', 1)
-                key = line[0]
-                value = line[1]
-                if key == 'LICENSE':
-                    for dep in value.split(','):
-                        dep = dep.split()[0]
-                        mapped = depmap.get(dep, '')
-                        if mapped:
-                            depends.append(mapped)
-                elif key == 'License':
-                    values['LICENSE'] = value
-                elif key == 'Summary':
-                    values['SUMMARY'] = value
-                elif key == 'Description':
-                    values['DESCRIPTION'] = value
-                    indesc = True
-    return values
-
 def convert_debian(debpath):
     value_map = {'Package': 'PN',
                  'Version': 'PV',
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-29  3:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-29  3:12 [PATCH 0/2] A couple of fixes for recipetool Paul Eggleton
2016-06-29  3:12 ` [PATCH 1/2] recipetool: create: avoid decoding errors with Python 3 Paul Eggleton
2016-06-29  3:12 ` [PATCH 2/2] recipetool: create: drop unused convert_pkginfo() function Paul Eggleton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox