#!/usr/bin/env bash # Regenerate ports/busybox/busybox.config: busybox's own `make defconfig` # (almost every applet on), minus the applets listed below that cannot work # on Rustbelt. You only need this when moving to a new busybox version or # changing the list; the build uses the committed busybox.config as is. # # Usage: ports/busybox/mkconfig.sh CACHE_DIR WORK_DIR # (WORK_DIR gets an unpacked busybox; the result is written back to # ports/busybox/busybox.config, so check `git diff` afterwards.) set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd) CACHE=$(realpath "$1") WORK=$(realpath -m "$2") read -r _ file < "$HERE/busybox.sha256" rm -rf "$WORK" && mkdir -p "$WORK" python3 "$HERE/untar.py" "$CACHE/$file" "$WORK" cd "$WORK/${file%.tar.bz2}" make defconfig > /dev/null # Switched off, by group. Each needs something Rustbelt doesn't have and # isn't planned to have soon, so the applet could only ever fail: off=( # Loadable kernel modules (Rustbelt has none). INSMOD RMMOD LSMOD MODPROBE DEPMOD MODINFO MODPROBE_SMALL # Traffic control: needs netlink, and 1.36.1's tc doesn't even compile # against current Linux headers (CBQ was removed from them). TC # Linux network configuration over netlink or raw packet sockets # (Rustbelt configures its network itself, see `ifconfig`). IP IPADDR IPLINK IPROUTE IPTUNNEL IPRULE IPNEIGH BRCTL IFPLUGD NAMEIF TUNCTL VCONFIG IFENSLAVE ETHER_WAKE ARPING ZCIP UDHCPC UDHCPD DHCPRELAY UDHCPC6 DUMPLEASES NBDCLIENT # Flash chips, I2C buses, PCI/USB listings, real-time clock, watchdog: # hardware Rustbelt doesn't expose (no /dev/mtd*, /dev/i2c-*, /sys). NANDWRITE NANDDUMP UBIATTACH UBIDETACH UBIMKVOL UBIRMVOL UBIRSVOL UBIUPDATEVOL UBIRENAME I2CGET I2CSET I2CDUMP I2CDETECT I2CTRANSFER LSPCI LSUSB HWCLOCK WATCHDOG DEVMEM ACPID BEEP SETSERIAL # Linux console fonts, keymaps and framebuffer ioctls (Rustbelt's console # and framebuffer work differently). LOADFONT SETFONT KBD_MODE LOADKMAP DUMPKMAP SETKEYCODES FBSET FBSPLASH CONSPY # Hot-plug (uevents), swap, loop devices, RAID, floppies, ramdisks, # namespaces and switching the root: kernel features Rustbelt lacks. MDEV UEVENT MKSWAP SWAPON SWAPOFF LOSETUP RAIDAUTORUN FDFORMAT FDFLUSH FREERAMDISK EJECT BLKDISCARD FSFREEZE RDEV PIVOT_ROOT SWITCH_ROOT NSENTER UNSHARE SETARCH LINUX32 LINUX64 ADJTIMEX ) # Switched on (defconfig has them off): on=( # busybox lives off PATH (/usr/lib/busybox), so when one applet runs # another (tar -z runs gzip, xargs and find -exec run their command, # adduser runs addgroup) it must not look for it on PATH: with this it # runs its own applet through /proc/self/exe instead. FEATURE_PREFER_APPLETS ) for o in "${on[@]}"; do grep -q "^# CONFIG_$o is not set" .config || { echo "[mkconfig] CONFIG_$o is not off in defconfig"; exit 1; } sed -i "s/^# CONFIG_$o is not set/CONFIG_$o=y/" .config done for o in "${off[@]}"; do grep -q "^CONFIG_$o=y" .config || { echo "[mkconfig] CONFIG_$o is not in defconfig"; exit 1; } sed -i "s/^CONFIG_$o=y/# CONFIG_$o is not set/" .config done { yes "" || true; } | make oldconfig > /dev/null # (yes ends by SIGPIPE) # Drop the generated date line so the file only changes when options do. grep -v '^# [A-Z][a-z][a-z] [A-Z][a-z][a-z] ' .config > "$HERE/busybox.config" echo "[mkconfig] wrote $HERE/busybox.config: $(grep -c '=y' "$HERE/busybox.config") options on, ${#off[@]} applets switched off, ${#on[@]} option(s) switched on"