From 765db0268082dfaf0110441894abf3dafeff258b Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 26 Sep 2024 18:02:35 +0200 Subject: [PATCH] hook-functions: Restore copy_file's handling of target ending in slash Until recently, copy_file would treat a target ending in a slash as a target directory. This was not intended behaviour, but had worked since at least v0.98.8. It broke when I started using 'realpath' to canonicalise the target, which stripped the slash. Add a specific check for a trailing slash, and document that behaviour. Fixes: 984bdc7d727f ("hook-functions: copy_file: Canonicalise target filename") Closes: #1082647 Signed-off-by: Ben Hutchings --- hook-functions | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hook-functions b/hook-functions index f673292..3c9a243 100644 --- a/hook-functions +++ b/hook-functions @@ -158,7 +158,8 @@ add_builtin_firmware() # * If the target is not specified, it defaults to the source file # name. # * If the target is specified and exists as a directory under -# $DESTDIR, the basename of the source is appended to it. +# $DESTDIR or ends in a slash, the basename of the source is +# appended to it. # # The target file's containing directories are created if necessary. # @@ -180,7 +181,7 @@ copy_file() { [ -f "${src}" ] || return 2 - if [ -d "${DESTDIR}/${target}" ]; then + if [ -d "${DESTDIR}/${target}" ] || [ "${target%/}" != "$target" ]; then target="${target}/${src##*/}" fi