[elbe-devel] [PATCH 5/8] efilesystem: fix copy_filelist symlink to non existant directory copy
Olivier Dion
dion at linutronix.de
Wed Mar 4 17:40:40 CET 2020
On Wed, 04 Mar 2020, Torben Hohn <torben.hohn at linutronix.de> wrote:
> The example armel-rescue-busybox-cpio.xml triggers this bug:
>
> ----------------------------------------------------------------------------------------
> [ERROR] Build failed
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/elbepack/asyncworker.py", line 186, in execute
> skip_pbuild=self.skip_pbuilder)
> File "/usr/lib/python2.7/dist-packages/elbepack/elbeproject.py", line 551, in build
> self.get_rpcaptcache())
> File "/usr/lib/python2.7/dist-packages/elbepack/efilesystem.py", line 83, in extract_target
> copy_filelist(src, file_list, dst)
> File "/usr/lib/python2.7/dist-packages/elbepack/efilesystem.py", line 40, in copy_filelist
> dst.fname(f)))
> File "/usr/lib/python2.7/dist-packages/elbepack/shellhelper.py", line 39, in system
> raise CommandError(cmd, ret)
> CommandError: Error: 1 returned from Command cp -a --reflink=auto "/var/cache/elbe/d6bda8a8-fd79-4eba-a443-98ea0a8fefcb/chroot/bin/busybox" "/var/cache/elbe/d6bda8a8-fd79-4eba-a443-98ea0a8fefcb/target/bin/busybox"
> Project build was not successful, current status: build_failed
> elbe control wait_busy Failed
> ----------------------------------------------------------------------------------------
>
> this is caused by /bin being a symlink to /usr bin.
> The /bin symlink has already been copied at that point.
> but /usr/bin has not.
>
> Fix that by making sure, that the target directory of a symlink exists,
> when its copied.
>
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/efilesystem.py | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
> index 5bc20afda..55dda7bf2 100644
> --- a/elbepack/efilesystem.py
> +++ b/elbepack/efilesystem.py
> @@ -36,6 +36,10 @@ def copy_filelist(src, filelist, dst):
> st = src.stat(f)
> dst.chown(f, st.st_uid, st.st_gid)
> else:
> + if src.isdir(f) and src.islink(f):
> + tgt = src.readlink(f)
Would you not prefer to use src.realpath(f) instead of src.readlink(f). In
case there's multiple symlinks
> + if not dst.isdir(tgt):
> + dst.mkdir(tgt)
> system('cp -a --reflink=auto "%s" "%s"' % (src.fname(f),
> dst.fname(f)))
> # update utime which will change after a file has been copied into
> --
> 2.20.1
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Olivier Dion
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
More information about the elbe-devel
mailing list