Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #52388 > unrolled thread

Bug#812404: [PATCH initramfs-tools] copy_file: Skip duplicating symlink if it points to the target file

Started byBen Hutchings <ben@decadent.org.uk>
First post2016-01-23 14:40 +0100
Last post2016-01-23 16:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.debian.kernel


Contents

  Bug#812404: [PATCH initramfs-tools] copy_file: Skip duplicating symlink if it points to the target file Ben Hutchings <ben@decadent.org.uk> - 2016-01-23 14:40 +0100
    Bug#812404: [PATCH initramfs-tools] copy_file: Skip duplicating symlink if it points to the target file Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> - 2016-01-23 16:10 +0100

#52388 — Bug#812404: [PATCH initramfs-tools] copy_file: Skip duplicating symlink if it points to the target file

FromBen Hutchings <ben@decadent.org.uk>
Date2016-01-23 14:40 +0100
SubjectBug#812404: [PATCH initramfs-tools] copy_file: Skip duplicating symlink if it points to the target file
Message-ID<qU6A2-3jF-5@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Control: tag -1 patch moreinfo

I couldn't reproduce this failure but I think I understand the
problem.  Does this patch work for you?

Ben.
---
When the source and target paths are different, it's possible that
the source is a symlink to the target path.  In that case we must
only copy the file - there is no need for a symlink and currently
we create a broken symlink.

Closes: #812404
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 hook-functions | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hook-functions b/hook-functions
index 60f798c..78b6a88 100644
--- a/hook-functions
+++ b/hook-functions
@@ -134,13 +134,17 @@ copy_file() {
 	mkdir -p "${DESTDIR}/${target%/*}"
 
 	if [ -h "${src}" ]; then
-		[ "${verbose}" = "y" ] && echo "Adding ${type}-link ${src}"
-
 		# We don't need to replicate a chain of links completely;
-		# just link directly to the ultimate target.  Create a
-		# relative link so it always points to the right place.
+		# just link directly to the ultimate target
 		link_target="$(readlink -f "${src}")" || return $(($? + 1))
-		ln -rs "${DESTDIR}/${link_target}" "${DESTDIR}/${target}"
+
+		if [ "${link_target}" != "${target}" ]; then
+			[ "${verbose}" = "y" ] && echo "Adding ${type}-link ${src}"
+
+			# Create a relative link so it always points
+			# to the right place
+			ln -rs "${DESTDIR}/${link_target}" "${DESTDIR}/${target}"
+		fi
 
 		# Copy the link target if it doesn't already exist
 		src="${link_target}"

[toc] | [next] | [standalone]


#52392

FromCristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Date2016-01-23 16:10 +0100
Message-ID<qU7Z8-4tS-11@gated-at.bofh.it>
In reply to#52388
On Sat, 23 Jan 2016, Ben Hutchings wrote:
>
> Control: tag -1 patch moreinfo
>
> I couldn't reproduce this failure but I think I understand the
> problem.  Does this patch work for you?

Yes, it does.  On my box:

# ls -l /usr/bin/touch /bin/touch
-rwxr-xr-x 1 root root 60136 Jan 18 21:44 /bin/touch
lrwxrwxrwx 1 root root    10 Jan 20 00:25 /usr/bin/touch -> /bin/touch


Thanks,

-- 
Cristian

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.kernel


csiph-web