[[!meta title="Installing BusyBox Without BusyBox"]] **or, Adventures in Regressions and Crazy Ideas** Two Problems ============ `opkg-lede` and the Outsourced Inflation ---------------------------------------- `opkg-lede` [now relies][opkg-lede-dd4c78a] on an external `gzip` executable. When upgrading a package, it tries to execute `gzip` to unpack maintainer scripts and data files [after removing][opkg_install_pkg] the old version of the package. When the package being upgraded is `busybox`, which provides `gzip`, `opkg` crashes and leaves behind a completely broken system. To reiterate, `opkg-lede` is (and has been for as long as it has been in ProteanOS) **currently unable to upgrade `busybox`**, due to its own design. [opkg-lede-dd4c78a]: https://git.openwrt.org/?p=project/opkg-lede.git;a=commitdiff;h=dd4c78aa88efd3b9cf516030937c684814df7962 [opkg_install_pkg]: https://git.openwrt.org/?p=project/opkg-lede.git;a=blob;f=libopkg/opkg_install.c;hb=d4ba162#l1520 The Amazing Alternatives of `busybox` ------------------------------------- Instead of [adding alternatives][alts] one at a time, [it would be nice][bb-ua] to manage all of `busybox`'s utility links using `update-alternatives`. Unfortunately, the [maintainer script][bb.pi] that runs `update-alternatives` (as well as the [`update-alternatives` script][u-a] itself) needs a few `busybox` utilities (`/bin/sh` for a start). Thus, after an older version of `busybox` is deconfigured, a newer version can't be configured. `busybox` also can't be configured when first unpacked by `prokit`. [alts]: http://git.proteanos.com/pkg/busybox.git/log/alternatives [bb-ua]: http://git.proteanos.com/pkg/busybox.git/commit/?id=1558d05c62ed90f7d93a14533541c33896b7b733 [bb.pi]: http://git.proteanos.com/pkg/busybox.git/tree/busybox.pkg/postinst [u-a]: https://git.openwrt.org/?p=project/opkg-lede.git;a=blob;f=utils/update-alternatives.in;hb=d4ba162 One Solution ============ The next version of `src:opkg-lede` (likely 0+git20190131.d4ba162-7) already will have a [wrapper script called `opkg`][opkg] that executes `opkg-cl` (the actual binary executable). The script can be extended to first save a copy of `/bin/busybox` to an empty temporary directory, generate utility links to it in the directory, and add the directory to `PATH`. Until all of this setup is complete, the wrapper script must be careful to execute utilities as `busybox $util` (a full path to `busybox` won't be necessary, as the usual `/bin/busybox` will be available at that point). This includes the interpreter line, which will need to be changed to `#!/bin/busybox sh`. `ash` built-in utilities can be used as usual. The `busybox` package can't use `update-alternatives` to manage all of its utility links until an `opkg-lede` with this wrapper script functionality is uploaded. This is because, even if `busybox`'s `postinst` script is modified to use the `busybox` executable directly, other packages' maintainer scripts may be executed first, while `busybox` is unpacked but not yet configured (and therefore utility links are not yet created). Once this new `opkg-lede` package is uploaded and `busybox` uses `update-alternatives` for everything, `busybox` would need to declare that it `Breaks` older versions of `opkg-lede`, to ensure that `opkg-lede` will preserve a copy of the `busybox` executable and its utility links. The `opkg` script of the `opkg-lede` package will need to read `busybox`'s list of alternatives links. This is currently located at `/usr/share/busybox/alternatives`, though the file's format will change when `busybox` uses `update-alternatives` for everything. A migration strategy for `opkg-lede` will need to be designed. [opkg]: http://git.proteanos.com/pkg/opkg-lede.git/tree/opkg