summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-rw-r--r--scripts/lib/recipetool/create.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 648f2d66fc..439dca0fcc 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -416,12 +416,14 @@ def create_recipe(args):
416 srcuri = rev_re.sub('', srcuri) 416 srcuri = rev_re.sub('', srcuri)
417 tempsrc = tempfile.mkdtemp(prefix='recipetool-') 417 tempsrc = tempfile.mkdtemp(prefix='recipetool-')
418 srctree = tempsrc 418 srctree = tempsrc
419 d = bb.data.createCopy(tinfoil.config_data)
419 if fetchuri.startswith('npm://'): 420 if fetchuri.startswith('npm://'):
420 # Check if npm is available 421 # Check if npm is available
421 check_npm(tinfoil.config_data, args.devtool) 422 npm_bindir = check_npm(tinfoil, args.devtool)
423 d.prependVar('PATH', '%s:' % npm_bindir)
422 logger.info('Fetching %s...' % srcuri) 424 logger.info('Fetching %s...' % srcuri)
423 try: 425 try:
424 checksums = scriptutils.fetch_uri(tinfoil.config_data, fetchuri, srctree, srcrev) 426 checksums = scriptutils.fetch_uri(d, fetchuri, srctree, srcrev)
425 except bb.fetch2.BBFetchException as e: 427 except bb.fetch2.BBFetchException as e:
426 logger.error(str(e).rstrip()) 428 logger.error(str(e).rstrip())
427 sys.exit(1) 429 sys.exit(1)
@@ -1119,10 +1121,21 @@ def convert_rpm_xml(xmlfile):
1119 return values 1121 return values
1120 1122
1121 1123
1122def check_npm(d, debugonly=False): 1124def check_npm(tinfoil, debugonly=False):
1123 if not os.path.exists(os.path.join(d.getVar('STAGING_BINDIR_NATIVE'), 'npm')): 1125 try:
1124 log_error_cond('npm required to process specified source, but npm is not available - you need to build nodejs-native first', debugonly) 1126 rd = tinfoil.parse_recipe('nodejs-native')
1127 except bb.providers.NoProvider:
1128 # We still conditionally show the message and exit with the special
1129 # return code, otherwise we can't show the proper message for eSDK
1130 # users
1131 log_error_cond('nodejs-native is required for npm but is not available - you will likely need to add a layer that provides nodejs', debugonly)
1132 sys.exit(14)
1133 bindir = rd.getVar('STAGING_BINDIR_NATIVE')
1134 npmpath = os.path.join(bindir, 'npm')
1135 if not os.path.exists(npmpath):
1136 log_error_cond('npm required to process specified source, but npm is not available - you need to run bitbake -c addto_recipe_sysroot nodejs-native first', debugonly)
1125 sys.exit(14) 1137 sys.exit(14)
1138 return bindir
1126 1139
1127def register_commands(subparsers): 1140def register_commands(subparsers):
1128 parser_create = subparsers.add_parser('create', 1141 parser_create = subparsers.add_parser('create',
@@ -1141,5 +1154,8 @@ def register_commands(subparsers):
1141 parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') 1154 parser_create.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)')
1142 parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies') 1155 parser_create.add_argument('--fetch-dev', action="store_true", help='For npm, also fetch devDependencies')
1143 parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS) 1156 parser_create.add_argument('--devtool', action="store_true", help=argparse.SUPPRESS)
1144 parser_create.set_defaults(func=create_recipe) 1157 # FIXME I really hate having to set parserecipes for this, but given we may need
1158 # to call into npm (and we don't know in advance if we will or not) and in order
1159 # to do so we need to know npm's recipe sysroot path, there's not much alternative
1160 parser_create.set_defaults(func=create_recipe, parserecipes=True)
1145 1161