# Contributor: Ɓukasz Jendrysik # Contributor: Oliver Smith # Maintainer: Natanael Copa pkgname=busybox pkgver=1.31.1 pkgrel=14 pkgdesc="Size optimized toolbox of many common UNIX utilities" url="https://busybox.net/" arch="all" license="GPL-2.0-only" makedepends_host="linux-headers openssl-dev libtls-standalone-dev" makedepends="$makedepends_build $makedepends_host" checkdepends="zip" provides="/bin/sh" install="$pkgname.post-install $pkgname.post-upgrade $pkgname-extras.post-install $pkgname-extras.pre-deinstall" subpackages="$pkgname-static $pkgname-doc $pkgname-suid $pkgname-extras ssl_client" options="suid !check" replaces="busybox-initscripts" # move of default.script triggers="busybox.trigger=/bin:/usr/bin:/sbin:/usr/sbin:/lib/modules/*" source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2 0001-ln-no-target-directory-implies-no-dereference.patch 0001-nologin-Install-applet-to-sbin-instead-of-usr-sbin.patch 0001-adduser-default-to-sbin-nologin-as-shell-for-system-.patch 0001-properly-fix-wget-https-support.patch 0002-fsck-resolve-LABEL-.-UUID-.-spec-to-device.patch 0003-ash-exec-busybox.static.patch 0004-app-location-for-cpio-vi-and-lspci.patch 0005-udhcpc-set-default-discover-retries-to-5.patch 0006-ping-make-ping-work-without-root-privileges.patch 0007-fbsplash-support-console-switching.patch 0008-fbsplash-support-image-and-bar-alignment-and-positio.patch 0009-depmod-support-generating-kmod-binary-index-files.patch 0010-Add-flag-for-not-following-symlinks-when-recursing.patch 0012-udhcpc-Don-t-background-if-n-is-given.patch 0013-testsuite-fix-cpio-tests.patch busybox-bc.patch nslookup.patch acpid.logrotate busyboxconfig busyboxconfig-extras bbsuid.c dad.if-up ssl_client.c default.script " # secfixes: # 1.30.1-r2: # - CVE-2019-5747 # 1.29.3-r10: # - CVE-2018-20679 # - CVE-2019-5747 # 1.27.2-r4: # - CVE-2017-16544 # - CVE-2017-15873 # - CVE-2017-15874 _staticdir="$srcdir"/build-static _dyndir="$srcdir"/build-dynamic _dyndir_extras="$srcdir"/build-dynamic-extras _config="$srcdir"/busyboxconfig _config_extras="$srcdir"/busyboxconfig-extras prepare() { default_prepare mkdir -p "$_staticdir" "$_dyndir" "$_dyndir_extras" } build() { # build bbsuid msg "Building bbsuid" ${CC:-${CROSS_COMPILE}gcc} ${CPPFLAGS} ${CFLAGS} \ ${LDFLAGS} "$srcdir"/bbsuid.c -o "$_dyndir"/bbsuid msg "Building ssl_client" # shellcheck disable=SC2046 # Allow wordsplitting for pkg-config ${CC:-${CROSS_COMPILE}gcc} ${CPPFLAGS} ${CFLAGS} $(pkg-config --cflags libtls-standalone) \ "$srcdir"/ssl_client.c -o "$_dyndir"/ssl_client ${LDFLAGS} $(pkg-config --libs libtls-standalone) # no timestamp in build export KCONFIG_NOTIMESTAMP=1 # build dynamic cd "$_dyndir" msg "Building dynamic busybox" echo "COPIED CONFIG to $(pwd)/.config" cp "$_config" .config [ "$CLIBC" = musl ] && sed -i \ -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \ .config make -C "$builddir" O="$PWD" silentoldconfig make # build dynamic (extras) cd "$_dyndir_extras" msg "Building dynamic busybox-extras" cp "$_config_extras" .config [ "$CLIBC" = musl ] && sed -i \ -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \ .config make -C "$builddir" O="$PWD" silentoldconfig make # build static cd "$_staticdir" msg "Building static busybox" # enable internal ssl_client for static build sed -e "s/.*CONFIG_PIE.*/\# CONFIG_PIE is not set/" \ -e "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" \ -e "s/.*CONFIG_SSL_CLIENT.*/CONFIG_SSL_CLIENT=y/" \ "$_config" > .config # musl does not support GNU regex [ "$CLIBC" = musl ] && sed -i \ -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \ .config make -C "$builddir" O="$PWD" silentoldconfig make mv busybox busybox.static } check() { cd "$_dyndir" SKIP_KNOWN_BUGS=1 make -C "$builddir" O="$PWD" V=1 check cd "$_dyndir_extras" SKIP_KNOWN_BUGS=1 make -C "$builddir" O="$PWD" V=1 check } package() { cd "$_dyndir" mkdir -p "$pkgdir"/usr/sbin "$pkgdir"/usr/bin "$pkgdir"/tmp \ "$pkgdir"/var/cache/misc "$pkgdir"/bin "$pkgdir"/sbin \ "$pkgdir"/usr/share/man/man1 chmod 1777 "$pkgdir"/tmp install -m755 busybox "$pkgdir"/bin/busybox # we need /bin/sh to be able to execute post-install ln -s /bin/busybox "$pkgdir"/bin/sh install -m 644 docs/busybox.1 "$pkgdir"/usr/share/man/man1/busybox.1 #ifupdown needs those dirs to be present mkdir -p \ "$pkgdir"/etc/network/if-down.d \ "$pkgdir"/etc/network/if-post-down.d \ "$pkgdir"/etc/network/if-post-up.d \ "$pkgdir"/etc/network/if-pre-down.d \ "$pkgdir"/etc/network/if-pre-up.d \ "$pkgdir"/etc/network/if-up.d install -m775 "$srcdir"/dad.if-up "$pkgdir"/etc/network/if-up.d/dad install -Dm644 "$srcdir"/acpid.logrotate \ "$pkgdir/etc/logrotate.d/acpid" mkdir -p "$pkgdir"/var/lib/udhcpd install -Dm644 "$builddir"/examples/udhcp/udhcpd.conf \ "$pkgdir"/etc/udhcpd.conf cat >"$pkgdir"/etc/securetty <