[Toybox] Toybox Installer/setup routine?

Rob Landley rob at landley.net
Sat Sep 7 18:12:19 PDT 2019



On 9/2/19 6:33 PM, scsijon wrote:
> sed was an example I gave, not a direct command.
> 
> On 03/09/19 07:58, Rob Landley wrote:
>> 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.)
> 
> Sorry, but I like vi, it was the first 'editor' I learn't to use on a mainframe
> back in the early years, a lot better and easier than ed was, and you did have
> to be carefull what you did back then as you were working on a 'live' system.

I don't see how that relates to this conversation? I said vi is on the todo
list, but I'm not working on it yet because it's a big job to do it right and
I've currently got my hands full with the shell and need route and make to make
mkroot work so those come first?

It's nice that you've used vi for a long time...?

>>> 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've seen and used these systems, but sorry I prefer to keep some separation,

Have fun with it, again... don't see the relevance?>
>>> 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?)
> 
> not necessary wrong, just not what's wanted in the instance, maybe it's the
> format or it's providing too much information to parse with and therefor taking
> unnecessary processor cycles to process or causing extra cleanup cycles, thus
> taking up visable time.

*blink* *blink. Nope, still not following. Maybe it's me today...

>>
>>> # 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.
>
> I did say it was an example, the change is changing busybox's sed link to sed-BB
> and it works still,

You had /bin/sed pointing to busybox. You replace that with /bin/sed pointing to
toybox. But it was "busybox's link".

How does the symlink belong to either? It points _to_ one of them. But since it
used to point to busybox it's busybox's by divine right?

(Have fun with busybox if that's what you like. I used to maintain it. Heck, I
wrote the majority of busybox sed.)

> trying a sed-BB --version gives a busybox answer (and doing
> it the wrong way gives an applet missing error),

Um, no?

$ busybox sed --version
This is not GNU sed version 4.0
$ toybox sed --version
This is not GNU sed version 9.0

Guess why it does that?

http://lists.busybox.net/pipermail/busybox/2004-January/044644.html

(I can start singing "You're welcome" if it would help?)

> while with toybox installed the
> command sed --version should give a toybox answer and sed-FULL --version gives a
> sed command answer.

In that particular case 2 of the 3 will lie to placate autoconf's regex.

>> 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.)
>
> Not sure I like this, if I understand you correctly, so, with toybox installed,
> I couldn't create a sed-TOY with a link to toybox, and expect toybox's version
> of sed to work, it doesn't do a internal partial-name lookup?

Um, neither does busybox?

$ ln -s $(which busybox) sed-blah
$ ./sed-blah
sed-blah: applet not found

I'm the guy who added the partial name lookup for _busybox_ back in the day
because I started looking at a bug that needed fixing:

http://lists.busybox.net/pipermail/busybox/2005-August/049781.html

And wound up doing https://git.busybox.net/busybox/commit/?id=b766c394569c to
preserve the subset of the behavior that was useful without the "busybox no
longer has devfsd so I can go devfsd rm -rf /" bug.

> If so, sorry, but
> it's a little user unfriendly.

Again, I have NO clue what you mean by this.

What I taught toybox to do is:

  $ ln -s toybox echo
  $ ln -s echo potato
  $ ./potato one two three
  one two three

And that means you CAN have an "echo-toybox" symlink, pointing to ~/toybox/echo,
which is itself a symlink to /bin/toybox. And it should all work fine.

I.E. I implemented a way to do what you want already, you just don't seem to
want to do it that way and want me to implement another way to do the same thing?

But then, I'm having trouble understanding this thread.

Rob



More information about the Toybox mailing list