From dd3d64da2f1fb5966b7b1bd36b20ab902f1ccedd Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 11 Nov 2020 16:49:17 -0500 Subject: opkg: Save /bin/busybox and make links This works around a regression in opkg-lede that thoroughly breaks upgrading the busybox package and also allows all of busybox's utility links to be managed using update-alternatives. /bin/busybox is copied instead of hard linked, because /var might be on a separate file system (e.g. tmpfs). --- (limited to 'opkg') 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