[OpenWrt-Devel] [PATCH 3/5] package/utils/util-linux: Allow smooth install/uninstall alongside busybox

openwrt at daniel.thecshore.com openwrt at daniel.thecshore.com
Thu Jan 21 12:54:43 EST 2016


From: Daniel Dickinson <openwrt at daniel.thecshore.com>

Rather than have packages that behave badly
when used alongside busybox and/or which fails to
cleanly uninstall, make any package for which there
is a busybox applet work cleanly with busybox (taking
over from busybox when installed, and restoring
busybox when removed as well as behaving properly if the
corresponding busybox applet does not exist in busybox
(that is no extraneous symlink).

Signed-off-by: Daniel Dickinson <openwrt at daniel.thecshore.com>
---
 package/utils/util-linux/Makefile | 55 ++++++++++++++++++++++++++++++++-------
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/package/utils/util-linux/Makefile b/package/utils/util-linux/Makefile
index eddbc2b..e439415 100644
--- a/package/utils/util-linux/Makefile
+++ b/package/utils/util-linux/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=util-linux
 PKG_VERSION:=2.25.2
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.25
@@ -149,6 +149,8 @@ define Package/blkid/description
  library.
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,blkid,/sbin,/usr/sbin,../bin,blkid))
+
 define Package/cal
 $(call Package/util-linux/Default)
   TITLE:=display a calendar
@@ -159,6 +161,8 @@ define Package/cal/description
  cal displays a simple calendar
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,cal,/usr/bin,/bin,../../bin,cal))
+
 define Package/cfdisk
 $(call Package/util-linux/Default)
   TITLE:=display or manipulate disk partition table
@@ -176,6 +180,8 @@ $(call Package/util-linux/Default)
   DEPENDS:= +librt
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,dmesg,/bin,/usr/bin,,dmesg))
+
 define Package/dmesg/description
  dmesg  is used to examine or control the kernel ring buffer
 endef
@@ -191,6 +197,8 @@ define Package/fdisk/description
  a menu-driven program for creation and manipulation of partition tables
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,fdisk,/sbin,/usr/sbin,../bin,fdisk))
+
 define Package/findfs
 $(call Package/util-linux/Default)
   TITLE:=find a filesystem by label or UUID
@@ -203,6 +211,8 @@ define Package/findfs/description
  a label matching label or a UUID equal to uuid
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,findfs,/sbin,/usr/sbin,../bin,findfs))
+
 define Package/flock
 $(call Package/util-linux/Default)
   TITLE:=manage locks from shell scripts
@@ -212,6 +222,8 @@ define Package/flock/description
   manages flock locks from within shell scripts or the command line
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,flock,/usr/bin,/bin,../../bin,flock))
+
 define Package/getopt
 $(call Package/util-linux/Default)
   TITLE:=parse command options (enhanced)
@@ -222,6 +234,8 @@ define Package/getopt/description
  by shell procedures, and to check for legal options
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,getopt,/bin,/usr/bin,,getopt))
+
 define Package/hwclock
 $(call Package/util-linux/Default)
   TITLE:=query or set the hardware clock
@@ -231,6 +245,8 @@ define Package/hwclock/description
  hwclock is a tool for accessing the Hardware Clock
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,hwclock,/sbin,/usr/sbin,../bin,hwclock))
+
 define Package/logger
 $(call Package/util-linux/Default)
   TITLE:=a shell command interface to the syslog system log module
@@ -241,6 +257,8 @@ define Package/logger/description
  to the syslog system log module
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,logger,/usr/bin,/bin,../../bin,logger))
+
 define Package/look
 $(call Package/util-linux/Default)
   TITLE:=display lines beginning with a given string
@@ -261,6 +279,8 @@ define Package/losetup/description
  to detach loop devices and to query the status of a loop device
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,losetup,/sbin,/usr/sbin,../bin,losetup))
+
 define Package/lsblk
 $(call Package/util-linux/Default)
   TITLE:=list block devices
@@ -292,6 +312,11 @@ define Package/mount-utils/description
  contains: mount, umount, findmnt
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,mount-utils,/bin,/usr/bin,,mount,\
+ln -sf /usr/bin/umount $${IPKG_INSTROOT}/bin/umount,\
+/bin/busybox umount -h 2>&1 | grep -q BusyBox && ln -sf busybox /bin/umount \
+))
+
 define Package/namei
 $(call Package/util-linux/Default)
   TITLE:=follow a pathname until a terminal point is found
@@ -344,6 +369,11 @@ define Package/script-utils/description
  contains: script, scriptreplay
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,script-utils,/usr/bin,/bin,../../bin,script,\
+ln -sf /usr/bin/scriptreplay $${IPKG_INSTROOT}/bin/scriptreplay,\
+/bin/busybox scriptreplay -h 2>&1 | grep -q BusyBox && ln -sf busybox /bin/scriptreplay \
+))
+
 define Package/setterm
 $(call Package/util-linux/Default)
   TITLE:=set terminal attributes
@@ -378,6 +408,11 @@ define Package/swap-utils/description
  contains: mkswap, swaplabel
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,swap-utils,/sbin,/usr/sbin,../bin,mkswap,\
+ln -sf /usr/sbin/swaplabel $${IPKG_INSTROOT}/sbin/swaplabel,\
+/bin/busybox swaplabel -h 2>&1 | grep -q BusyBox && ln -sf ../bin/busybox /sbin/swaplabel || rm -f /sbin/swaplabel\
+))
+
 define Package/uuidd
 $(call Package/util-linux/Default)
   TITLE:=UUID generation daemon
@@ -415,6 +450,8 @@ define Package/wall/description
  set to yes
 endef
 
+$(eval $(call Package/BusyBoxReplacement/Default,wall,/usr/bin,/bin,../../bin,wall))
+
 define Package/whereis
 $(call Package/util-linux/Default)
   TITLE:=locate the binary, source, and manual page files for a command
@@ -468,8 +505,8 @@ define Package/blkid/install
 endef
 
 define Package/cal/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(PKG_BUILD_DIR)/cal $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/cal $(1)/bin/
 endef
 
 define Package/cfdisk/install
@@ -493,8 +530,8 @@ define Package/findfs/install
 endef
 
 define Package/flock/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(PKG_BUILD_DIR)/flock $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/flock $(1)/bin/
 endef
 
 define Package/getopt/install
@@ -508,8 +545,8 @@ define Package/hwclock/install
 endef
 
 define Package/logger/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(PKG_BUILD_DIR)/logger $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/logger $(1)/bin/
 endef
 
 define Package/look/install
@@ -562,8 +599,8 @@ define Package/partx-utils/install
 endef
 
 define Package/script-utils/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(PKG_BUILD_DIR)/script $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/usr/bin $(1)/bin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/script $(1)/bin/
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/scriptreplay $(1)/usr/bin/
 endef
 
-- 
2.4.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list