Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions classes/init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
buildVars: [CONFIG_INIT]
buildSetup: |
# Checks if the init system is the sysv sysvinit variant.
initIsSysvinitSysv()
{
[[ ${CONFIG_INIT:-} == "sysvinit/sysv" ]]
}

# Checks if the init system is the busybox sysvinit variant.
initIsSysvinitBusybox()
{
[[ ${CONFIG_INIT:-} == "sysvinit/busybox" ]]
}

# Checks if the init system is any of the supported sysvinit variants.
initIsAnySysvinit()
{
[[ ${CONFIG_INIT:-} == "sysvinit" ]] || initIsSysvinitSysv || initIsSysvinitBusybox
}
18 changes: 12 additions & 6 deletions classes/rootfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,20 @@ buildSetup: |
# $2+: source directories to search for bob files
rootfsPrepare()
{
# set hostname; defaults to "demo"
rootfsSetHostname "$1" "${CONFIG_HOSTNAME:-demo}"
# set hostname
if [[ ${CONFIG_HOSTNAME:+set} ]]; then
rootfsSetHostname "$1" "${CONFIG_HOSTNAME}"
fi

# set timezone; defaults to "Europe/Berlin"
rootfsSetTimezone "$1" "${CONFIG_TZ:-Europe/Berlin}"
# set timezone
if [[ ${CONFIG_TZ:+set} ]]; then
rootfsSetTimezone "$1" "${CONFIG_TZ}"
fi

# set root pw; defaults to "root"
rootfsSetRootPw "$1" "${CONFIG_ROOT_PW:-root}" "${CONFIG_ROOT_PW_SALT:-}"
# set root pw
if [[ ${CONFIG_ROOT_PW:+set} ]]; then
rootfsSetRootPw "$1" "${CONFIG_ROOT_PW}" "${CONFIG_ROOT_PW_SALT:-}"
fi

# Search for all user-table files and cat them into one file
rootfsMergeUserTables $USER_TABLE_FILE "${@:2}"
Expand Down
87 changes: 68 additions & 19 deletions recipes/core/busybox.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,61 @@
inherit: [make, install, kconfig]
inherit: [make, install, kconfig, patch, init]

depends:
- if: "${BUSYBOX_CUSTOM_CONFIG:-}"
name: core::busybox-custom-config
name: "${BUSYBOX_CUSTOM_CONFIG_PKG:-core::busybox-custom-config}"

metaEnvironment:
PKG_VERSION: "1.35.0"
PKG_VERSION: "1.37.0"
PKG_LICENSE: "GPL-2.0, bzip2-1.0.4"

checkoutSCM:
scm: url
url: https://busybox.net/downloads/busybox-${PKG_VERSION}.tar.bz2
digestSHA1: "36a1766206c8148bc06aca4e1f134016d40912d0"
digestSHA1: "50efee4e4438b8aea90ea6895dac818d23125549"
stripComponents: 1

checkoutDeterministic: True
checkoutScript: |
patchApplySeries $<@busybox/*.patch@>

buildTools: [host-toolchain, target-toolchain]
buildVars: [ARCH, BUSYBOX_CUSTOM_CONFIG, CFLAGS, CROSS_COMPILE, LDFLAGS]
buildVars: [BUSYBOX_CONFIG, BUSYBOX_CUSTOM_CONFIG, BUSYBOX_CUSTOM_CONFIG_PKG, BASEMENT_DEBUG,
ARCH, CFLAGS, CROSS_COMPILE, LDFLAGS]
buildScript: |
# prevent timestamps in configuration
export KCONFIG_NOTIMESTAMP=1

mkdir -p build install
pushd build

# where does the config come from?
if [[ ${BUSYBOX_CUSTOM_CONFIG:+true} ]] ; then
cp -u "${BOB_DEP_PATHS[core::busybox-custom-config]}/${BUSYBOX_CUSTOM_CONFIG}" .config
make -C $1 O=$PWD oldconfig
PKG="${BUSYBOX_CUSTOM_CONFIG_PKG:-core::busybox-custom-config}"
CFG="${BOB_DEP_PATHS[$PKG]}/$BUSYBOX_CUSTOM_CONFIG"
elif [[ ${BUSYBOX_CONFIG:+true} ]] ; then
CFG="$1/configs/${BUSYBOX_CONFIG}"
else
make -C $1 O=$PWD defconfig
kconfigEnable CONFIG_DEBUG
make -C $1 O=$PWD oldconfig
CFG="defconfig"
fi

# check if the defconfig exists
if [[ ! -f "$CFG" ]]; then
>&2 echo "Don't know how to use '$CFG' as busybox config!"
false
fi

# check if the source defconfig changed
if [[ ! -f .config || .config -ot $CFG ]]; then
cp -u $CFG .config
# enable debug symbols if requested
[[ ${BASEMENT_DEBUG:-0} != "0" ]] && kconfigEnable CONFIG_DEBUG
make -C $1 O=$PWD \
oldconfig
fi
makeParallel
make CONFIG_PREFIX=${BOB_CWD}/install install

makeParallel CONFIG_PREFIX=${BOB_CWD}/install \
install

popd #build

if [[ -f build/busybox_unstripped ]] ; then
Expand All @@ -43,15 +67,40 @@ buildScript: |
mkdir -p install/.bob

# busybox must be setuid if configured
grep -qE '^CONFIG_FEATURE_SUID=y$' build/.config && \
(printf '/usr/bin/busybox f 4755 0 0 - - - - -\n' > install/.bob/busybox.device-table) ||:
if kconfigIsSet CONFIG_FEATURE_SUID build/.config; then
printf '/usr/bin/busybox f 4755 0 0 - - - - -\n' > install/.bob/busybox.device-table
fi

# add configured shells
(
printf '/bin/sh\n/usr/bin/sh\n'
grep -qE '^CONFIG_SHELL_ASH=y$' build/.config && printf '/bin/ash\n/usr/bin/ash\n' ||:
grep -qE '^CONFIG_SHELL_HUSH=y$' build/.config && printf '/bin/hush\n/usr/bin/hush\n' ||:
) > install/.bob/busybox.shell-table
printf '/bin/sh\n/usr/bin/sh\n' > install/.bob/busybox.shell-table
if kconfigIsSet CONFIG_SHELL_ASH build/.config; then
printf '/bin/ash\n/usr/bin/ash\n' >> install/.bob/busybox.shell-table
fi
if kconfigIsSet CONFIG_SHELL_HUSH build/.config; then
printf '/bin/hush\n/usr/bin/hush\n' >> install/.bob/busybox.shell-table
fi

# install basic inittab if enabled
if kconfigIsSet CONFIG_FEATURE_USE_INITTAB build/.config; then
install -D -m 0644 $<@busybox/inittab@> install/etc/inittab
fi

# install basic rc scripts if enabled
if kconfigIsSet CONFIG_INIT build/.config; then
install -D -m 0777 $<@busybox/rcS@> install/etc/init.d/rcS
install -D -m 0777 $<@busybox/rcK@> install/etc/init.d/rcK
fi

# install udhcpc script if enabled
if kconfigIsSet CONFIG_UDHCPC build/.config; then
install -D -m 0755 $<@busybox/udhcpc.script@> install/usr/share/udhcpc/default.script
fi

if initIsAnySysvinit; then
if kconfigIsSet CONFIG_HWCLOCK build/.config; then
install -D -m 0755 $<@busybox/S09hwclock.sh@> install/etc/init.d/S09hwclock.sh
fi
fi

packageScript: |
installCopy "$1/install/"
29 changes: 29 additions & 0 deletions recipes/core/busybox/S09hwclock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# Synchronize to hw clock
#

start() {
hwclock -us
}

stop() {
hwclock -uw
}

restart() {
stop
sleep 1
start
}

case "$1" in
start|stop|restart)
"$1";;
reload)
# Restart, since there is no true "reload" feature.
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
49 changes: 49 additions & 0 deletions recipes/core/busybox/busybox-add-missing-sha-NI-guard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From andre.przywara at arm.com Tue Sep 10 13:32:46 2024
From: andre.przywara at arm.com (Andre Przywara)
Date: Tue, 10 Sep 2024 14:32:46 +0100
Subject: [PATCH] libbb/sha: add missing sha-NI guard
Message-ID: <20240910133246.3726861-1-andre.przywara@arm.com>

The ENABLE_SHA1_HWACCEL Kconfig symbol is meant to be archicture
agnostic, so can be enabled regardless of whether your build
architecture provides hardware acceleration or not. At the moment only
x86 implements this, so every piece of optimised code should be guarded
by both ENABLE_SHA1_HWACCEL and (__x86_64__ || __i386__). This is missing
at one place, so compiling for arm64 breaks when ENABLE_SHA1_HWACCEL is
enabled:
================================
libbb/hash_md5_sha.c: In function ?sha1_end?:
libbb/hash_md5_sha.c:1316:28: error: ?sha1_process_block64_shaNI? undeclared (first use in this function); did you mean ?sha1_process_block64??
1316 | || ctx->process_block == sha1_process_block64_shaNI
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| sha1_process_block64
libbb/hash_md5_sha.c:1316:28: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [scripts/Makefile.build:197: libbb/hash_md5_sha.o] Error 1
make: *** [Makefile:744: libbb] Error 2
================================

Add the missing guards around the call to sha1_process_block64_shaNI to
fix the build on other architectures with ENABLE_SHA1_HWACCEL enabled.

Change-Id: I40bba388422625f4230abf15a5de23e1fdc654fc
Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
libbb/hash_md5_sha.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index 57a801459..75a61c32c 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -1313,7 +1313,9 @@ unsigned FAST_FUNC sha1_end(sha1_ctx_t *ctx, void *resbuf)
hash_size = 8;
if (ctx->process_block == sha1_process_block64
#if ENABLE_SHA1_HWACCEL
+# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|| ctx->process_block == sha1_process_block64_shaNI
+# endif
#endif
) {
hash_size = 5;
--
2.25.1
23 changes: 23 additions & 0 deletions recipes/core/busybox/inittab
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Startup the system

::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
# The linux kernel does not mount /dev in case of an ramdisk. So check if it is
# already mounted and if not mount it before creating any subdirs in it.
::sysinit:/bin/sh -c '/bin/grep -q /dev /proc/mounts || mount /dev'
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
::sysinit:/bin/mount -a
::sysinit:/bin/mkdir -p /run/lock/subsys
::sysinit:/sbin/swapon -a
::sysinit:/bin/hostname -F /etc/hostname

# now run any rc scripts
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL

# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
29 changes: 29 additions & 0 deletions recipes/core/busybox/rcK
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# This file comes from buildroot and is licensed under GPLv2.


# Stop all init scripts in /etc/init.d
# executing them in reversed numerical order.
#
for i in $(ls -r /etc/init.d/S??*) ;do

# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue

case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set stop
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i stop
;;
esac
done

29 changes: 29 additions & 0 deletions recipes/core/busybox/rcS
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# This file comes from buildroot and is licensed under GPLv2.


# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do

# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue

case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done

Loading