summaryrefslogtreecommitdiffstats
path: root/opkg
diff options
context:
space:
mode:
Diffstat (limited to 'opkg')
-rwxr-xr-xopkg45
1 files changed, 44 insertions, 1 deletions
diff --git a/opkg b/opkg
index 54e2886..33ec19f 100755
--- a/opkg
+++ b/opkg
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/busybox sh
#
# opkg - Multiarch support wrapper for opkg
#
@@ -19,6 +19,45 @@
set -eu
+BB='/bin/busybox'
+BIN='/var/lib/opkg/bin'
+
+save_bb()
+{
+ local file=
+ local link=
+ local name=
+ local prio=
+
+ "${BB}" mkdir "${BIN}" 2>/dev/null || :
+ "${BB}" cp -p "${BB}" "${BIN}/busybox"
+
+ while read file; do
+ case "${file}" in
+ /bin/busybox) ;;
+ /bin/?* | /sbin/?* | /usr/bin/?* | /usr/sbin/?*)
+ "${BB}" ln -sf 'busybox' "${BIN}/${file##*/}"
+ ;;
+ esac
+ done 0<<-EOF
+ $(/usr/bin/opkg-cl files busybox)
+ EOF
+
+ while read link name prio; do
+ "${BB}" ln -sf 'busybox' "${BIN}/${link##*/}"
+ done 0</usr/share/busybox/alternatives
+
+ export PATH="${PATH}:${BIN}"
+ export OPKG_BUSYBOX_SAVED='1'
+
+ return 0
+}
+
+unsave_bb()
+{
+ rm -f "${BIN}/"*
+}
+
main()
{
local first_arg=
@@ -80,9 +119,13 @@ main()
return 1
fi
+ save_bb
+
if /usr/bin/opkg-cl "${@}"; then
+ unsave_bb
return 0
else
+ unsave_bb
return ${?}
fi
}