diff options
Diffstat (limited to 'scripts/lib/recipetool/setvar.py')
| -rw-r--r-- | scripts/lib/recipetool/setvar.py | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/scripts/lib/recipetool/setvar.py b/scripts/lib/recipetool/setvar.py deleted file mode 100644 index b5ad335cae..0000000000 --- a/scripts/lib/recipetool/setvar.py +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | # Recipe creation tool - set variable plugin | ||
| 2 | # | ||
| 3 | # Copyright (C) 2015 Intel Corporation | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 6 | # | ||
| 7 | |||
| 8 | import sys | ||
| 9 | import os | ||
| 10 | import argparse | ||
| 11 | import glob | ||
| 12 | import fnmatch | ||
| 13 | import re | ||
| 14 | import logging | ||
| 15 | import scriptutils | ||
| 16 | |||
| 17 | logger = logging.getLogger('recipetool') | ||
| 18 | |||
| 19 | tinfoil = None | ||
| 20 | plugins = None | ||
| 21 | |||
| 22 | def tinfoil_init(instance): | ||
| 23 | global tinfoil | ||
| 24 | tinfoil = instance | ||
| 25 | |||
| 26 | def setvar(args): | ||
| 27 | import oe.recipeutils | ||
| 28 | |||
| 29 | if args.delete: | ||
| 30 | if args.value: | ||
| 31 | logger.error('-D/--delete and specifying a value are mutually exclusive') | ||
| 32 | return 1 | ||
| 33 | value = None | ||
| 34 | else: | ||
| 35 | if args.value is None: | ||
| 36 | logger.error('You must specify a value if not using -D/--delete') | ||
| 37 | return 1 | ||
| 38 | value = args.value | ||
| 39 | varvalues = {args.varname: value} | ||
| 40 | |||
| 41 | if args.recipe_only: | ||
| 42 | patches = [oe.recipeutils.patch_recipe_file(args.recipefile, varvalues, patch=args.patch)] | ||
| 43 | else: | ||
| 44 | rd = tinfoil.parse_recipe_file(args.recipefile, False) | ||
| 45 | if not rd: | ||
| 46 | return 1 | ||
| 47 | patches = oe.recipeutils.patch_recipe(rd, args.recipefile, varvalues, patch=args.patch) | ||
| 48 | if args.patch: | ||
| 49 | for patch in patches: | ||
| 50 | for line in patch: | ||
| 51 | sys.stdout.write(line) | ||
| 52 | tinfoil.modified_files() | ||
| 53 | return 0 | ||
| 54 | |||
| 55 | |||
| 56 | def register_commands(subparsers): | ||
| 57 | parser_setvar = subparsers.add_parser('setvar', | ||
| 58 | help='Set a variable within a recipe', | ||
| 59 | description='Adds/updates the value a variable is set to in a recipe') | ||
| 60 | parser_setvar.add_argument('recipefile', help='Recipe file to update') | ||
| 61 | parser_setvar.add_argument('varname', help='Variable name to set') | ||
| 62 | parser_setvar.add_argument('value', nargs='?', help='New value to set the variable to') | ||
| 63 | parser_setvar.add_argument('--recipe-only', '-r', help='Do not set variable in any include file if present', action='store_true') | ||
| 64 | parser_setvar.add_argument('--patch', '-p', help='Create a patch to make the change instead of modifying the recipe', action='store_true') | ||
| 65 | parser_setvar.add_argument('--delete', '-D', help='Delete the specified value instead of setting it', action='store_true') | ||
| 66 | parser_setvar.set_defaults(func=setvar) | ||
