tools/coreutils: replace symlinks to build prerequisites

Before building, symlinks are made from existing utilities
on the host machine, because they are necessary before
coreutils can be built.

Instead of leaving these utilities as symlinks,
replace them with the copy provided by the coreutils build
in order to increase version control for these utilities
and to have a real copy for targets like the SDK.

The utilities required before building and provided by coreutils are
cp, install, realpath, seq, and stat.

Let all of the utilities be installed with the "g" prefix,
then, existing symlinks named without the "g" prefix are safely replaced
with a new symlink using the coreutils version of `ln` just built
in order to prevent an inconsistent state of the file
since these utilities must always be available.

While at it, sort the list alphabetically.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/16522
Signed-off-by: Robert Marko <robimarko@gmail.com>
(cherry picked from commit b8c0ed4692)
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25363
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Michael Pratt authored and Hauke Mehrtens committed 2026-09-26 22:50:47 +02:00
1 parent 56c74132ce
commit 7e12f73c30
1 file changed
+5 -3
+5 -3
View File
@@ -16,7 +16,7 @@ PKG_HASH:=767ae6a22950ec42f3ba5f7c1de79dd27800ee8e9b8642da5dedb5974a1741e5
HOST_BUILD_PARALLEL := 1
PKG_PROGRAMS:=date readlink touch ln chown ginstall
PKG_PROGRAMS:=chown cp date ginstall ln readlink realpath seq stat touch
include $(INCLUDE_DIR)/host-build.mk
@@ -62,8 +62,10 @@ endef
define Host/Install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(patsubst %,$(HOST_BUILD_DIR)/src/%,$(PKG_PROGRAMS)) $(1)/bin/
ln -sf ginstall $(1)/bin/install
$(foreach prog,$(filter-out g%,$(PKG_PROGRAMS)),$(INSTALL_BIN) $(patsubst %,$(HOST_BUILD_DIR)/src/%,$(prog)) $(1)/bin/g$(prog); )
$(foreach prog,$(filter g%,$(PKG_PROGRAMS)),$(INSTALL_BIN) $(patsubst %,$(HOST_BUILD_DIR)/src/%,$(prog)) $(1)/bin/$(prog); )
$(foreach prog,$(filter-out g%,$(PKG_PROGRAMS)),g$(LN) g$(prog) $(1)/bin/$(prog); )
$(foreach prog,$(filter g%,$(PKG_PROGRAMS)),g$(LN) $(prog) $(1)/bin/$(patsubst g%,%,$(prog)); )
endef
define Host/Uninstall