[master] standard.py: Provide an additional option for devtool reset

Submitted by Sai Hari Chandana Kalluri on Feb. 8, 2019, 1:57 a.m. | Patch ID: 158602

Details

Message ID 1549591052-12688-1-git-send-email-chandana.kalluri@xilinx.com
State New
Headers show

Commit Message

Sai Hari Chandana Kalluri Feb. 8, 2019, 1:57 a.m.
The devtool reset command cleans the sysroot for a recipe in workspace.
It also removes the append file but leaves the source code as in
workspace. The source is not cleaned intentionally and the user has to
manually remove it before calling devtool modify again.

Provide the user with an option to remove the source code from workspace
by adding a flag to the devtool reset command. The --rm-source option for
the devtool reset command will also clean the source code from the
workspace along with the sysroot and the append file.
Ex: devtool reset --rm-source zip or devtool reset -r zip

Signed-off-by: Sai Hari Chandana Kalluri <chandana.kalluri@xilinx.com>
---
 scripts/lib/devtool/standard.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index b7d4d47..e3bb0d1 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1751,7 +1751,7 @@  def status(args, config, basepath, workspace):
     return 0
 
 
-def _reset(recipes, no_clean, config, basepath, workspace):
+def _reset(recipes, no_clean, rm_source, config, basepath, workspace):
     """Reset one or more recipes"""
     import oe.path
 
@@ -1828,11 +1828,14 @@  def _reset(recipes, no_clean, config, basepath, workspace):
 
         srctreebase = workspace[pn]['srctreebase']
         if os.path.isdir(srctreebase):
-            if os.listdir(srctreebase):
+            if os.listdir(srctreebase) and not rm_source:
                 # We don't want to risk wiping out any work in progress
                 logger.info('Leaving source tree %s as-is; if you no '
                             'longer need it then please delete it manually'
                             % srctreebase)
+            elif rm_source:
+                 logger.info('Cleaning source tree from workspace ')
+                 shutil.rmtree(srctreebase)
             else:
                 # This is unlikely, but if it's empty we can just remove it
                 os.rmdir(srctreebase)
@@ -1856,7 +1859,7 @@  def reset(args, config, basepath, workspace):
     else:
         recipes = args.recipename
 
-    _reset(recipes, args.no_clean, config, basepath, workspace)
+    _reset(recipes, args.no_clean, args.rm_source, config, basepath, workspace)
 
     return 0
 
@@ -2157,6 +2160,7 @@  def register_commands(subparsers, context):
     parser_reset.add_argument('recipename', nargs='*', help='Recipe to reset')
     parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)')
     parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output')
+    parser_reset.add_argument('--rm-source', '-r', action="store_true", help='Remove source code from the workspace')
     parser_reset.set_defaults(func=reset)
 
     parser_finish = subparsers.add_parser('finish', help='Finish working on a recipe in your workspace',

Comments

Paul Eggleton March 4, 2019, 8:17 p.m.
On Friday, 8 February 2019 2:57:32 PM NZDT Sai Hari Chandana Kalluri wrote:
> The devtool reset command cleans the sysroot for a recipe in workspace.
> It also removes the append file but leaves the source code as in
> workspace. The source is not cleaned intentionally and the user has to
> manually remove it before calling devtool modify again.
> 
> Provide the user with an option to remove the source code from workspace
> by adding a flag to the devtool reset command. The --rm-source option for
> the devtool reset command will also clean the source code from the
> workspace along with the sysroot and the append file.
> Ex: devtool reset --rm-source zip or devtool reset -r zip

When I wrote this I made a conscious decision not to delete the source, in 
case the user has unsaved work in the source tree; at least then the user has 
to take an explicit step (an additional rm -rf) in order to delete it. You 
might argue that adding an option is the same as that explicit step, but I am 
still hesitant as you might for example pick a previously used command from 
your command history with -r in it and only realise after you've run it that 
you've just blown away a bunch of your work.

However, I have received the feedback from a number of people that they find 
it annoying that they have to delete the source themselves before being able 
to run devtool on the recipe again. I'd like to hear from the wider community 
on the following two questions:

1) Does the convenience of having this kind of option outweigh the potential 
danger of deleting unsaved work?

2) Are there issues that anyone is experiencing that force you to run devtool 
clean/finish and then re-run devtool modify (or add, or upgrade), making this 
kind of situation come up more frequently? Or is it mostly that the source 
directories end up being left around to stumble over some time later?

Cheers,
Paul
Manjukumar Harthikote Matha March 4, 2019, 11:27 p.m.
Hi Paul,

> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org
> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of Paul
> Eggleton
> Sent: Monday, March 04, 2019 12:17 PM
> To: openembedded-core@lists.openembedded.org; Chandana Kalluri
> <ckalluri@xilinx.com>
> Subject: Re: [OE-core] [OE-Core][master][PATCH] standard.py: Provide an additional
> option for devtool reset
> 
> On Friday, 8 February 2019 2:57:32 PM NZDT Sai Hari Chandana Kalluri wrote:
> > The devtool reset command cleans the sysroot for a recipe in workspace.
> > It also removes the append file but leaves the source code as in
> > workspace. The source is not cleaned intentionally and the user has to
> > manually remove it before calling devtool modify again.
> >
> > Provide the user with an option to remove the source code from
> > workspace by adding a flag to the devtool reset command. The
> > --rm-source option for the devtool reset command will also clean the
> > source code from the workspace along with the sysroot and the append file.
> > Ex: devtool reset --rm-source zip or devtool reset -r zip
> 
> When I wrote this I made a conscious decision not to delete the source, in case the
> user has unsaved work in the source tree; at least then the user has to take an
> explicit step (an additional rm -rf) in order to delete it. You might argue that adding
> an option is the same as that explicit step, but I am still hesitant as you might for
> example pick a previously used command from your command history with -r in it
> and only realise after you've run it that you've just blown away a bunch of your
> work.
> 
> However, I have received the feedback from a number of people that they find it
> annoying that they have to delete the source themselves before being able to run
> devtool on the recipe again. I'd like to hear from the wider community on the
> following two questions:
> 
> 1) Does the convenience of having this kind of option outweigh the potential danger
> of deleting unsaved work?
> 
> 2) Are there issues that anyone is experiencing that force you to run devtool
> clean/finish and then re-run devtool modify (or add, or upgrade), making this kind of
> situation come up more frequently? Or is it mostly that the source directories end up
> being left around to stumble over some time later?

We have seen source directories end up being left around (taking more disk space on certain projects), hence a solution to remove it might be optimal. If the preference is not have "-r" option to avoid command history mistake, then a full command like devtool reset --rm-source is acceptable as well

Thanks,
Manju

<...>
Chandana Kalluri March 11, 2019, 9:23 p.m.
Hello,

For me this was more useful for second scenario where I had to run devtool finish and re run devtool modify. 
This makes it easier to test changes or add new feature to devtool add/modify/ commands. 

Thanks,
Chandana

-----Original Message-----
From: Paul Eggleton <paul.eggleton@linux.intel.com> 
Sent: Monday, March 4, 2019 12:17 PM
To: openembedded-core@lists.openembedded.org; Chandana Kalluri <ckalluri@xilinx.com>
Subject: Re: [OE-core] [OE-Core][master][PATCH] standard.py: Provide an additional option for devtool reset

On Friday, 8 February 2019 2:57:32 PM NZDT Sai Hari Chandana Kalluri wrote:
> The devtool reset command cleans the sysroot for a recipe in workspace.
> It also removes the append file but leaves the source code as in 
> workspace. The source is not cleaned intentionally and the user has to 
> manually remove it before calling devtool modify again.
> 
> Provide the user with an option to remove the source code from 
> workspace by adding a flag to the devtool reset command. The 
> --rm-source option for the devtool reset command will also clean the 
> source code from the workspace along with the sysroot and the append file.
> Ex: devtool reset --rm-source zip or devtool reset -r zip

When I wrote this I made a conscious decision not to delete the source, in case the user has unsaved work in the source tree; at least then the user has to take an explicit step (an additional rm -rf) in order to delete it. You might argue that adding an option is the same as that explicit step, but I am still hesitant as you might for example pick a previously used command from your command history with -r in it and only realise after you've run it that you've just blown away a bunch of your work.

However, I have received the feedback from a number of people that they find it annoying that they have to delete the source themselves before being able to run devtool on the recipe again. I'd like to hear from the wider community on the following two questions:

1) Does the convenience of having this kind of option outweigh the potential danger of deleting unsaved work?

2) Are there issues that anyone is experiencing that force you to run devtool clean/finish and then re-run devtool modify (or add, or upgrade), making this kind of situation come up more frequently? Or is it mostly that the source directories end up being left around to stumble over some time later?

Cheers,
Paul