[klibc] [klibc:master] Install command links as appropriate

klibc-bot for Ben Hutchings ben at decadent.org.uk
Thu Jul 27 14:51:05 PDT 2023


Commit-ID:  d16525038612be94cf2573c02eac8c7f76321f62
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=d16525038612be94cf2573c02eac8c7f76321f62
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Thu, 27 Jul 2023 23:32:02 +0200
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Thu, 27 Jul 2023 23:42:25 +0200

[klibc] Install command links as appropriate

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 at canonical.com>
References: https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/2028571
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 scripts/Kbuild.install | 7 +++++++
 usr/gzip/Kbuild        | 3 ++-
 usr/utils/Kbuild       | 5 +++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/scripts/Kbuild.install b/scripts/Kbuild.install
index 0788637f..df02159b 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 9bbf0a47..52c57d01 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 002342f7..a389c2a7 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


More information about the klibc mailing list