10f66f451Sopenharmony_ciToybox: all-in-one Linux command line.
20f66f451Sopenharmony_ci
30f66f451Sopenharmony_ci--- Getting started
40f66f451Sopenharmony_ci
50f66f451Sopenharmony_ciYou can download static binaries for various targets from:
60f66f451Sopenharmony_ci
70f66f451Sopenharmony_ci  http://landley.net/toybox/bin
80f66f451Sopenharmony_ci
90f66f451Sopenharmony_ciThe special name "." indicates the current directory (just like ".." means
100f66f451Sopenharmony_cithe parent directory), and you can run a program that isn't in the $PATH by
110f66f451Sopenharmony_cispecifying a path to it, so this should work:
120f66f451Sopenharmony_ci
130f66f451Sopenharmony_ci  wget http://landley.net/toybox/bin/toybox-x86_64
140f66f451Sopenharmony_ci  chmod +x toybox-x86_64
150f66f451Sopenharmony_ci  ./toybox-x86_64 echo hello world
160f66f451Sopenharmony_ci
170f66f451Sopenharmony_ci--- Building toybox
180f66f451Sopenharmony_ci
190f66f451Sopenharmony_ciType "make help" for build instructions.
200f66f451Sopenharmony_ci
210f66f451Sopenharmony_ciToybox uses the "make menuconfig; make; make install" idiom same as
220f66f451Sopenharmony_cithe Linux kernel. Usually you want something like:
230f66f451Sopenharmony_ci
240f66f451Sopenharmony_ci  make defconfig
250f66f451Sopenharmony_ci  make
260f66f451Sopenharmony_ci  make install
270f66f451Sopenharmony_ci
280f66f451Sopenharmony_ciOr maybe:
290f66f451Sopenharmony_ci
300f66f451Sopenharmony_ci  LDFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox
310f66f451Sopenharmony_ci  PREFIX=/path/to/root/filesystem/bin make install_flat
320f66f451Sopenharmony_ci
330f66f451Sopenharmony_ciThe file "configure" defines default values for many environment variables
340f66f451Sopenharmony_cithat control the toybox build; if you export any of these variables into your
350f66f451Sopenharmony_cienvironment, your value is used instead of the default in that file.
360f66f451Sopenharmony_ci
370f66f451Sopenharmony_ciThe CROSS_COMPILE argument above is optional, the default builds a version of
380f66f451Sopenharmony_citoybox to run on the current machine. Cross compiling requires an appropriately
390f66f451Sopenharmony_ciprefixed cross compiler toolchain, several example toolchains (built using
400f66f451Sopenharmony_cithe file "scripts/mcm-buildall.sh" in the toybox source) are available at:
410f66f451Sopenharmony_ci
420f66f451Sopenharmony_ci  https://landley.net/toybox/downloads/binaries/toolchains/latest
430f66f451Sopenharmony_ci
440f66f451Sopenharmony_ciFor the "CROSS_COMPILE=armv5l-" example above, download
450f66f451Sopenharmony_ciarmv5l-linux-musleabihf-cross.tar.xz, extract it, and add its "bin"
460f66f451Sopenharmony_cisubdirectory to your $PATH. (And yes, the trailing - is significant,
470f66f451Sopenharmony_cibecause the prefix includes a dash.)
480f66f451Sopenharmony_ci
490f66f451Sopenharmony_ciFor more about cross compiling, see:
500f66f451Sopenharmony_ci
510f66f451Sopenharmony_ci  https://landley.net/toybox/faq.html#cross
520f66f451Sopenharmony_ci  http://landley.net/writing/docs/cross-compiling.html
530f66f451Sopenharmony_ci  http://landley.net/aboriginal/architectures.html
540f66f451Sopenharmony_ci
550f66f451Sopenharmony_ciFor a more thorough description of the toybox build process, see:
560f66f451Sopenharmony_ci
570f66f451Sopenharmony_ci  http://landley.net/toybox/code.html#building
580f66f451Sopenharmony_ci
590f66f451Sopenharmony_ci--- Using toybox
600f66f451Sopenharmony_ci
610f66f451Sopenharmony_ciThe toybox build produces a multicall binary, a "swiss-army-knife" program
620f66f451Sopenharmony_cithat acts differently depending on the name it was called by (cp, mv, cat...).
630f66f451Sopenharmony_ciInstalling toybox adds symlinks for each command name to the $PATH.
640f66f451Sopenharmony_ci
650f66f451Sopenharmony_ciThe special "toybox" command treats its first argument as the command to run.
660f66f451Sopenharmony_ciWith no arguments, it lists available commands. This allows you to use toybox
670f66f451Sopenharmony_ciwithout installing it, and is the only command that can have an arbitrary
680f66f451Sopenharmony_cisuffix (hence "toybox-armv5l").
690f66f451Sopenharmony_ci
700f66f451Sopenharmony_ciThe "help" command provides information about each command (ala "help cat"),
710f66f451Sopenharmony_ciand "help toybox" provides general information about toybox.
720f66f451Sopenharmony_ci
730f66f451Sopenharmony_ci--- Configuring toybox
740f66f451Sopenharmony_ci
750f66f451Sopenharmony_ciIt works like the Linux kernel: allnoconfig, defconfig, and menuconfig edit
760f66f451Sopenharmony_cia ".config" file that selects which features to include in the resulting
770f66f451Sopenharmony_cibinary. You can save and re-use your .config file, but may want to
780f66f451Sopenharmony_cirun "make oldconfig" to re-run the dependency resolver when migrating to
790f66f451Sopenharmony_cinew versions.
800f66f451Sopenharmony_ci
810f66f451Sopenharmony_ciThe maximum sane configuration is "make defconfig": allyesconfig isn't
820f66f451Sopenharmony_cirecommended as a starting point for toybox because it enables unfinished
830f66f451Sopenharmony_cicommands, debug code, and optional dependencies your build environment may
840f66f451Sopenharmony_cinot provide.
850f66f451Sopenharmony_ci
860f66f451Sopenharmony_ci--- Creating a Toybox-based Linux system
870f66f451Sopenharmony_ci
880f66f451Sopenharmony_ciToybox has a built-in simple system builder (scripts/mkroot.sh) with a
890f66f451Sopenharmony_ciMakefile target:
900f66f451Sopenharmony_ci
910f66f451Sopenharmony_ci  make root
920f66f451Sopenharmony_ci  sudo chroot root/host/fs /init
930f66f451Sopenharmony_ci
940f66f451Sopenharmony_ciType "exit" to get back out. If you install appropriate cross compilers and
950f66f451Sopenharmony_cipoint it at Linux source code, it can build simple three-package systems
960f66f451Sopenharmony_cithat boot to a shell prompt under qemu:
970f66f451Sopenharmony_ci
980f66f451Sopenharmony_ci  make root CROSS_COMPILE=sh4-linux-musl- LINUX=~/linux
990f66f451Sopenharmony_ci  cd root/sh4
1000f66f451Sopenharmony_ci  ./qemu-sh4.sh
1010f66f451Sopenharmony_ci
1020f66f451Sopenharmony_ciBy calling scripts/mkroot.sh directly you can add additional packages
1030f66f451Sopenharmony_cito the build, see scripts/root/dropbear as an example.
1040f66f451Sopenharmony_ci
1050f66f451Sopenharmony_ciThe FAQ explains this in a lot more detail:
1060f66f451Sopenharmony_ci
1070f66f451Sopenharmony_ci  https://landley.net/toybox/faq.html#system
1080f66f451Sopenharmony_ci  https://landley.net/toybox/faq.html#mkroot
1090f66f451Sopenharmony_ci
1100f66f451Sopenharmony_ci--- Presentations
1110f66f451Sopenharmony_ci
1120f66f451Sopenharmony_ci1) "Why Toybox?" talk at the Embedded Linux Conference in 2013
1130f66f451Sopenharmony_ci
1140f66f451Sopenharmony_ci    outline: http://landley.net/talks/celf-2013.txt
1150f66f451Sopenharmony_ci    video: http://youtu.be/SGmtP5Lg_t0
1160f66f451Sopenharmony_ci
1170f66f451Sopenharmony_ci    The https://landley.net/toybox/about.html page has nav links breaking that
1180f66f451Sopenharmony_ci    talk down into sections.
1190f66f451Sopenharmony_ci
1200f66f451Sopenharmony_ci2) "Why Public Domain?" The rise and fall of copyleft, Ohio LinuxFest 2013
1210f66f451Sopenharmony_ci
1220f66f451Sopenharmony_ci    outline: http://landley.net/talks/ohio-2013.txt
1230f66f451Sopenharmony_ci    audio: https://archive.org/download/OhioLinuxfest2013/24-Rob_Landley-The_Rise_and_Fall_of_Copyleft.mp3
1240f66f451Sopenharmony_ci
1250f66f451Sopenharmony_ci3) Why did I do Aboriginal Linux (which led me here)
1260f66f451Sopenharmony_ci
1270f66f451Sopenharmony_ci    260 slide presentation:
1280f66f451Sopenharmony_ci      https://speakerdeck.com/landley/developing-for-non-x86-targets-using-qemu
1290f66f451Sopenharmony_ci
1300f66f451Sopenharmony_ci    How and why to make android self-hosting:
1310f66f451Sopenharmony_ci      http://landley.net/aboriginal/about.html#selfhost
1320f66f451Sopenharmony_ci
1330f66f451Sopenharmony_ci    More backstory than strictly necessary:
1340f66f451Sopenharmony_ci      https://landley.net/aboriginal/history.html
1350f66f451Sopenharmony_ci
1360f66f451Sopenharmony_ci4) What's new with toybox (ELC 2015 status update):
1370f66f451Sopenharmony_ci
1380f66f451Sopenharmony_ci    video: http://elinux.org/ELC_2015_Presentations
1390f66f451Sopenharmony_ci    outline: http://landley.net/talks/celf-2015.txt
1400f66f451Sopenharmony_ci
1410f66f451Sopenharmony_ci5) Toybox vs BusyBox (2019 ELC talk):
1420f66f451Sopenharmony_ci
1430f66f451Sopenharmony_ci    outline: http://landley.net/talks/elc-2019.txt
1440f66f451Sopenharmony_ci    video: https://www.youtube.com/watch?v=MkJkyMuBm3g
1450f66f451Sopenharmony_ci
1460f66f451Sopenharmony_ci--- Contributing
1470f66f451Sopenharmony_ci
1480f66f451Sopenharmony_ciThe three important URLs for communicating with the toybox project are:
1490f66f451Sopenharmony_ci
1500f66f451Sopenharmony_ci  web page: http://landley.net/toybox
1510f66f451Sopenharmony_ci
1520f66f451Sopenharmony_ci  mailing list: http://lists.landley.net/listinfo.cgi/toybox-landley.net
1530f66f451Sopenharmony_ci
1540f66f451Sopenharmony_ci  git repo: http://github.com/landley/toybox
1550f66f451Sopenharmony_ci
1560f66f451Sopenharmony_ciThe maintainer prefers patches be sent to the mailing list. If you use git,
1570f66f451Sopenharmony_cithe easy thing to do is:
1580f66f451Sopenharmony_ci
1590f66f451Sopenharmony_ci  git format-patch -1 $HASH
1600f66f451Sopenharmony_ci
1610f66f451Sopenharmony_ciThen send a file attachment. The list holds messages from non-subscribers
1620f66f451Sopenharmony_cifor moderation, but I usually get to them in a day or two.
1630f66f451Sopenharmony_ci
1640f66f451Sopenharmony_ciI download github pull requests as patches and apply them with "git am"
1650f66f451Sopenharmony_ci(which avoids gratuitous merge commits). Sometimes I even remember to close
1660f66f451Sopenharmony_cithe pull request.
1670f66f451Sopenharmony_ci
1680f66f451Sopenharmony_ciIf I haven't responded to your patch after one week, feel free to remind
1690f66f451Sopenharmony_cime of it.
1700f66f451Sopenharmony_ci
1710f66f451Sopenharmony_ciAndroid's policy for toybox patches is that non-build patches should go
1720f66f451Sopenharmony_ciupstream first (into vanilla toybox, with discussion on the toybox mailing
1730f66f451Sopenharmony_cilist) and then be pulled into android's toybox repo from there. (They
1740f66f451Sopenharmony_cigenerally resync on fridays). The exception is patches to their build scripts
1750f66f451Sopenharmony_ci(Android.mk and the checked-in generated/* files) which go directly to AOSP.
1760f66f451Sopenharmony_ci
1770f66f451Sopenharmony_ci(As for the other meaning of "contributing", https://patreon.com/landley is
1780f66f451Sopenharmony_cialways welcome but I warn you up front I'm terrible about updating it.)
179