diff mbox series

devtool: modify: don't accidentally override existing source tree

Message ID 20240930133007.1184996-1-rhi@pengutronix.de
State New
Headers show
Series devtool: modify: don't accidentally override existing source tree | expand

Commit Message

Roland Hieber Sept. 30, 2024, 1:30 p.m. UTC
The 'srctree' argument might point to an existing source directory, and
'devtool modify' without '--no-extract' given (maybe because of the
user's forgetfulness or inexperience) will override its content without
futher warning. Catch this accidental use case, and prompt the user to
specify '--no-extract' if this source tree should be used.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
Note: this patch was developed on kirkstone and will probably also apply
on scarthgap.

 scripts/lib/devtool/standard.py | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Richard Purdie Oct. 1, 2024, 9:44 a.m. UTC | #1
On Mon, 2024-09-30 at 15:30 +0200, Roland Hieber via lists.openembedded.org wrote:
> The 'srctree' argument might point to an existing source directory, and
> 'devtool modify' without '--no-extract' given (maybe because of the
> user's forgetfulness or inexperience) will override its content without
> futher warning. Catch this accidental use case, and prompt the user to
> specify '--no-extract' if this source tree should be used.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
> Note: this patch was developed on kirkstone and will probably also apply
> on scarthgap.
> 
>  scripts/lib/devtool/standard.py | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
> index b2e1a6ca3a5e..5354f298f598 100644
> --- a/scripts/lib/devtool/standard.py
> +++ b/scripts/lib/devtool/standard.py
> @@ -790,6 +790,10 @@ def modify(args, config, basepath, workspace):
>                              "not exist or is not a directory" %
>                              srctree)
>  
> +        if not args.no_extract and os.path.isdir(srctree):
> +            raise DevtoolError("Source path %s already exists. Did you mean to "
> +                               "specify --no-extract?" % srctree)
> +
>          recipefile = rd.getVar('FILE')
>          appendfile = recipe_to_append(recipefile, config, args.wildcard)
>          if os.path.exists(appendfile):
> 

This causes most of the devtool tests to fail:

https://valkyrie.yoctoproject.org/#/builders/48/builds/130/steps/14/logs/stdio

(oe-selftest -r devtool)

This does make me worry that combination of options is used quite commonly.

Cheers,

Richard
diff mbox series

Patch

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index b2e1a6ca3a5e..5354f298f598 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -790,6 +790,10 @@  def modify(args, config, basepath, workspace):
                             "not exist or is not a directory" %
                             srctree)
 
+        if not args.no_extract and os.path.isdir(srctree):
+            raise DevtoolError("Source path %s already exists. Did you mean to "
+                               "specify --no-extract?" % srctree)
+
         recipefile = rd.getVar('FILE')
         appendfile = recipe_to_append(recipefile, config, args.wildcard)
         if os.path.exists(appendfile):