diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-07-20 16:48:11 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-21 08:44:25 +0100 |
commit | e4346e8be5f451d5cfe0b68a272abd15b0951831 (patch) | |
tree | fee60446d4319e5e771c2e809fc8a21278d00983 /scripts/lib/recipetool | |
parent | 7d474e27bc851b22b7c00ace66ac40ea45588054 (diff) | |
download | poky-e4346e8be5f451d5cfe0b68a272abd15b0951831.tar.gz |
recipetool: create: reimplement fetching with normal fetch/unpack tasks
Now that we have the ability to run the tasks in a more standard context
through tinfoil, change recipetool's fetching code to use that to fetch
files using it. This has the major advantage that any dependencies of
do_fetch and do_unpack (e.g. for subversion or npm) will be handled
automatically. This also has the beneficial side-effect of fixing a
recent regression that prevented this fetch operation from working with
memory resident bitbake.
Also fix devtool's usage of fetch_uri() at the same time so that we can
completely replace it.
Fixes [YOCTO #11710].
(From OE-Core rev: 9a47a6690052ef943c0d4760630ee630fb012153)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool')
-rw-r--r-- | scripts/lib/recipetool/create.py | 40 | ||||
-rw-r--r-- | scripts/lib/recipetool/create_npm.py | 10 |
2 files changed, 25 insertions, 25 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 2b7cc76ccb..2a6a28ba91 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -417,7 +417,7 @@ def create_recipe(args): | |||
417 | pkgarch = "${MACHINE_ARCH}" | 417 | pkgarch = "${MACHINE_ARCH}" |
418 | 418 | ||
419 | extravalues = {} | 419 | extravalues = {} |
420 | checksums = (None, None) | 420 | checksums = {} |
421 | tempsrc = '' | 421 | tempsrc = '' |
422 | source = args.source | 422 | source = args.source |
423 | srcsubdir = '' | 423 | srcsubdir = '' |
@@ -439,22 +439,25 @@ def create_recipe(args): | |||
439 | if res: | 439 | if res: |
440 | srcrev = res.group(1) | 440 | srcrev = res.group(1) |
441 | srcuri = rev_re.sub('', srcuri) | 441 | srcuri = rev_re.sub('', srcuri) |
442 | tempsrc = tempfile.mkdtemp(prefix='recipetool-') | 442 | |
443 | srctree = tempsrc | 443 | tmpparent = tinfoil.config_data.getVar('BASE_WORKDIR') |
444 | d = bb.data.createCopy(tinfoil.config_data) | 444 | bb.utils.mkdirhier(tmpparent) |
445 | if fetchuri.startswith('npm://'): | 445 | tempsrc = tempfile.mkdtemp(prefix='recipetool-', dir=tmpparent) |
446 | # Check if npm is available | 446 | srctree = os.path.join(tempsrc, 'source') |
447 | npm_bindir = check_npm(tinfoil, args.devtool) | 447 | |
448 | d.prependVar('PATH', '%s:' % npm_bindir) | ||
449 | logger.info('Fetching %s...' % srcuri) | ||
450 | try: | 448 | try: |
451 | checksums = scriptutils.fetch_uri(d, fetchuri, srctree, srcrev) | 449 | checksums, ftmpdir = scriptutils.fetch_url(tinfoil, srcuri, srcrev, srctree, logger, preserve_tmp=args.keep_temp) |
452 | except bb.fetch2.BBFetchException as e: | 450 | except scriptutils.FetchUrlFailure as e: |
453 | logger.error(str(e).rstrip()) | 451 | logger.error(str(e)) |
454 | sys.exit(1) | 452 | sys.exit(1) |
453 | |||
454 | if ftmpdir and args.keep_temp: | ||
455 | logger.info('Fetch temp directory is %s' % ftmpdir) | ||
456 | |||
455 | dirlist = os.listdir(srctree) | 457 | dirlist = os.listdir(srctree) |
456 | if 'git.indirectionsymlink' in dirlist: | 458 | filterout = ['git.indirectionsymlink'] |
457 | dirlist.remove('git.indirectionsymlink') | 459 | dirlist = [x for x in dirlist if x not in filterout] |
460 | logger.debug('Directory listing (excluding filtered out):\n %s' % '\n '.join(dirlist)) | ||
458 | if len(dirlist) == 1: | 461 | if len(dirlist) == 1: |
459 | singleitem = os.path.join(srctree, dirlist[0]) | 462 | singleitem = os.path.join(srctree, dirlist[0]) |
460 | if os.path.isdir(singleitem): | 463 | if os.path.isdir(singleitem): |
@@ -465,7 +468,7 @@ def create_recipe(args): | |||
465 | check_single_file(dirlist[0], fetchuri) | 468 | check_single_file(dirlist[0], fetchuri) |
466 | elif len(dirlist) == 0: | 469 | elif len(dirlist) == 0: |
467 | if '/' in fetchuri: | 470 | if '/' in fetchuri: |
468 | fn = os.path.join(d.getVar('DL_DIR'), fetchuri.split('/')[-1]) | 471 | fn = os.path.join(tinfoil.config_data.getVar('DL_DIR'), fetchuri.split('/')[-1]) |
469 | if os.path.isfile(fn): | 472 | if os.path.isfile(fn): |
470 | check_single_file(fn, fetchuri) | 473 | check_single_file(fn, fetchuri) |
471 | # If we've got to here then there's no source so we might as well give up | 474 | # If we've got to here then there's no source so we might as well give up |
@@ -593,11 +596,8 @@ def create_recipe(args): | |||
593 | if not srcuri: | 596 | if not srcuri: |
594 | lines_before.append('# No information for SRC_URI yet (only an external source tree was specified)') | 597 | lines_before.append('# No information for SRC_URI yet (only an external source tree was specified)') |
595 | lines_before.append('SRC_URI = "%s"' % srcuri) | 598 | lines_before.append('SRC_URI = "%s"' % srcuri) |
596 | (md5value, sha256value) = checksums | 599 | for key, value in sorted(checksums.items()): |
597 | if md5value: | 600 | lines_before.append('SRC_URI[%s] = "%s"' % (key, value)) |
598 | lines_before.append('SRC_URI[md5sum] = "%s"' % md5value) | ||
599 | if sha256value: | ||
600 | lines_before.append('SRC_URI[sha256sum] = "%s"' % sha256value) | ||
601 | if srcuri and supports_srcrev(srcuri): | 601 | if srcuri and supports_srcrev(srcuri): |
602 | lines_before.append('') | 602 | lines_before.append('') |
603 | lines_before.append('# Modify these as desired') | 603 | lines_before.append('# Modify these as desired') |
diff --git a/scripts/lib/recipetool/create_npm.py b/scripts/lib/recipetool/create_npm.py index cb8f338b8b..ba7e39a406 100644 --- a/scripts/lib/recipetool/create_npm.py +++ b/scripts/lib/recipetool/create_npm.py | |||
@@ -109,7 +109,6 @@ class NpmRecipeHandler(RecipeHandler): | |||
109 | if varname == 'SRC_URI': | 109 | if varname == 'SRC_URI': |
110 | if not origvalue.startswith('npm://'): | 110 | if not origvalue.startswith('npm://'): |
111 | src_uri = origvalue.split() | 111 | src_uri = origvalue.split() |
112 | changed = False | ||
113 | deplist = {} | 112 | deplist = {} |
114 | for dep, depver in optdeps.items(): | 113 | for dep, depver in optdeps.items(): |
115 | depdata = self.get_npm_data(dep, depver, d) | 114 | depdata = self.get_npm_data(dep, depver, d) |
@@ -123,14 +122,15 @@ class NpmRecipeHandler(RecipeHandler): | |||
123 | depdata = self.get_npm_data(dep, depver, d) | 122 | depdata = self.get_npm_data(dep, depver, d) |
124 | deplist[dep] = depdata | 123 | deplist[dep] = depdata |
125 | 124 | ||
125 | extra_urls = [] | ||
126 | for dep, depdata in deplist.items(): | 126 | for dep, depdata in deplist.items(): |
127 | version = depdata.get('version', None) | 127 | version = depdata.get('version', None) |
128 | if version: | 128 | if version: |
129 | url = 'npm://registry.npmjs.org;name=%s;version=%s;subdir=node_modules/%s' % (dep, version, dep) | 129 | url = 'npm://registry.npmjs.org;name=%s;version=%s;subdir=node_modules/%s' % (dep, version, dep) |
130 | scriptutils.fetch_uri(d, url, srctree) | 130 | extra_urls.append(url) |
131 | src_uri.append(url) | 131 | if extra_urls: |
132 | changed = True | 132 | scriptutils.fetch_url(tinfoil, ' '.join(extra_urls), None, srctree, logger) |
133 | if changed: | 133 | src_uri.extend(extra_urls) |
134 | return src_uri, None, -1, True | 134 | return src_uri, None, -1, True |
135 | return origvalue, None, 0, True | 135 | return origvalue, None, 0, True |
136 | updated, newlines = bb.utils.edit_metadata(lines_before, ['SRC_URI'], varfunc) | 136 | updated, newlines = bb.utils.edit_metadata(lines_before, ['SRC_URI'], varfunc) |