[elbe-devel] [PATCH] archivedir: Fail elbe chg_archive on tar errors

Manuel Traut manut at linutronix.de
Wed Jul 4 12:30:29 CEST 2018


Hi Bene,

On Wed, Jul 04, 2018 at 12:18:15PM +0200, Benedikt Spranger wrote:
> Error from tar are reported to stderr/stdout but not recognized in
> elbe chg_archive:
> 
> $ elbe chg_archive preprocess.xml overlay/
> tar: ./unaccessable: Cannot open: Permission denied
> tar: Exiting with failure status due to previous errors
> Error reading archive
> $ echo $?
> 0
> 
> Convert os.system call to subprocess.check_call to recognize the failure
> and set a proper exit code:
> 
> $ elbe chg_archive preprocess.xml overlay/
> tar: ./unaccessable: Cannot open: Permission denied
> tar: Exiting with failure status due to previous errors
> Error reading archive
> $ echo $?
> 20
> 
> Signed-off-by: Benedikt Spranger <b.spranger at linutronix.de>
> Reviewed-by: Manuel Traut <manut at linutronix.de>

thanks, it is in devel/elbe-3.0 now.

> ---
>  elbepack/archivedir.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/elbepack/archivedir.py b/elbepack/archivedir.py
> index 96b0ccb4..9b3b307a 100644
> --- a/elbepack/archivedir.py
> +++ b/elbepack/archivedir.py
> @@ -6,6 +6,8 @@
>  import os
>  
>  from base64 import standard_b64encode
> +from subprocess import check_call
> +
>  from elbepack.treeutils import etree
>  
>  def enbase(fname):
> @@ -30,7 +32,7 @@ def chg_archive(xml, path, keep):
>          else:
>              cmd = 'tar cjf .archive.tbz --owner=root --group=root -C '
>          cmd += path + ' .'
> -        os.system(cmd)
> +        check_call(cmd, shell=True)
>      else:
>          archive = path
>  
> -- 
> 2.18.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list