Skip to contentSkip to conversation

Switch coreutils to symlink method

PATCH New Thomas Petazzoni 2 participants 5 messages Apr 1, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover Switch coreutils to symlink method

Hello,

This is a new iteration of Carlos Santos patch [1] for coreutils, with the following changes:

- Add a patch to use a foreach make loop instead of a for shell loop.

- Use the symlink method instead of shell wrappers in all cases, not only in the merged /usr situation, by tweaking how some programs are moved from /usr/bin to /bin.

[1] https://patchwork.ozlabs.org/patch/819273/

Thanks,

Thomas

Carlos Santos (1):
coreutils: use single binary in symlink method

Thomas Petazzoni (1):
coreutils: rewrite for loop with foreach

 package/coreutils/coreutils.mk | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 1/2 coreutils: rewrite for loop with foreach

This brings up error checking at each iteration of the loop for free, which removes the need for "|| exit 1".

---
 package/coreutils/coreutils.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
package/coreutils/coreutils.mk +3 -3
index 8259f42f4a..8880e77dcc 100644
@@ -104,9 +104,9 @@ endif
 ifeq ($(BR2_ROOTFS_MERGED_USR),)
 define COREUTILS_CLEANUP_BIN
 	# some things go in root rather than usr
-	for f in $(COREUTILS_BIN_PROGS); do \
-		mv -f $(TARGET_DIR)/usr/bin/$$f $(TARGET_DIR)/bin/$$f || exit 1; \
-	done
+	$(foreach f,$(COREUTILS_BIN_PROGS), \
+		mv -f $(TARGET_DIR)/usr/bin/$(f) $(TARGET_DIR)/bin/$(f)
+	)
 endef
 COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CLEANUP_BIN
 endif
Signature · 1 line
2.14.3
#2 lore raw

PATCH v2 1/2 coreutils: rewrite for loop with foreach

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

This brings up error checking at each iteration of the loop for free, which removes the need for "|| exit 1".

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 2/2 coreutils: use single binary in symlink method

In reply to Thomas Petazzoni

From: Carlos Santos <[email protected]>

The symlink method is faster, since there is no shell fork/exec, and provides extra space savings.

[Thomas: use the symlinks method not only for the merged /usr case, but also in the non-merged case to be consistent, and therefore adjust the logic that was moving the shell wrappers to a logic that recreates the symlinks.]

---
 package/coreutils/coreutils.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
package/coreutils/coreutils.mk +4 -3
index 8880e77dcc..4ef888829f 100644
@@ -14,7 +14,7 @@ COREUTILS_LICENSE_FILES = COPYING
 COREUTILS_AUTORECONF = YES
 COREUTILS_GETTEXTIZE = YES
 
-COREUTILS_CONF_OPTS = --disable-rpath --enable-single-binary=shebangs \
+COREUTILS_CONF_OPTS = --disable-rpath --enable-single-binary=symlinks \
 	$(if $(BR2_TOOLCHAIN_USES_MUSL),--with-included-regex)
 COREUTILS_CONF_ENV = ac_cv_c_restrict=no \
 	ac_cv_func_chown_works=yes \
@@ -103,9 +103,10 @@ endif
 
 ifeq ($(BR2_ROOTFS_MERGED_USR),)
 define COREUTILS_CLEANUP_BIN
-	# some things go in root rather than usr
+	# some things go in /bin rather than /usr/bin
 	$(foreach f,$(COREUTILS_BIN_PROGS), \
-		mv -f $(TARGET_DIR)/usr/bin/$(f) $(TARGET_DIR)/bin/$(f)
+		rm -f $(TARGET_DIR)/usr/bin/$(f) && \
+		ln -sf ../usr/bin/coreutils $(TARGET_DIR)/bin/$(f)
 	)
 endef
 COREUTILS_POST_INSTALL_TARGET_HOOKS += COREUTILS_CLEANUP_BIN
Signature · 1 line
2.14.3
#4 lore raw

PATCH v2 2/2 coreutils: use single binary in symlink method

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

From: Carlos Santos <[email protected]>
The symlink method is faster, since there is no shell fork/exec, and provides extra space savings.

Quoted 6 lines

[Thomas: use the symlinks method not only for the merged /usr case, but also in the non-merged case to be consistent, and therefore adjust the logic that was moving the shell wrappers to a logic that recreates the symlinks.]

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard