[elbe-devel] [PATCH v3] efilesystem: Fix copy_filelist copying none existing file

Torben Hohn torben.hohn at linutronix.de
Tue Aug 25 12:45:05 CEST 2020


On Thu, Aug 20, 2020 at 10:21:44AM -0400, Olivier Dion wrote:
> Some files that are passed to copy_filelist() might not exist on the
> source file system.  One such example is
> '/etc/sysctl.d/99-sysctl.conf -> ../sysctl.conf'.
> 
> Thus, if the target of a symlink doesn't exists, create the link but
> do not call copy_filelist() recursively with the target.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/efilesystem.py | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
> index ef697c46..18b592a4 100644
> --- a/elbepack/efilesystem.py
> +++ b/elbepack/efilesystem.py
> @@ -56,6 +56,10 @@ def copy_filelist(src, file_lst, dst):
>  
>              tgt = src.readlink(f)
>  
> +            if not src.lexists(tgt):
> +                dst.symlink(tgt, f, allow_exists=True)
> +                continue
> +
>              # If the target is not yet in the destination RFS, we need
>              # to defer the copy of the symlink after the target is
>              # resolved.  Thus, we recusively call copy_filelist
> @@ -78,8 +82,12 @@ def copy_filelist(src, file_lst, dst):
>              dst.chown(f, st.st_uid, st.st_gid)
>  
>          else:
> -            system('cp -a --reflink=auto "%s" "%s"' % (src.realpath(f),
> -                                                       dst.realpath(f)))
> +            try:
> +                system('cp -a --reflink=auto "%s" "%s"' % (src.realpath(f),
> +                                                           dst.realpath(f)))
> +            except CommandError as E:
> +                logging.warning("Error while copying from %s to %s of file %s - %s",
> +                                src.path, dst.path, f, E)
>  
>      # update utime which will change after a file has been copied into
>      # the directory
> -- 
> 2.28.0
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list