diff options
Diffstat (limited to 'scripts/lib/recipetool/create.py')
| -rw-r--r-- | scripts/lib/recipetool/create.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 8e63580db7..923c336849 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
| @@ -462,10 +462,16 @@ def create_recipe(args): | |||
| 462 | srcsubdir = dirlist[0] | 462 | srcsubdir = dirlist[0] |
| 463 | srctree = os.path.join(srctree, srcsubdir) | 463 | srctree = os.path.join(srctree, srcsubdir) |
| 464 | else: | 464 | else: |
| 465 | with open(singleitem, 'r', errors='surrogateescape') as f: | 465 | check_single_file(dirlist[0], fetchuri) |
| 466 | if '<html' in f.read(100).lower(): | 466 | elif len(dirlist) == 0: |
| 467 | logger.error('Fetching "%s" returned a single HTML page - check the URL is correct and functional' % fetchuri) | 467 | if '/' in fetchuri: |
| 468 | sys.exit(1) | 468 | fn = os.path.join(d.getVar('DL_DIR'), fetchuri.split('/')[-1]) |
| 469 | if os.path.isfile(fn): | ||
| 470 | check_single_file(fn, fetchuri) | ||
| 471 | # If we've got to here then there's no source so we might as well give up | ||
| 472 | logger.error('URL %s resulted in an empty source tree' % fetchuri) | ||
| 473 | sys.exit(1) | ||
| 474 | |||
| 469 | if os.path.exists(os.path.join(srctree, '.gitmodules')) and srcuri.startswith('git://'): | 475 | if os.path.exists(os.path.join(srctree, '.gitmodules')) and srcuri.startswith('git://'): |
| 470 | srcuri = 'gitsm://' + srcuri[6:] | 476 | srcuri = 'gitsm://' + srcuri[6:] |
| 471 | logger.info('Fetching submodules...') | 477 | logger.info('Fetching submodules...') |
| @@ -812,6 +818,14 @@ def create_recipe(args): | |||
| 812 | 818 | ||
| 813 | return 0 | 819 | return 0 |
| 814 | 820 | ||
| 821 | def check_single_file(fn, fetchuri): | ||
| 822 | """Determine if a single downloaded file is something we can't handle""" | ||
| 823 | with open(fn, 'r', errors='surrogateescape') as f: | ||
| 824 | if '<html' in f.read(100).lower(): | ||
| 825 | logger.error('Fetching "%s" returned a single HTML page - check the URL is correct and functional' % fetchuri) | ||
| 826 | sys.exit(1) | ||
| 827 | |||
| 828 | |||
| 815 | def handle_license_vars(srctree, lines_before, handled, extravalues, d): | 829 | def handle_license_vars(srctree, lines_before, handled, extravalues, d): |
| 816 | licvalues = guess_license(srctree, d) | 830 | licvalues = guess_license(srctree, d) |
| 817 | lic_files_chksum = [] | 831 | lic_files_chksum = [] |
