[Toybox] Toybox Installer/setup routine?

Rob Landley rob at landley.net
Mon Sep 2 14:58:12 PDT 2019


On 9/1/19 8:47 PM, Denys Nykula wrote:
>> Which is where we come back to the question, what and how are others 
>> dealing with this problem and is there a need for a simple and basic 
>> installer inside toybox?
> 
> In gentoo I have this /etc/portage/bashrc hook symlink toybox to every
> command missing or linked to nowhere, after package install or removal:
> 
> if test "$EBUILD_PHASE" = postinst || test "$EBUILD_PHASE" = postrm; then
>   for i in `toybox`; do
>     toybox which $i 2>&1 >/dev/null || toybox ln -fsv toybox /bin/$i
>   done
>   which awk 2>&1 >/dev/null || ln -fsv nawk /bin/awk
>   which vi 2>&1 >/dev/null || ln -fsv vim /bin/vi
> fi

Those last two are on the todo list. But after toysh and route, which mkroot
needs. (And vi might be after make, and promoting half the stuff currently in
pending.)

> Since I symlink `/sbin` to `bin` and `/usr` to `.`,

I go the other way with /usr (symlink the top level bin/sbin/lib into usr)
because I don't want more debris (include, local, share...) at the top level.

> I don't have to deal
> with paths. When I need some replacements from busybox:
> 
> for i in head ifconfig route sed; do ln -fsv busybox /bin/$i; done

What do you need head, ifconfig or sed for? (What is the toybox version missing
and/or getting wrong?)

> # Use... And restore toybox:
> find /bin -lname busybox -print -delete
> EBUILD_PHASE=postrm . /etc/portage/bashrc
> 
> You can't link sed-BB to busybox because busybox guesses it's sed by
> name match.

When toybox can't find a command I made it dereference one level of symlink to
get a new name to try. (And then if that name is "toybox", barf.)

> I don't manually touch standalone binaries, letting Portage
> write them over symlinks when installing a build dependency, and after
> their auto removal the above hook returns Toybox.

As long as it doesn't dereference the symlink and stomp the binary at its end.
(The bzip2 installer used to do that to busybox. THAT was a fun one to debug.
And this is why the "install" command has different defaults than the "cp"
command. :)

Rob



More information about the Toybox mailing list