Skip to contentSkip to conversation

coreutils: fix chroot installation

PATCH New Baruch Siach 5 participants 8 messages Jul 11, 2018 – Jul 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 coreutils: fix chroot installation

Since commit 256bb383fb7 (coreutils: use single binary in symlink method) the chroot move command creates a dangling symlink, because the symlink target is 'coreutils' which is not in the /usr/sbin/ directory. Instead of moving, remove the coreutils installed symlink, and create a new one in $(TARGET_DIR)/usr/sbin with the correct target.

Should also fix (busybox):
http://autobuild.buildroot.net/results/6b3/6b39648b466738162516aa50ab328d839ec85448/

Cc Carlos Santos <[email protected]>
Cc Thomas Petazzoni <[email protected]>

---
v2: Drop ../usr from symlink target (Arnout, Carlos)

---
 package/coreutils/coreutils.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/coreutils/coreutils.mk +2 -1
index 3cb96589f228..2fb4a32c794f 100644
@@ -114,7 +114,8 @@ define COREUTILS_CLEANUP
 	# link for archaic shells
 	ln -fs test $(TARGET_DIR)/usr/bin/[
 	# gnu thinks chroot is in bin, debian thinks it's in sbin
-	mv -f $(TARGET_DIR)/usr/bin/chroot $(TARGET_DIR)/usr/sbin/chroot
+	rm -f $(TARGET_DIR)/usr/bin/chroot
+	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
 endef
 
 COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CLEANUP
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 2/2 coreutils: optimize the '[' symlink

Link '[' directly to the coreutils binary instead of going through 'test'.

---
v2: New patch in this series

---
 package/coreutils/coreutils.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/coreutils/coreutils.mk +1 -1
index 2fb4a32c794f..7e7251ff7396 100644
@@ -112,7 +112,7 @@ endif
 
 define COREUTILS_CLEANUP
 	# link for archaic shells
-	ln -fs test $(TARGET_DIR)/usr/bin/[
+	ln -fs coreutils $(TARGET_DIR)/usr/bin/[
 	# gnu thinks chroot is in bin, debian thinks it's in sbin
 	rm -f $(TARGET_DIR)/usr/bin/chroot
 	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
Signature · 1 line
2.18.0
#2 lore raw

PATCH v2 2/2 coreutils: optimize the '[' symlink

Quoted 27 lines

From: "Baruch Siach" <[email protected]>
To: "buildroot" <[email protected]>
Cc: "DATACOM" <[email protected]>, "Arnout Vandecappelle" <[email protected]>, "Baruch Siach" <[email protected]>
Sent: Wednesday, July 11, 2018 4:51:19 PM
Subject: [PATCH v2 2/2] coreutils: optimize the '[' symlink

Link '[' directly to the coreutils binary instead of going through 'test'.

---
v2: New patch in this series
---
package/coreutils/coreutils.mk | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
package/coreutils/coreutils.mk +0 -0
index 2fb4a32c794f..7e7251ff7396 100644
@@ -112,7 +112,7 @@ endif
 

define COREUTILS_CLEANUP

	# link for archaic shells
package/coreutils/coreutils.mk +1 -1
-	ln -fs test $(TARGET_DIR)/usr/bin/[
+	ln -fs coreutils $(TARGET_DIR)/usr/bin/[
Quoted 5 lines
	# gnu thinks chroot is in bin, debian thinks it's in sbin
	rm -f $(TARGET_DIR)/usr/bin/chroot
	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
--
2.18.0
Signature · 3 lines
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
#3 lore raw

PATCH v2 2/2 coreutils: optimize the '[' symlink

In reply to Baruch Siach
Quoted 2 lines · Baruch Siach

Link '[' directly to the coreutils binary instead of going through 'test'.

One more small question: did you do a runtime test to be sure that this
actually works? (That said, if this doesn't work, then the previous one also can't have worked.)

Regards,
Arnout

Quoted 23 lines

---
v2: New patch in this series

---
 package/coreutils/coreutils.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/coreutils/coreutils.mk +1 -1
index 2fb4a32c794f..7e7251ff7396 100644
@@ -112,7 +112,7 @@ endif
 
 define COREUTILS_CLEANUP
 	# link for archaic shells
-	ln -fs test $(TARGET_DIR)/usr/bin/[
+	ln -fs coreutils $(TARGET_DIR)/usr/bin/[
 	# gnu thinks chroot is in bin, debian thinks it's in sbin
 	rm -f $(TARGET_DIR)/usr/bin/chroot
 	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#4 lore raw

PATCH v2 2/2 coreutils: optimize the '[' symlink

Quoted 6 lines

From: "Arnout Vandecappelle" <[email protected]>
To: "Baruch Siach" <[email protected]>, "buildroot" <[email protected]>
Cc: "DATACOM" <[email protected]>
Sent: Wednesday, July 11, 2018 6:49:43 PM
Subject: Re: [PATCH v2 2/2] coreutils: optimize the '[' symlink

Quoted 7 lines
Quoted 2 lines · Baruch Siach

Link '[' directly to the coreutils binary instead of going through 'test'.

One more small question: did you do a runtime test to be sure that this actually works? (That said, if this doesn't work, then the previous one also can't have worked.)

Yes, but it must be invoked directly since '[' is a shell built-in command:

   # type [
   [ is a shell builtin
   # /usr/bin/[ -d / ] && echo ok
   ok
Signature · 3 lines
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
#5 lore raw

PATCH v2 2/2 coreutils: optimize the '[' symlink

In reply to Arnout Vandecappelle

Hi Arnout,

Quoted 7 lines · Arnout Vandecappelle
Quoted 2 lines · Baruch Siach

Link '[' directly to the coreutils binary instead of going through 'test'.

One more small question: did you do a runtime test to be sure that this
actually works? (That said, if this doesn't work, then the previous one also can't have worked.)

Tested in chroot now:

# readlink /usr/bin/[
coreutils
# if /usr/bin/[ 0 -eq 0 ]; then echo true; else echo false; fi
true
# if /usr/bin/[ 1 -eq 0 ]; then echo true; else echo false; fi
false

baruch

Quoted 21 lines
Quoted 21 lines

---
v2: New patch in this series

---
 package/coreutils/coreutils.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/coreutils/coreutils.mk +1 -1
index 2fb4a32c794f..7e7251ff7396 100644
@@ -112,7 +112,7 @@ endif
 
 define COREUTILS_CLEANUP
 	# link for archaic shells
-	ln -fs test $(TARGET_DIR)/usr/bin/[
+	ln -fs coreutils $(TARGET_DIR)/usr/bin/[
 	# gnu thinks chroot is in bin, debian thinks it's in sbin
 	rm -f $(TARGET_DIR)/usr/bin/chroot
 	ln -sf ../bin/coreutils $(TARGET_DIR)/usr/sbin/chroot
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#6 lore raw

PATCH v2 1/2 coreutils: fix chroot installation

In reply to Baruch Siach

Hello,

Quoted 9 lines · Baruch Siach

Since commit 256bb383fb7 (coreutils: use single binary in symlink method) the chroot move command creates a dangling symlink, because the symlink target is 'coreutils' which is not in the /usr/sbin/ directory. Instead of moving, remove the coreutils installed symlink, and create a new one in $(TARGET_DIR)/usr/sbin with the correct target.

Should also fix (busybox):
http://autobuild.buildroot.net/results/6b3/6b39648b466738162516aa50ab328d839ec85448/

Quoted 8 lines
Cc Carlos Santos <[email protected]>
Cc Thomas Petazzoni <[email protected]>

---
v2: Drop ../usr from symlink target (Arnout, Carlos)

---
 package/coreutils/coreutils.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Series applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

PATCH v2 1/2 coreutils: fix chroot installation

In reply to Baruch Siach
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Since commit 256bb383fb7 (coreutils: use single binary in symlink method) the chroot move command creates a dangling symlink, because the symlink target is 'coreutils' which is not in the /usr/sbin/ directory. Instead of moving, remove the coreutils installed symlink, and create a new one in $(TARGET_DIR)/usr/sbin with the correct target.

Quoted 8 lines

Should also fix (busybox):
http://autobuild.buildroot.net/results/6b3/6b39648b466738162516aa50ab328d839ec85448/

Cc Carlos Santos <[email protected]>
Cc Thomas Petazzoni <[email protected]>

---
v2: Drop ../usr from symlink target (Arnout, Carlos)

Committed to 2018.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard