Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.kernel > #52388
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Newsgroups | linux.debian.bugs.dist, linux.debian.kernel |
| Subject | Bug#812404: [PATCH initramfs-tools] copy_file: Skip duplicating symlink if it points to the target file |
| Date | 2016-01-23 14:40 +0100 |
| Message-ID | <qU6A2-3jF-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Cross-posted to 2 groups.
[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}"
Back to linux.debian.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
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
csiph-web