From efb8060a591b6ed13c16c4034db43652e03f90d5 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 7 Aug 2020 02:25:50 -0500 Subject: People have been having trouble finding the toybox web page (despite being the first google hit for "android toybox"), and want toybox --help to mention it. I was referred to https://github.com/landley/toybox/issues/50 So add a URL to toybox --help. While I was there, make unrecognized commands (like toybox -?) suggest "toybox --help", move the install instructions to the FAQ page (with a second link from toybox --help), and generally tighten up the help text. Also, "toybox -*" is no longer a synonym for --long. Oh, and I fixed some build dependencies when Config.in changes. --- Config.in | 17 +++++++---------- Makefile | 6 ++---- main.c | 4 ++-- scripts/make.sh | 2 +- www/faq.html | 29 +++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/Config.in b/Config.in index 362b22f3..aced2ab9 100644 --- a/Config.in +++ b/Config.in @@ -13,19 +13,16 @@ config TOYBOX bool default y help - usage: toybox [--long | --help | --version | [command] [arguments...]] + usage: toybox [--long | --help | --version | [COMMAND] [ARGUMENTS...]] - With no arguments, shows available commands. First argument is - name of a command to run, followed by any arguments to that command. + Toybox multicall binary: https://landley.net/toybox/about.html - --long Show path to each command + With no arguments, "toybox" shows available COMMAND names. Add --long + to include suggested install path for each command, see + https://landley.net/toybox/faq.html#install for details. - To install command symlinks with paths, try: - for i in $(/bin/toybox --long); do ln -s /bin/toybox $i; done - or all in one directory: - for i in $(./toybox); do ln -s toybox $i; done; PATH=$PWD:$PATH - - Most toybox commands also understand the following arguments: + First argument is name of a COMMAND to run, followed by any ARGUMENTS + to that command. Most toybox commands also understand: --help Show command help (only) --version Show toybox version (only) diff --git a/Makefile b/Makefile index ede910cb..4da90ded 100644 --- a/Makefile +++ b/Makefile @@ -13,13 +13,11 @@ all: toybox KCONFIG_CONFIG ?= .config -toybox_stuff: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*/*.c scripts/*.sh - -toybox generated/unstripped/toybox: toybox_stuff +toybox generated/unstripped/toybox: $(KCONFIG_CONFIG) *.[ch] lib/*.[ch] toys/*/*.c scripts/*.sh Config.in scripts/make.sh .PHONY: clean distclean baseline bloatcheck install install_flat \ - uinstall uninstall_flat tests help toybox_stuff change \ + uinstall uninstall_flat tests help change \ list list_working list_pending root run_root include kconfig/Makefile diff --git a/main.c b/main.c index dbb84cf4..ffa735e3 100644 --- a/main.c +++ b/main.c @@ -64,7 +64,7 @@ static void unknown(char *name) { toys.exitval = 127; toys.which = toy_list; - error_exit("Unknown command %s", name); + help_exit("Unknown command %s", name); } // Setup toybox global state for this command. @@ -193,7 +193,7 @@ void toybox_main(void) // For early error reporting toys.which = toy_list; - if (toys.argv[1] && toys.argv[1][0] != '-') unknown(toys.argv[1]); + if (toys.argv[1] && strcmp(toys.argv[1], "--long")) unknown(toys.argv[1]); // Output list of command. for (i = 1; i +
  • How do I install toybox?

  • How do I cross compile toybox?

  • Where does toybox fit into the Linux/Android ecosystem?
    @@ -237,6 +238,34 @@ instead of the toybox version (in theory they should work the same), and VERBOSE=1 to see diffs of the expected and actual output when a test fails (VERBOSE=fail to stop at the first such failure)

    +
    +

    Q: How do I install toybox?

    + +

    A: +Multicall binaries like toybox behave differently based on the filename +used to call them, so if you "mv toybox ls; ./ls" it acts like ls. Creating +symlinks or hardlinks and adding them to the $PATH lets you run the +commands normally by name.

    + +

    If you already have a toybox binary +you can install a tree of command symlinks living in +the +standard path +locations (export PATH=/bin:/usr/bin:/sbin:/usr/sbin) by doing:

    + +

    for i in $(/bin/toybox --long); do ln -s /bin/toybox $i; done

    + +

    or you can install all the symlinks in the same directory as the toybox binary +(export PATH="$PWD:$PATH") via:

    + +

    for i in $(./toybox); do ln -s toybox $i; done

    + +

    When building from source, use the "make install" and +"make install_flat" +targets with an appropriate PREFIX=/path/to/new/directory either +exported or on the make command line +(as mentioned in "make help" output).

    +

    Q: How do I cross compile toybox?

    -- cgit v1.2.3