[OpenWrt-Devel] [PATCH 1/5] include/package: Add generic macro for replacing BusyBox applets

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


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

There are a number of packages in base and feeds
that provide full versions of commands that are
provided by busybox either by default or as a
configure option.  Here we add a macro that makes
installation/uninstallation of the full version
work smoothly (so that --force-overwrite is
unnecessary and so that so on uninstall the busybox
functionality is restored, if the applicable
applet has been included in busybox).

It does require making sure that if busybox
applet is installed in /bin that the full
version is in /usr/bin and vice versa (and
similarly with /sbin and /usr/sbin) so that
the path of the file in the package doesn't
conflict with the symlink to busybox that
exists in the stock image, so that on
installation/deinstallation of the package
we simply point symlinks at the right target
and at the same time that even if the command isn't
in the 'standard' location there is a symlink so that
any program or configuration that depends or
defaults to a particular path still works.

Signed-off-by: Daniel Dickinson <openwrt at daniel.thecshore.com>
---
 include/package.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/package.mk b/include/package.mk
index 1dfbd68..012b504 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -233,6 +233,21 @@ define Build/IncludeOverlay
   endef
 endef
 
+define Package/BusyBoxReplacement/Default
+  define Package/$(1)/postinst
+  #!/bin/sh
+  ln -sf $(3)/$(5) $${IPKG_INSTROOT}/$(2)/$(5)
+  $(6)
+  exit 0
+  endef
+  define Package/$(1)/postrm
+  #!/bin/sh
+  /bin/busybox $(5) -h 2>&1 | grep -q BusyBox && ln -sf $(if $(4),$(4)/)busybox $(2)/$(5) || rm -f $(2)/$(5)
+  $(7)
+  exit 0
+  endef
+endef
+
 define BuildPackage
   $(Build/IncludeOverlay)
   $(eval $(Package/Default))
-- 
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