summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool
diff options
context:
space:
mode:
authorSai Hari Chandana Kalluri <chandana.kalluri@xilinx.com>2019-10-04 15:52:29 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-10-23 16:30:35 +0100
commit586175df3b1577c816e9bb320c098084a1db5f83 (patch)
treedbd467354a9ee686bf54deec582ab09145bf8785 /scripts/lib/devtool
parent52fe6a79d97e596ba5c0b2638aa0b0e605f818a5 (diff)
downloadpoky-586175df3b1577c816e9bb320c098084a1db5f83.tar.gz
devtool: Add --remove-work option for devtool reset command
Enable --remove-work option for devtool reset command that allows user to clean up source directory within workspace. Currently devtool reset command only removes recipes and user is forced to manually remove the sources directory within the workspace before running devtool modify again. Using devtool reset -r or devtool reset --remove-work option, user can cleanup the sources directory along with the recipe instead of manually cleaning it. syntax: devtool reset -r <recipename> Ex: devtool reset -r zip devtool finish -r <recipename> <layer-name> Ex: devtool finish -r zip meta-yocto-bsp (From OE-Core rev: 0d6dd01b8633ad63d77c24568a4b20852aaa366f) Signed-off-by: Sai Hari Chandana Kalluri <chandana.kalluri@xilinx.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool')
-rw-r--r--scripts/lib/devtool/standard.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 1646971a91..8d9c1a3022 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1852,7 +1852,7 @@ def status(args, config, basepath, workspace):
1852 return 0 1852 return 0
1853 1853
1854 1854
1855def _reset(recipes, no_clean, config, basepath, workspace): 1855def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
1856 """Reset one or more recipes""" 1856 """Reset one or more recipes"""
1857 import oe.path 1857 import oe.path
1858 1858
@@ -1930,10 +1930,15 @@ def _reset(recipes, no_clean, config, basepath, workspace):
1930 srctreebase = workspace[pn]['srctreebase'] 1930 srctreebase = workspace[pn]['srctreebase']
1931 if os.path.isdir(srctreebase): 1931 if os.path.isdir(srctreebase):
1932 if os.listdir(srctreebase): 1932 if os.listdir(srctreebase):
1933 # We don't want to risk wiping out any work in progress 1933 if remove_work:
1934 logger.info('Leaving source tree %s as-is; if you no ' 1934 logger.info('-r argument used on %s, removing source tree.'
1935 'longer need it then please delete it manually' 1935 ' You will lose any unsaved work' %pn)
1936 % srctreebase) 1936 shutil.rmtree(srctreebase)
1937 else:
1938 # We don't want to risk wiping out any work in progress
1939 logger.info('Leaving source tree %s as-is; if you no '
1940 'longer need it then please delete it manually'
1941 % srctreebase)
1937 else: 1942 else:
1938 # This is unlikely, but if it's empty we can just remove it 1943 # This is unlikely, but if it's empty we can just remove it
1939 os.rmdir(srctreebase) 1944 os.rmdir(srctreebase)
@@ -1943,6 +1948,10 @@ def _reset(recipes, no_clean, config, basepath, workspace):
1943def reset(args, config, basepath, workspace): 1948def reset(args, config, basepath, workspace):
1944 """Entry point for the devtool 'reset' subcommand""" 1949 """Entry point for the devtool 'reset' subcommand"""
1945 import bb 1950 import bb
1951 import shutil
1952
1953 recipes = ""
1954
1946 if args.recipename: 1955 if args.recipename:
1947 if args.all: 1956 if args.all:
1948 raise DevtoolError("Recipe cannot be specified if -a/--all is used") 1957 raise DevtoolError("Recipe cannot be specified if -a/--all is used")
@@ -1957,7 +1966,7 @@ def reset(args, config, basepath, workspace):
1957 else: 1966 else:
1958 recipes = args.recipename 1967 recipes = args.recipename
1959 1968
1960 _reset(recipes, args.no_clean, config, basepath, workspace) 1969 _reset(recipes, args.no_clean, args.remove_work, config, basepath, workspace)
1961 1970
1962 return 0 1971 return 0
1963 1972
@@ -2009,6 +2018,7 @@ def finish(args, config, basepath, workspace):
2009 raise DevtoolError('Source tree is not clean:\n\n%s\nEnsure you have committed your changes or use -f/--force if you are sure there\'s nothing that needs to be committed' % dirty) 2018 raise DevtoolError('Source tree is not clean:\n\n%s\nEnsure you have committed your changes or use -f/--force if you are sure there\'s nothing that needs to be committed' % dirty)
2010 2019
2011 no_clean = args.no_clean 2020 no_clean = args.no_clean
2021 remove_work=args.remove_work
2012 tinfoil = setup_tinfoil(basepath=basepath, tracking=True) 2022 tinfoil = setup_tinfoil(basepath=basepath, tracking=True)
2013 try: 2023 try:
2014 rd = parse_recipe(config, tinfoil, args.recipename, True, False) 2024 rd = parse_recipe(config, tinfoil, args.recipename, True, False)
@@ -2160,7 +2170,7 @@ def finish(args, config, basepath, workspace):
2160 if args.dry_run: 2170 if args.dry_run:
2161 logger.info('Resetting recipe (dry-run)') 2171 logger.info('Resetting recipe (dry-run)')
2162 else: 2172 else:
2163 _reset([args.recipename], no_clean=no_clean, config=config, basepath=basepath, workspace=workspace) 2173 _reset([args.recipename], no_clean=no_clean, remove_work=remove_work, config=config, basepath=basepath, workspace=workspace)
2164 2174
2165 return 0 2175 return 0
2166 2176
@@ -2272,6 +2282,7 @@ def register_commands(subparsers, context):
2272 parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset') 2282 parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset')
2273 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)') 2283 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)')
2274 parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output') 2284 parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output')
2285 parser_reset.add_argument('--remove-work', '-r', action="store_true", help='Clean the sources directory along with append')
2275 parser_reset.set_defaults(func=reset) 2286 parser_reset.set_defaults(func=reset)
2276 2287
2277 parser_finish = subparsers.add_parser('finish', help='Finish working on a recipe in your workspace', 2288 parser_finish = subparsers.add_parser('finish', help='Finish working on a recipe in your workspace',
@@ -2282,6 +2293,7 @@ def register_commands(subparsers, context):
2282 parser_finish.add_argument('--mode', '-m', choices=['patch', 'srcrev', 'auto'], default='auto', help='Update mode (where %(metavar)s is %(choices)s; default is %(default)s)', metavar='MODE') 2293 parser_finish.add_argument('--mode', '-m', choices=['patch', 'srcrev', 'auto'], default='auto', help='Update mode (where %(metavar)s is %(choices)s; default is %(default)s)', metavar='MODE')
2283 parser_finish.add_argument('--initial-rev', help='Override starting revision for patches') 2294 parser_finish.add_argument('--initial-rev', help='Override starting revision for patches')
2284 parser_finish.add_argument('--force', '-f', action="store_true", help='Force continuing even if there are uncommitted changes in the source tree repository') 2295 parser_finish.add_argument('--force', '-f', action="store_true", help='Force continuing even if there are uncommitted changes in the source tree repository')
2296 parser_finish.add_argument('--remove-work', '-r', action="store_true", help='Clean the sources directory under workspace')
2285 parser_finish.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output') 2297 parser_finish.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output')
2286 parser_finish.add_argument('--no-overrides', '-O', action="store_true", help='Do not handle other override branches (if they exist)') 2298 parser_finish.add_argument('--no-overrides', '-O', action="store_true", help='Do not handle other override branches (if they exist)')
2287 parser_finish.add_argument('--dry-run', '-N', action="store_true", help='Dry-run (just report changes instead of writing them)') 2299 parser_finish.add_argument('--dry-run', '-N', action="store_true", help='Dry-run (just report changes instead of writing them)')