aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2023-07-27 23:32:02 +0200
committerBen Hutchings <ben@decadent.org.uk>2023-07-27 23:42:25 +0200
commitd16525038612be94cf2573c02eac8c7f76321f62 (patch)
treeb584b765bb88b2419c53b7b8e9bfd69b388bcce5
parent78106790f9de2c297dbcedea7ff39ce4192ec1b2 (diff)
[klibc] Install command links as appropriateklibc-2.0.13
We build gzip to support being called as "gunzip" or "zcat", and similarly we build halt to support being called as "poweroff" or "reboot". In the build directory, we create the aliases as links to the same binary. When installing, however, we pass all the names for the same binary to the "install" command, creating multiple copies of it in the install directory. To fix this: - Define an install_links command that creates links as specified in an install-links-y variable. - Invoke install_links after installing binaries. - In usr/gzip/Kbuild and usr/utils/Kbuild, specify the links in install-links-y instead of install-y. Reported-by: Benjamin Drung <benjamin.drung@canonical.com> References: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/2028571 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--scripts/Kbuild.install7
-rw-r--r--usr/gzip/Kbuild3
-rw-r--r--usr/utils/Kbuild5
3 files changed, 12 insertions, 3 deletions
diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
index 0788637f8bd33..df02159bf8be0 100644
--- a/scripts/Kbuild.install
+++ b/scripts/Kbuild.install
@@ -27,6 +27,10 @@ quiet_cmd_install = INSTALL $(install-y)
cmd_install = $(install-bin) $(install-y) \
$(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)bin
+# Link install command
+quiet_cmd_install_links = LN $(install-link-y)
+ cmd_install_links = $(foreach l, $(install-link-y), ln -f $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)bin/$(word 2,$(subst =,$(space),$(l))) $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)bin/$(word 1,$(subst =,$(space),$(l))) &&) true
+
ifeq ($(KLIBC_INSTALL),1)
# First part - we are descending..
@@ -69,6 +73,9 @@ ifneq ($(install-y),)
else
@:
endif
+ifneq ($(install-link-y),)
+ $(call cmd,install_links)
+endif
# Descending
PHONY += $(subdir-)
diff --git a/usr/gzip/Kbuild b/usr/gzip/Kbuild
index 9bbf0a4715092..52c57d01d0238 100644
--- a/usr/gzip/Kbuild
+++ b/usr/gzip/Kbuild
@@ -22,4 +22,5 @@ $(obj)/gunzip $(obj)/zcat: $(obj)/gzip
targets := gzip gzip.g gunzip zcat
# Targets to install
-install-y := gzip gunzip zcat
+install-y := gzip
+install-link-y := gunzip=gzip zcat=gzip
diff --git a/usr/utils/Kbuild b/usr/utils/Kbuild
index 002342f769401..a389c2a761d7b 100644
--- a/usr/utils/Kbuild
+++ b/usr/utils/Kbuild
@@ -79,7 +79,8 @@ clean-dirs := static shared
# install the shared binaries by preference
ifdef KLIBCSHAREDFLAGS
-install-y := $(shared-y) shared/reboot shared/poweroff
+install-y := $(shared-y)
else
-install-y := $(static-y) static/reboot static/poweroff
+install-y := $(static-y)
endif
+install-link-y := reboot=halt poweroff=halt