coreutils: add alternatives support

Fixes openwrt/packages#9290

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
(cherry-picked from commit 9282044851)
This commit is contained in:
Yousong Zhou 2019-07-13 11:09:09 +00:00
parent ef44ef6980
commit 93e7b09827
1 changed files with 27 additions and 2 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=coreutils
PKG_VERSION:=8.23
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/coreutils
@ -31,6 +31,30 @@ COREUTILS_APPLETS := \
timeout touch tr true truncate tsort tty uname unexpand uniq unlink \
uptime users vdir wc who whoami yes
DIR_BIN := \
base64 cat chgrp chmod chown cp date dd echo false kill link ln ls \
mkdir mknod mktemp mv nice printenv pwd rm rmdir sleep stat stty sync \
touch true uname
DIR_USR_BIN := \
basename cksum comm cut dirname du env expand expr factor fold groups \
head hostid id install logname md5sum mkfifo nl nohup nproc od paste \
printf readlink realpath seq sha1sum sha256sum sha512sum shred shuf \
sort split sum tac tail tee test timeout tr truncate tty unexpand uniq \
unlink uptime users wc who whoami yes
DIR_USR_SBIN := \
chroot
# BusyBox does not provide these yet
DIR_OTHERS := \
chcon csplit dir dircolors fmt join pathchk pinky pr ptx runcon \
sha224sum sha384sum stdbuf tsort vdir
$(eval $(foreach a,$(DIR_BIN),ALTS_$(a):=300:/bin/$(a):/usr/bin/gnu-$(a)$(newline)))
$(eval $(foreach a,$(DIR_USR_BIN),ALTS_$(a):=300:/usr/bin/$(a):/usr/bin/gnu-$(a)$(newline)))
$(eval $(foreach a,$(DIR_USR_SBIN),ALTS_$(a):=300:/usr/sbin/$(a):/usr/bin/gnu-$(a)$(newline)))
DEPENDS_sort = +libpthread
DEPENDS_timeout = +librt
DEPENDS_expr = +libgmp
@ -68,6 +92,7 @@ define GenPlugin
$(call Package/coreutils/Default)
DEPENDS:=coreutils $(DEPENDS_$(2))
TITLE:=Utility $(2) from the GNU core utilities
ALTERNATIVES:=$(ALTS_$(2))
endef
define Package/$(1)/description
@ -105,7 +130,7 @@ endef
define BuildPlugin
define Package/$(1)/install
$(INSTALL_DIR) $$(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(2) $$(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(2) $$(1)/usr/bin/$(if $(ALTS_$(2)),gnu-$(2),$(2))
$(foreach f,$(FILES_$(2)),
$(INSTALL_DIR) $$(1)/$(dir $(f))
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/$(f) $$(1)/$(f)