Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Toybox Inittab #239

Closed
wants to merge 3 commits into from
Closed
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
26 changes: 26 additions & 0 deletions meta-oe/recipes-core/toybox/toybox-inittab/inittab
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# STARTUP
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -t sysfs sysfs /sys
::sysinit:/bin/mount -t devtmpfs devtmpfs /dev
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mount -t devpts devpts /dev/pts
::sysinit:/bin/mount -a

::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

::sysinit:/bin/hostname -F /etc/hostname

::sysinit:/etc/init.d/rcS

# REBOOT
::ctrlaltdel:/sbin/reboot
::shutdown:/etc/init.d/rcK
::shutdown:/bin/umount -a -r

# RESTART INIT
::restart:/sbin/init

26 changes: 26 additions & 0 deletions meta-oe/recipes-core/toybox/toybox-inittab/rcK
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# Stop all init scripts in /etc/rc6.d
# executing them in numerical order.
#
for i in /etc/rc6.d/K??*; 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

27 changes: 27 additions & 0 deletions meta-oe/recipes-core/toybox/toybox-inittab/rcS
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Start all init scripts in /etc/rcS.d and /etc/rc5.d
# executing them in numerical order.
#

for i in /etc/rcS.d/S??* /etc/rc5.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

61 changes: 61 additions & 0 deletions meta-oe/recipes-core/toybox/toybox-inittab_0.8.2.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
SUMMARY = "Toybox Inittab Configuration"
LICENSE = "BSD-0-Clause"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/BSD-0-Clause;md5=81eeb0083e31f11ab1e33ded846d521c"

SRC_URI = "\
file://inittab \
file://rcK \
file://rcS \
"

PACKAGE_ARCH = "${MACHINE_ARCH}"

RCONFLICTS_${PN} = "\
busybox-inittab \
sysvinit-inittab \
"

# most users may want to have getty enabled by default
PACKAGECONFIG ??= "getty"

PACKAGECONFIG[getty] = "\
enable_getty \
"

do_patch[noexec] = "1"

do_configure() {
# copy over files now to have a fresh start on each config
for file in ${SRC_URI}; do
cp ${WORKDIR}/${file/file:\/\//} ${S}
done

for config in ${PACKAGECONFIG_CONFARGS}; do
if [[ ${config} == "enable_getty" ]]; then
echo "# generated by bitbake recipe ${PN}" >> ${S}/inittab
for console in "${SERIAL_CONSOLES}"; do
param=$(echo ${console} | sed s/\;/\ /g)
name=$(echo ${param} | cut -d' ' -f2)
echo "$name::respawn:${base_sbindir}/getty ${param}" >> ${S}/inittab
done
fi
done
}

do_compile[noexec] = "1"

do_install() {
install -d ${D}${sysconfdir}
install -D -m 0644 ${S}/inittab ${D}${sysconfdir}/inittab

install -d ${D}${sysconfdir}/init.d
install -D -m 0744 ${S}/rcK ${D}${sysconfdir}/init.d/rcK
install -D -m 0744 ${S}/rcS ${D}${sysconfdir}/init.d/rcS
}

FILES_${PN} = "\
${sysconfdir}/inittab \
${sysconfdir}/init.d/rcK \
${sysconfdir}/init.d/rcS \
"

7 changes: 7 additions & 0 deletions meta-oe/recipes-core/toybox/toybox_0.8.3.bb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ SRC_URI[sha256sum] = "eab28fd29d19d4e61ef09704e5871940e6f35fd35a3bb1285e41f20450

SECTION = "base"

RDEPENDS_${PN} = "${@["", "toybox-inittab"][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'toybox')]}"

TOYBOX_BIN = "generated/unstripped/toybox"

# Toybox is strict on what CC, CFLAGS and CROSS_COMPILE variables should contain.
Expand Down Expand Up @@ -52,6 +54,11 @@ do_configure() {

# Disable swapon as it doesn't handle the '-a' argument used during boot
sed -e 's/CONFIG_SWAPON=y/# CONFIG_SWAPON is not set/' -i .config

# Enable init if toybox was set as init manager
if [[ ${VIRTUAL-RUNTIME_init_manager} == *"toybox"* ]]; then
sed -e 's/# CONFIG_INIT is not set/CONFIG_INIT=y/' -i .config
fi
}

do_compile() {
Expand Down