summaryrefslogtreecommitdiffstats
path: root/dev/todo/install-bb-without-bb.mdwn
diff options
context:
space:
mode:
Diffstat (limited to 'dev/todo/install-bb-without-bb.mdwn')
-rw-r--r--dev/todo/install-bb-without-bb.mdwn86
1 files changed, 86 insertions, 0 deletions
diff --git a/dev/todo/install-bb-without-bb.mdwn b/dev/todo/install-bb-without-bb.mdwn
new file mode 100644
index 0000000..4bb90ff
--- /dev/null
+++ b/dev/todo/install-bb-without-bb.mdwn
@@ -0,0 +1,86 @@
+[[!meta title="Installing BusyBox Without BusyBox"]]
+
+**or, Adventures in Regressions and Crazy Ideas**
+
+---
+
+**This work is now done.**
+
+**The rest of this page is kept only for reference and historical purposes.**
+
+---
+
+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-log] 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-log]: 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. However, this is
+still insufficient, as the version of `opkg` that is *running* must have already
+set up this environment before `busybox` is upgraded. `busybox`'s `prerm`
+script will need to check for this somehow and abort the upgrade if `opkg` is
+too old to have prepared for a safe upgrade. One solution is for the `opkg`
+script to set an `OPKG_BUSYBOX_SAVED` environment variable.
+
+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`. [The file's format][alts] will change when
+`busybox` uses `update-alternatives` for everything: the last two columns (name
+and priority) will be dropped. `opkg` however can simply read the first column,
+so it will maintain compatibility.
+
+[opkg]: http://git.proteanos.com/pkg/opkg-lede.git/tree/opkg
+[alts]: http://git.proteanos.com/pkg/busybox.git/tree/alternatives?id=e37f03311d934a8f33a9ff31db47b18bbf0be555