grep: alternatives instead of postinst

Signed-off-by: Huangbin Zhan <zhanhb88@gmail.com>
This commit is contained in:
Huangbin Zhan 2020-06-23 22:32:33 +08:00
parent 6b5fa7e9b9
commit 413027e865
1 changed files with 9 additions and 15 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=grep
PKG_VERSION:=3.4
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@GNU/grep
@ -31,6 +31,10 @@ define Package/grep
TITLE:=grep search utility - full version
DEPENDS:=+libpcre
URL:=https://www.gnu.org/software/grep/
ALTERNATIVES:=\
300:/bin/egrep:/usr/libexec/egrep-gnu \
300:/bin/fgrep:/usr/libexec/fgrep-gnu \
300:/bin/grep:/usr/libexec/grep-gnu
endef
define Package/grep/description
@ -40,20 +44,10 @@ prints the matching lines.
endef
define Package/grep/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
endef
define Package/grep/postinst
#!/bin/sh
[ -L "$${IPKG_INSTROOT}/bin/grep" ] && rm -f "$${IPKG_INSTROOT}/bin/grep"
exit 0
endef
define Package/grep/prerm
$${IPKG_INSTROOT}/bin/busybox grep -h 2>&1 | grep -q BusyBox && \
ln -sf busybox $${IPKG_INSTROOT}/bin/grep
exit 0
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/egrep $(1)/usr/libexec/egrep-gnu
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fgrep $(1)/usr/libexec/fgrep-gnu
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/grep $(1)/usr/libexec/grep-gnu
endef
$(eval $(call BuildPackage,grep))