template (4309B)
1 # Template file for 'busybox' 2 pkgname=busybox 3 version=1.36.1 4 revision=8 5 short_desc="Swiss Army knife of embedded Linux utilities" 6 maintainer="finwo <finwo@pm.me>" 7 license="GPL-2.0-only" 8 homepage="https://busybox.net" 9 distfiles="https://busybox.net/downloads/busybox-1.36.1.tar.bz2" 10 checksum=b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314 11 depends= 12 13 # Applet policy (locked in PLAN.md section 10, enforced by assertions in 14 # do_build - a missing symbol fails the build, never the boot): 15 # 16 # ON: init sequence + supervision + shell + connection handling, i.e. the 17 # whole reason busybox is here, plus console login and mgmt DHCP. 18 # (INIT/HALT/POWEROFF/REBOOT/GETTY/LOGIN/MOUNT/UMOUNT/SWITCH_ROOT are 19 # defconfig defaults; listing them makes the requirement explicit.) 20 # OFF: IP applets (iproute2 is the only `ip`), TC (iproute2's `tc` is 21 # full-featured; busybox's references kernel-removed CBQ UAPI and does not 22 # build against modern headers), LDCONFIG (glibc's real ldconfig owns 23 # /sbin/ldconfig; the applet would conflict on that path and its cache 24 # output must never feed glibc's loader), the xz family (real xz owns 25 # usr/bin/{xz,xzcat,unxz,lzma,unlzma,lzcat} - apk refuses the overwrite 26 # otherwise; six symbols gate them in bbunzip.c, all six go; kernel 27 # initramfs xz stays independent via CONFIG_RD_XZ), 28 # udhcpd (dnsmasq covers the server side), httpd/inetd (tcpsvd is our 29 # super-server), IFUP (linkd owns /etc/network/interfaces via linkctl, busybox 30 # ifupdown would conflict and its `iface <name>` parser is for old 31 # `iface <name> inet static` only -- cumulus `iface <name>` fails there), 32 # MKFS_VFAT/MKDOSFS (dosfstools owns mkfs.vfat; two providers of one command 33 # resolved by PATH order is a trap, and busybox's variant warns about 34 # codepage conversion on every run because it wants iconv data our 35 # C.UTF-8-only glibc does not ship. dosfstools also brings fsck.fat, which 36 # busybox has no equivalent of at all -- and the ESP is the one partition 37 # whose corruption stops the switch booting). 38 # Untouched (defconfig default) until their design lands: SYSLOGD/KLOGD. 39 # No checked-in .config on purpose: defconfig + CFG_* is the source of truth 40 # (this kconfig has no savedefconfig anyway); the assertions below enforce it. 41 CFG_ON="INIT HALT POWEROFF REBOOT GETTY LOGIN MOUNT UMOUNT SWITCH_ROOT ASH ASH_JOB_CONTROL RUNSV RUNSVDIR SV SVLOGD CHPST SETUIDGID TCPSVD UDHCPC" 42 CFG_OFF="IP FEATURE_IP_ADDRESS FEATURE_IP_LINK FEATURE_IP_ROUTE FEATURE_IP_RULE FEATURE_IP_TUNNEL TC LDCONFIG UNLZMA LZCAT LZMA UNXZ XZCAT XZ UDHCPD HTTPD INETD IFUP IFDOWN MKFS_VFAT MKDOSFS" 43 44 # applet names as `busybox --list` prints them 45 REQUIRE="init halt poweroff reboot getty login mount umount switch_root ash runsv runsvdir sv svlogd chpst setuidgid tcpsvd udhcpc" 46 FORBID="ip tc ldconfig unlzma lzcat lzma unxz xzcat xz udhcpd httpd inetd ifup ifdown mkfs.vfat mkdosfs" 47 48 set_config() { 49 # $1 = symbol, $2 = y|n 50 if grep -q "^CONFIG_$1=" .config 2>/dev/null || grep -q "^# CONFIG_$1 is not set$" .config 2>/dev/null; then 51 sed -i -e "s/^# CONFIG_$1 is not set\$/CONFIG_$1=$2/" -e "s/^CONFIG_$1=.*\$/CONFIG_$1=$2/" .config 52 else 53 [ "$2" = y ] && echo "CONFIG_$1=y" >> .config || echo "# CONFIG_$1 is not set" >> .config 54 fi 55 } 56 57 do_configure() { 58 cd "${WRKSRC}" 59 make defconfig >/dev/null 60 for c in ${CFG_ON}; do set_config "${c}" y; done 61 for c in ${CFG_OFF}; do set_config "${c}" n; done 62 # this kconfig has no olddefconfig; resolve non-interactively instead 63 yes "" | make oldconfig >/dev/null 64 for c in ${CFG_ON}; do 65 grep -q "^CONFIG_${c}=y$" .config || die "busybox: CONFIG_${c} did not stick" 66 done 67 } 68 69 do_build() { 70 cd "${WRKSRC}" 71 make -j"$(nproc)" 72 have=$(./busybox --list) 73 for a in ${REQUIRE}; do 74 printf '%s\n' "${have}" | grep -qx "${a}" || die "busybox: required applet missing: ${a}" 75 done 76 for a in ${FORBID}; do 77 printf '%s\n' "${have}" | grep -qx "${a}" && die "busybox: forbidden applet present: ${a}" || true 78 done 79 } 80 81 do_install() { 82 cd "${WRKSRC}" 83 make CONFIG_PREFIX="${DESTDIR}" install 84 # initrd-era fossil: the kernel runs /linuxrc only on classic initrd, and 85 # UNOS boots initramfs-style (/init + switch_root). Prune it so the rootfs 86 # carries no dead symlinks. 87 rm -f "${DESTDIR}/linuxrc" 88 }