freebsd-src/usr.sbin/crunch
Martin Tournoij f122045e36 crunchgen: add --list option
"bsdbox --list" will print all tools in the binary, one per line. The
main use case for this is to make it easier to create links:

	for t in $(bsdbox --list); do
		ln -s bsdbox $t
	done

The name --list was taken from busybox.

This just adds a new "program" with the name "--list". I don't think we
need to do real argument parsing here, and this is also how busybox does
it.

An additional minor change is that just "bsdbox" will no longer print
the binary name itself ("bsdbox" in this case). Before it would do:

	% bsdbox
	usage: boxlike <prog> <args> ..., where <prog> is one of:
	 cp ls mv bsdbox

And now just:

	% bsdbox
	usage: boxlike <prog> <args> ..., where <prog> is one of:
	 cp ls mv

And just "bsdbox" will also exit with code 0 (and print to stdout)
rather than exit with 0 and print to stderr

Example output:

	% ./bsdbox
	usage: bsdbox program [args ...]
	       bsdbox --list
	       program [args ...]

	bsdbox combines several programs in one executable. Create a link to this
	executable with the program name to run that program, or give the program
	name as the first argument.

	Currently defined programs:
	 true false tail head uname

	% ./bsdbox --list
	true
	false
	tail
	head
	uname

	% ./bsdbox uname -a
	FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64

	% ln -s bsdbox uname
	% ./uname -a
	FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64

Pull Request:	https://github.com/freebsd/freebsd-src/pull/894
Signed-off-by: Martin Tournoij <martin@arp242.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/894
2024-04-17 12:07:25 -06:00
..
crunchgen crunchgen: add --list option 2024-04-17 12:07:25 -06:00
crunchide Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
examples crunch: remove fdisk from examples 2024-01-24 09:12:19 -05:00
COPYRIGHT
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
README crunch: Fix typo 2024-04-11 11:40:40 -06:00

CRUNCH 0.2 README				6/14/94

Crunch is available via anonymous ftp to ftp.cs.umd.edu in
		pub/bsd/crunch-0.2.tar.gz


WHAT'S NEW IN 0.2

* The prototype awk script has been replaced by a more capable and
  hopefully more robust C program.
* No fragile template makefiles or dependencies on the details of the
  bsd build environment.
* You can build crunched binaries even with no sources on-line, you
  just need the .o files.  Crunchgen still will try to figure out as
  much as possible on its own, but you can override its guessing by
  specifying the list of .o files explicitly.
* Crunch itself has been bmake'd and some man pages written, so it
  should be ready to install.


INTRODUCTION

Crunch is a little package that helps create "crunched" binaries for use
on boot, install, and fixit floppies.  A crunched binary in this case is
one where many programs have been linked together into one a.out file.
The different programs are run depending on the value of argv[0], so
hard links to the crunched binary suffice to simulate a perfectly normal
system.

As an example, I have created an 980K crunched "fixit" binary containing
the following programs in their entirety:

	cat chmod cp date dd df echo ed expr hostname kill ln ls mkdir
	mt mv pwd rcp rm rmdir sh sleep stty sync test [ badsect chown
	clri disklabel dump rdump dmesg fdisk fsck halt ifconfig init
	mknod mount newfs ping reboot restore rrestore swapon umount
	ftp rsh sed telnet rlogin vi cpio gzip gunzip gzcat

Note carefully: vi, cpio, gzip, ed, sed, dump/restore, some networking
utilities, and the disk management utilities, all in a binary small
enough to fit on a 1.2 MB root filesystem floppy (albeit with the kernel
on its own boot floppy).  A more reasonable subset can be made to fit
easily with a kernel for a decent one-disk fixit filesystem.

The linking together of different programs by hand is an old
space-saving technique.  Crunch automates the process by building the
necessary stub files and makefile for you (via the crunchgen program),
and by doctoring the symbol tables of the component .o files to allow
them to link without "symbol multiply defined" conflicts (via the
crunchide program).


BUILDING CRUNCH

Just type make, then make install.

Crunch was written and tested under NetBSD/i386, but should work under
other PC BSD systems that use GNU ld.

The crunchgen(1) and crunchide(1) man pages have more details on using
crunch, and the examples subdirectory contains some working .conf files
and a sample Makefile.

CREDITS

Thanks to the NetBSD team for a consistently high quality effort in
bringing together a solid, state of the art development environment.

Thanks to the FreeBSD guys; Rod Grimes, Nate Williams and Jordan
Hubbard; and to Bruce Evans, for immediate and detailed feedback on
crunch 0.1, and for pressing me to make the prototype more usable.

Crunch was written for the Maruti Hard Real-Time Operating System
project at the University of Maryland, to help make for better install
and recovery procedures for our NetBSD-based development environment. It
is copyright (c) 1994 by the University of Maryland under a UCB-style
freely- redistributable notice.  See the file COPYRIGHT for details.

Please let me know of any problems or of enhancements you make to this
package.  I'm particularly interested in the details of what you found
was good to put on your fixit or install disks.  Thanks!

Share and Enjoy,
Jaime
............................................................................
: Stand on my shoulders, : jds@cs.umd.edu  :                  James da Silva
: not on my toes.        : uunet!mimsy!jds : http://www.cs.umd.edu/users/jds