Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] busybox: don't clobber dangling symlinks
@ 2018-07-17 11:01 Baruch Siach
  2018-07-18 12:36 ` Carlos Santos
  2018-08-21 12:20 ` Thomas Petazzoni
  0 siblings, 2 replies; 3+ messages in thread
From: Baruch Siach @ 2018-07-17 11:01 UTC (permalink / raw)
  To: buildroot

We sometimes create dangling symlinks in the target directory. That is
because we need canonical targets, as relative targets don't work well
with BR2_ROOTFS_MERGED_USR. For example, the vim package installs the
/bin/vi symlink to /usr/bin/vim. This symlink might be dangling when the
build host has no vim installed there.

Patch the busybox install.sh script to avoid clobber of dangling
symlinks.

Fixes:
http://autobuild.buildroot.net/results/796/796107430db6545401d9926e84f19eaf2040b756/

Cc: Adam Duskett <aduskett@gmail.com>
Cc: Carlos Santos <casantos@datacom.com.br>
Cc: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 ...l.sh-don-t-clobber-dangling-symlinks.patch | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch

diff --git a/package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch b/package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch
new file mode 100644
index 000000000000..b6fb5b92368f
--- /dev/null
+++ b/package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch
@@ -0,0 +1,38 @@
+From c9f1a877f1b9e2602913600d769edb17ee41d15d Mon Sep 17 00:00:00 2001
+From: Baruch Siach <baruch@tkos.co.il>
+Date: Tue, 17 Jul 2018 13:18:09 +0300
+Subject: [PATCH] install.sh: don't clobber dangling symlinks
+
+Symlinks in a subdirectory that is to become target rootfs are sometimes
+dangling because they link to canonical file names that are not present
+on the host, but are present relative to the target rootfs root. Don't
+copy over dangling symlinks when noclobber is enabled
+
+The -e test treats dangling symlinks as non-existent files. Add -h test
+that returns true for all symlinks.
+
+Cc: Yann E. MORIN <yann.morin.1998@free.fr>
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+---
+Upstream status: 
+http://lists.busybox.net/pipermail/busybox/2018-July/086555.html
+
+ applets/install.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/applets/install.sh b/applets/install.sh
+index 9aede0f530e2..415896893e86 100755
+--- a/applets/install.sh
++++ b/applets/install.sh
+@@ -83,7 +83,7 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
+ for i in $h; do
+ 	appdir=`dirname "$i"`
+ 	app=`basename "$i"`
+-	if [ x"$noclobber" = x"1" ] && [ -e "$prefix/$i" ]; then
++	if [ x"$noclobber" = x"1" ] && ([ -e "$prefix/$i" ] || [ -h "$prefix/$i" ]); then
+ 		echo "  $prefix/$i already exists"
+ 		continue
+ 	fi
+-- 
+2.18.0
+
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] busybox: don't clobber dangling symlinks
  2018-07-17 11:01 [Buildroot] [PATCH] busybox: don't clobber dangling symlinks Baruch Siach
@ 2018-07-18 12:36 ` Carlos Santos
  2018-08-21 12:20 ` Thomas Petazzoni
  1 sibling, 0 replies; 3+ messages in thread
From: Carlos Santos @ 2018-07-18 12:36 UTC (permalink / raw)
  To: buildroot

> From: "Baruch Siach" <baruch@tkos.co.il>
> To: "buildroot" <buildroot@busybox.net>
> Cc: "Baruch Siach" <baruch@tkos.co.il>, "ratbert90" <aduskett@gmail.com>, "DATACOM" <casantos@datacom.com.br>, "Yann
> Morin" <yann.morin.1998@free.fr>
> Sent: Tuesday, July 17, 2018 8:01:43 AM
> Subject: [PATCH] busybox: don't clobber dangling symlinks

> We sometimes create dangling symlinks in the target directory. That is
> because we need canonical targets, as relative targets don't work well
> with BR2_ROOTFS_MERGED_USR. For example, the vim package installs the
> /bin/vi symlink to /usr/bin/vim. This symlink might be dangling when the
> build host has no vim installed there.
> 
> Patch the busybox install.sh script to avoid clobber of dangling
> symlinks.
> 
> Fixes:
> http://autobuild.buildroot.net/results/796/796107430db6545401d9926e84f19eaf2040b756/
> 
> Cc: Adam Duskett <aduskett@gmail.com>
> Cc: Carlos Santos <casantos@datacom.com.br>
> Cc: Yann E. MORIN <yann.morin.1998@free.fr>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> ...l.sh-don-t-clobber-dangling-symlinks.patch | 38 +++++++++++++++++++
> 1 file changed, 38 insertions(+)
> create mode 100644
> package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch
> 
> diff --git
> a/package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch
> b/package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch
> new file mode 100644
> index 000000000000..b6fb5b92368f
> --- /dev/null
> +++ b/package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch
> @@ -0,0 +1,38 @@
> +From c9f1a877f1b9e2602913600d769edb17ee41d15d Mon Sep 17 00:00:00 2001
> +From: Baruch Siach <baruch@tkos.co.il>
> +Date: Tue, 17 Jul 2018 13:18:09 +0300
> +Subject: [PATCH] install.sh: don't clobber dangling symlinks
> +
> +Symlinks in a subdirectory that is to become target rootfs are sometimes
> +dangling because they link to canonical file names that are not present
> +on the host, but are present relative to the target rootfs root. Don't
> +copy over dangling symlinks when noclobber is enabled
> +
> +The -e test treats dangling symlinks as non-existent files. Add -h test
> +that returns true for all symlinks.
> +
> +Cc: Yann E. MORIN <yann.morin.1998@free.fr>
> +Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> +---
> +Upstream status:
> +http://lists.busybox.net/pipermail/busybox/2018-July/086555.html
> +
> + applets/install.sh | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/applets/install.sh b/applets/install.sh
> +index 9aede0f530e2..415896893e86 100755
> +--- a/applets/install.sh
> ++++ b/applets/install.sh
> +@@ -83,7 +83,7 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
> + for i in $h; do
> + 	appdir=`dirname "$i"`
> + 	app=`basename "$i"`
> +-	if [ x"$noclobber" = x"1" ] && [ -e "$prefix/$i" ]; then
> ++	if [ x"$noclobber" = x"1" ] && ([ -e "$prefix/$i" ] || [ -h "$prefix/$i" ]);
> then
> + 		echo "  $prefix/$i already exists"
> + 		continue
> + 	fi
> +--
> +2.18.0
> +
> --
> 2.18.0

I'm not sure if this is a good approach. Perhaps we should look for
dangling symlinks in target-finalize and stop if one is found.

For the specific case of vim, I propose a different solution:

    https://patchwork.ozlabs.org/patch/945700/

-- 
Carlos Santos (Casantos) - DATACOM, P&D
?Marched towards the enemy, spear upright, armed with the certainty
that only the ignorant can have.? ? Epitaph of a volunteer

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] busybox: don't clobber dangling symlinks
  2018-07-17 11:01 [Buildroot] [PATCH] busybox: don't clobber dangling symlinks Baruch Siach
  2018-07-18 12:36 ` Carlos Santos
@ 2018-08-21 12:20 ` Thomas Petazzoni
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2018-08-21 12:20 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 17 Jul 2018 14:01:43 +0300, Baruch Siach wrote:
> We sometimes create dangling symlinks in the target directory. That is
> because we need canonical targets, as relative targets don't work well
> with BR2_ROOTFS_MERGED_USR. For example, the vim package installs the
> /bin/vi symlink to /usr/bin/vim. This symlink might be dangling when the
> build host has no vim installed there.
> 
> Patch the busybox install.sh script to avoid clobber of dangling
> symlinks.
> 
> Fixes:
> http://autobuild.buildroot.net/results/796/796107430db6545401d9926e84f19eaf2040b756/
> 
> Cc: Adam Duskett <aduskett@gmail.com>
> Cc: Carlos Santos <casantos@datacom.com.br>
> Cc: Yann E. MORIN <yann.morin.1998@free.fr>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  ...l.sh-don-t-clobber-dangling-symlinks.patch | 38 +++++++++++++++++++
>  1 file changed, 38 insertions(+)
>  create mode 100644 package/busybox/0003-install.sh-don-t-clobber-dangling-symlinks.patch

Applied to master, thanks.

Carlos: I know you disagreed with this patch, but since it has been
merged by the upstream Busybox developers, I don't see the point of not
merging it in Buildroot as well, since we will anyway get this behavior
at the next Busybox version bump.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-21 12:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-17 11:01 [Buildroot] [PATCH] busybox: don't clobber dangling symlinks Baruch Siach
2018-07-18 12:36 ` Carlos Santos
2018-08-21 12:20 ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox