[elbe-devel] [PATCH v2 2/5] efilesystem: Fix copy_filelist copying none existing file

Olivier Dion dion at linutronix.de
Mon Aug 17 15:49:17 CEST 2020


Some files that are passed to copy_filelist() might not exist on the
source file system.  One such example IIRC was /etc/sysctl.conf that
was a broken symlink to something like /etc/sysctl.d/*.conf

Thus, ignore broken symlinks and emit a warning when trying to copy a
regular file that doesn't exist.

Signed-off-by: Olivier Dion <dion 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



More information about the elbe-devel mailing list