From b9b65e8c79ac27cf8bd7cf1ae155f632e6d72ec8 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 19 Jul 2017 12:07:17 +0200 Subject: [PATCH] recipetool: create: ensure meaningful error for malformed tarballs If you pointed recipetool at a URL that should be a tarball e.g. https://tls.mbed.org/download/start/mbedtls-2.4.2-apache.tgz but instead it returns an HTML page, we try to unpack it, gzip complains but the operation doesn't seem to fail - instead we just get back an empty source tree. Change the checks to account for this - if the source tree is empty, check if the downloaded file in DL_DIR looks like an HTML file and error accordingly if it is. If it's not, error out anyway because no source was unpacked and it should have been (otherwise we just blindly set up EXTERNALSRC for this which is pointless). Fixes an aspect of [YOCTO #11407]. Signed-off-by: Paul Eggleton --- scripts/lib/recipetool/create.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 8e63580db71..923c3368494 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py @@ -462,10 +462,16 @@ def create_recipe(args): srcsubdir = dirlist[0] srctree = os.path.join(srctree, srcsubdir) else: - with open(singleitem, 'r', errors='surrogateescape') as f: - if '