diff options
Diffstat (limited to 'meta-oe/recipes-core/toybox')
8 files changed, 295 insertions, 268 deletions
diff --git a/meta-oe/recipes-core/toybox/toybox-inittab/inittab b/meta-oe/recipes-core/toybox/toybox-inittab/inittab new file mode 100644 index 0000000000..ffb2f17a66 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox-inittab/inittab @@ -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 + diff --git a/meta-oe/recipes-core/toybox/toybox-inittab/rcK b/meta-oe/recipes-core/toybox/toybox-inittab/rcK new file mode 100644 index 0000000000..617d3c0c3f --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox-inittab/rcK @@ -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 + diff --git a/meta-oe/recipes-core/toybox/toybox-inittab/rcS b/meta-oe/recipes-core/toybox/toybox-inittab/rcS new file mode 100644 index 0000000000..b8e29855d4 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox-inittab/rcS @@ -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 + diff --git a/meta-oe/recipes-core/toybox/toybox-inittab_0.8.2.bb b/meta-oe/recipes-core/toybox/toybox-inittab_0.8.2.bb new file mode 100644 index 0000000000..603f365cf3 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox-inittab_0.8.2.bb @@ -0,0 +1,64 @@ +SUMMARY = "Toybox Inittab Configuration" +LICENSE = "0BSD" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/0BSD;md5=f667a3c3830a55a17ec3067709f4526c" + +# Unpack to ${S}/orig +# +SRC_URI = "\ + file://inittab;subdir=${BP}/orig \ + file://rcK;subdir=${BP}/orig \ + file://rcS;subdir=${BP}/orig \ +" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +RCONFLICTS:${PN} = "\ + busybox-inittab \ + sysvinit-inittab \ +" + +# Just being sure. +B = "${S}" + +# 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 + cp orig/* . + + 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 \ +" + diff --git a/meta-oe/recipes-core/toybox/toybox/0001-portability-Fix-timer_settime_wrap-for-32bit-systems.patch b/meta-oe/recipes-core/toybox/toybox/0001-portability-Fix-timer_settime_wrap-for-32bit-systems.patch new file mode 100644 index 0000000000..8976b3748b --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox/0001-portability-Fix-timer_settime_wrap-for-32bit-systems.patch @@ -0,0 +1,37 @@ +From 7284c7ae0df9aa5a9c8aa0a81a018e17289fe2c4 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.khem@gmail.com> +Date: Thu, 8 Sep 2022 07:22:26 -0700 +Subject: [PATCH] portability: Fix timer_settime_wrap for 32bit systems with + 64bit time_t + +glibc does not define SYS_timer_settime if the 32bit syscall is not +available, new architectures like riscv32 has defaulted to 64bit time_t +from get go and avoided wiring 32bit syscall, therefore alias it to +64bit version here + +Upstream-Status: Submitted [https://github.com/landley/toybox/pull/373] +Signed-off-by: Khem Raj <raj.khem@gmail.com> +--- + lib/portability.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/lib/portability.c b/lib/portability.c +index d955d081..4baa9367 100644 +--- a/lib/portability.c ++++ b/lib/portability.c +@@ -711,6 +711,12 @@ int timer_create_wrap(clockid_t c, struct sigevent *se, timer_t *t) + return 0; + } + ++#if !defined(SYS_timer_settime) && defined(SYS_timer_settime64) ++// glibc does not define defines SYS_timer_settime on 32-bit systems ++// with 64-bit time_t defaults e.g. riscv32 ++#define SYS_timer_settime SYS_timer_settime64 ++#endif ++ + int timer_settime_wrap(timer_t t, int flags, struct itimerspec *val, + struct itimerspec *old) + { +-- +2.37.3 + diff --git a/meta-oe/recipes-core/toybox/toybox/OE-path-changes.patch b/meta-oe/recipes-core/toybox/toybox/OE-path-changes.patch deleted file mode 100644 index e42c22ebd4..0000000000 --- a/meta-oe/recipes-core/toybox/toybox/OE-path-changes.patch +++ /dev/null @@ -1,195 +0,0 @@ -diff --git a/toys/net/microcom.c b/toys/net/microcom.c -index d34e1fe..a369e6c 100644 ---- a/toys/net/microcom.c -+++ b/toys/net/microcom.c -@@ -2,7 +2,7 @@ - * - * Copyright 2017 The Android Open Source Project. - --USE_MICROCOM(NEWTOY(microcom, "<1>1s:X", TOYFLAG_BIN)) -+USE_MICROCOM(NEWTOY(microcom, "<1>1s:X", TOYFLAG_USR|TOYFLAG_BIN)) - - config MICROCOM - bool "microcom" -diff --git a/toys/other/blockdev.c b/toys/other/blockdev.c -index 38e0993..c5d9fcd 100644 ---- a/toys/other/blockdev.c -+++ b/toys/other/blockdev.c -@@ -4,7 +4,7 @@ - * - * No Standard. - --USE_BLOCKDEV(NEWTOY(blockdev, "<1>1(setro)(setrw)(getro)(getss)(getbsz)(setbsz)#<0(getsz)(getsize)(getsize64)(flushbufs)(rereadpt)",TOYFLAG_USR|TOYFLAG_BIN)) -+USE_BLOCKDEV(NEWTOY(blockdev, "<1>1(setro)(setrw)(getro)(getss)(getbsz)(setbsz)#<0(getsz)(getsize)(getsize64)(flushbufs)(rereadpt)",TOYFLAG_SBIN)) - - config BLOCKDEV - bool "blockdev" -diff --git a/toys/other/chrt.c b/toys/other/chrt.c -index a1c37a0..d6db3a5 100644 ---- a/toys/other/chrt.c -+++ b/toys/other/chrt.c -@@ -4,7 +4,7 @@ - * - * Note: -ibrfo flags sorted to match SCHED positions for highest_bit() - --USE_CHRT(NEWTOY(chrt, "^mp#<0iRbrfo[!ibrfo]", TOYFLAG_USR|TOYFLAG_SBIN)) -+USE_CHRT(NEWTOY(chrt, "^mp#<0iRbrfo[!ibrfo]", TOYFLAG_USR|TOYFLAG_BIN)) - - config CHRT - bool "chrt" -diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c -index 1d313e3..412582d 100644 ---- a/toys/other/hwclock.c -+++ b/toys/other/hwclock.c -@@ -4,7 +4,7 @@ - * - * No standard, but see Documentation/rtc.txt in the linux kernel source.. - * --USE_HWCLOCK(NEWTOY(hwclock, ">0(fast)f(rtc):u(utc)l(localtime)t(systz)s(hctosys)r(show)w(systohc)[-ul][!rtsw]", TOYFLAG_USR|TOYFLAG_BIN)) -+USE_HWCLOCK(NEWTOY(hwclock, ">0(fast)f(rtc):u(utc)l(localtime)t(systz)s(hctosys)r(show)w(systohc)[-ul][!rtsw]", TOYFLAG_SBIN)) - - config HWCLOCK - bool "hwclock" -diff --git a/toys/other/modinfo.c b/toys/other/modinfo.c -index 1178d67..966a9de 100644 ---- a/toys/other/modinfo.c -+++ b/toys/other/modinfo.c -@@ -4,7 +4,7 @@ - * - * TODO: cleanup - --USE_MODINFO(NEWTOY(modinfo, "<1b:k:F:0", TOYFLAG_BIN)) -+USE_MODINFO(NEWTOY(modinfo, "<1b:k:F:0", TOYFLAG_SBIN)) - - config MODINFO - bool "modinfo" -diff --git a/toys/other/pmap.c b/toys/other/pmap.c -index abb0a33..2acef02 100644 ---- a/toys/other/pmap.c -+++ b/toys/other/pmap.c -@@ -5,7 +5,7 @@ - * - * No Standard. - --USE_PMAP(NEWTOY(pmap, "<1xq", TOYFLAG_BIN)) -+USE_PMAP(NEWTOY(pmap, "<1xq", TOYFLAG_USR|TOYFLAG_BIN)) - - config PMAP - bool "pmap" -diff --git a/toys/other/printenv.c b/toys/other/printenv.c -index e8bcf29..65f62ed 100644 ---- a/toys/other/printenv.c -+++ b/toys/other/printenv.c -@@ -2,7 +2,7 @@ - * - * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org> - --USE_PRINTENV(NEWTOY(printenv, "0(null)", TOYFLAG_USR|TOYFLAG_BIN)) -+USE_PRINTENV(NEWTOY(printenv, "0(null)", TOYFLAG_BIN)) - - config PRINTENV - bool "printenv" -diff --git a/toys/other/taskset.c b/toys/other/taskset.c -index 8ffdab7..89fd528 100644 ---- a/toys/other/taskset.c -+++ b/toys/other/taskset.c -@@ -2,7 +2,7 @@ - * - * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> - --USE_TASKSET(NEWTOY(taskset, "<1^pa", TOYFLAG_BIN|TOYFLAG_STAYROOT)) -+USE_TASKSET(NEWTOY(taskset, "<1^pa", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT)) - USE_NPROC(NEWTOY(nproc, "(all)", TOYFLAG_USR|TOYFLAG_BIN)) - - config NPROC -diff --git a/toys/other/timeout.c b/toys/other/timeout.c -index 9b93466..e1d0f4d 100644 ---- a/toys/other/timeout.c -+++ b/toys/other/timeout.c -@@ -4,7 +4,7 @@ - * - * No standard - --USE_TIMEOUT(NEWTOY(timeout, "<2^vk:s: ", TOYFLAG_BIN)) -+USE_TIMEOUT(NEWTOY(timeout, "<2^vk:s: ", TOYFLAG_USR|TOYFLAG_BIN)) - - config TIMEOUT - bool "timeout" -diff --git a/toys/other/truncate.c b/toys/other/truncate.c -index 142d3c7..40eb1e5 100644 ---- a/toys/other/truncate.c -+++ b/toys/other/truncate.c -@@ -2,7 +2,7 @@ - * - * Copyright 2011 Rob Landley <rob@landley.net> - --USE_TRUNCATE(NEWTOY(truncate, "<1s:|c", TOYFLAG_BIN)) -+USE_TRUNCATE(NEWTOY(truncate, "<1s:|c", TOYFLAG_USR|TOYFLAG_BIN)) - - config TRUNCATE - bool "truncate" -diff --git a/toys/posix/nice.c b/toys/posix/nice.c -index 4b587ee..9f7b119 100644 ---- a/toys/posix/nice.c -+++ b/toys/posix/nice.c -@@ -4,7 +4,7 @@ - * - * See http://opengroup.org/onlinepubs/9699919799/utilities/nice.html - --USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_USR|TOYFLAG_BIN)) -+USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_BIN)) - - config NICE - bool "nice" -diff --git a/toys/posix/nl.c b/toys/posix/nl.c -index 9b02bfa..41e1b89 100644 ---- a/toys/posix/nl.c -+++ b/toys/posix/nl.c -@@ -7,7 +7,7 @@ - * This implements a subset: only one logical page (-ip), no sections (-dfh). - * todo: -lv - --USE_NL(NEWTOY(nl, "v#<1=1l#b:n:s:w#<0=6E", TOYFLAG_BIN)) -+USE_NL(NEWTOY(nl, "v#<1=1l#b:n:s:w#<0=6E", TOYFLAG_USR|TOYFLAG_BIN)) - - config NL - bool "nl" -diff --git a/toys/posix/paste.c b/toys/posix/paste.c -index ea04f02..8972f71 100644 ---- a/toys/posix/paste.c -+++ b/toys/posix/paste.c -@@ -6,7 +6,7 @@ - * - * Deviations from posix: the FILE argument isn't mandatory, none == '-' - --USE_PASTE(NEWTOY(paste, "d:s", TOYFLAG_BIN|TOYFLAG_LOCALE)) -+USE_PASTE(NEWTOY(paste, "d:s", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE)) - - config PASTE - bool "paste" -diff --git a/toys/posix/ps.c b/toys/posix/ps.c -index aef2a7f..b559e09 100644 ---- a/toys/posix/ps.c -+++ b/toys/posix/ps.c -@@ -44,7 +44,7 @@ - * TODO: top: thread support and SMP - * TODO: pgrep -f only searches the amount of cmdline that fits in toybuf. - --USE_PS(NEWTOY(ps, "k(sort)*P(ppid)*aAdeflMno*O*p(pid)*s*t*Tu*U*g*G*wZ[!ol][+Ae][!oO]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE)) -+USE_PS(NEWTOY(ps, "k(sort)*P(ppid)*aAdeflMno*O*p(pid)*s*t*Tu*U*g*G*wZ[!ol][+Ae][!oO]", TOYFLAG_BIN|TOYFLAG_LOCALE)) - // stayroot because iotop needs root to read other process' proc/$$/io - USE_TOP(NEWTOY(top, ">0m" "O*Hk*o*p*u*s#<1d#=3<1n#<1bq[!oO]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE)) - USE_IOTOP(NEWTOY(iotop, ">0AaKO" "k*o*p*u*s#<1=7d#=3<1n#<1bq", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT|TOYFLAG_LOCALE)) -diff --git a/toys/posix/sed.c b/toys/posix/sed.c -index cf7d15e..130ac08 100644 ---- a/toys/posix/sed.c -+++ b/toys/posix/sed.c -@@ -10,7 +10,7 @@ - * TODO: handle error return from emit(), error_msg/exit consistently - * What's the right thing to do for -i when write fails? Skip to next? - --USE_SED(NEWTOY(sed, "(help)(version)e*f*inEr[+Er]", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE|TOYFLAG_NOHELP)) -+USE_SED(NEWTOY(sed, "(help)(version)e*f*inEr[+Er]", TOYFLAG_BIN|TOYFLAG_LOCALE|TOYFLAG_NOHELP)) - - config SED - bool "sed" diff --git a/meta-oe/recipes-core/toybox/toybox_0.7.5.bb b/meta-oe/recipes-core/toybox/toybox_0.7.5.bb deleted file mode 100644 index 614136e27f..0000000000 --- a/meta-oe/recipes-core/toybox/toybox_0.7.5.bb +++ /dev/null @@ -1,73 +0,0 @@ -SUMMARY = "Toybox combines common utilities together into a single executable." -HOMEPAGE = "http://www.landley.net/toybox/" -DEPENDS = "attr virtual/crypt" - -LICENSE = "BSD-0-Clause" -LIC_FILES_CHKSUM = "file://LICENSE;md5=f0b8b3dd6431bcaa245da0a08bd0d511" - -SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \ - file://OE-path-changes.patch \ - " -SRC_URI[md5sum] = "a8bb502a1be941f06dd2644fff25f547" -SRC_URI[sha256sum] = "3ada450ac1eab1dfc352fee915ea6129b9a4349c1885f1394b61bd2d89a46c04" - -SECTION = "base" - -TOYBOX_BIN = "generated/unstripped/toybox" - -EXTRA_OEMAKE = 'HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()}' - -do_configure() { - oe_runmake defconfig - - # Disable killall5 as it isn't managed by update-alternatives - sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config - - # 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 -} - -do_compile() { - oe_runmake ${TOYBOX_BIN} - - # Create a list of links needed - ${BUILD_CC} -I . scripts/install.c -o generated/instlist - ./generated/instlist long | sed -e 's#^#/#' > toybox.links -} - -do_install() { - # Install manually instead of using 'make install' - install -d ${D}${base_bindir} - if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then - install -m 4755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox - else - install -m 0755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox - fi - - install -d ${D}${sysconfdir} - install -m 0644 ${B}/toybox.links ${D}${sysconfdir} -} - -inherit cml1 update-alternatives - -# If you've chosen to install toybox you probably want it to take precedence -# over busybox where possible but not over other packages -ALTERNATIVE_PRIORITY = "60" - -python do_package_prepend () { - # Read links from /etc/toybox.links and create appropriate - # update-alternatives variables - - dvar = d.getVar('D') - pn = d.getVar('PN') - target = d.expand("${base_bindir}/toybox") - - f = open('%s/etc/toybox.links' % (dvar), 'r') - for alt_link_name in f: - alt_link_name = alt_link_name.strip() - alt_name = os.path.basename(alt_link_name) - d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) - d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) - d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) - f.close() -} diff --git a/meta-oe/recipes-core/toybox/toybox_0.8.8.bb b/meta-oe/recipes-core/toybox/toybox_0.8.8.bb new file mode 100644 index 0000000000..6836b14682 --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox_0.8.8.bb @@ -0,0 +1,115 @@ +SUMMARY = "Toybox combines common utilities together into a single executable." +HOMEPAGE = "http://www.landley.net/toybox/" +DEPENDS = "attr virtual/crypt" + +LICENSE = "0BSD" +LIC_FILES_CHKSUM = "file://LICENSE;md5=78659a599b9325da368f2f1eb88f19c7" + +inherit cml1 update-alternatives + +SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \ + file://0001-portability-Fix-timer_settime_wrap-for-32bit-systems.patch \ + " +SRC_URI[sha256sum] = "dafd41978d40f02a61cf1be99a2b4a25812bbfb9c3157e679ee7611202d6ac58" + +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. +# Fix CC, CFLAGS, CROSS_COMPILE to match expectations. +# CC = compiler name +# CFLAGS = only compiler flags +# CROSS_COMPILE = compiler prefix +CFLAGS += "${TOOLCHAIN_OPTIONS} ${TUNE_CCARGS}" + +COMPILER:toolchain-clang = "clang" +COMPILER ?= "gcc" + +PACKAGECONFIG ??= "no-iconv no-getconf" + +PACKAGECONFIG[no-iconv] = ",," +PACKAGECONFIG[no-getconf] = ",," + +EXTRA_OEMAKE = 'CROSS_COMPILE="${HOST_PREFIX}" \ + CC="${COMPILER}" \ + STRIP="strip" \ + CFLAGS="${CFLAGS}" \ + HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()} V=1' + +do_configure() { + # allow user to define their own defconfig in bbappend, taken from kernel.bbclass + if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then + mv "${S}/.config" "${B}/.config" + fi + + # Copy defconfig to .config if .config does not exist. This allows + # recipes to manage the .config themselves in do_configure:prepend(). + if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then + cp "${WORKDIR}/defconfig" "${B}/.config" + fi + + oe_runmake oldconfig || oe_runmake defconfig + + # Disable killall5 as it isn't managed by update-alternatives + sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config + + # 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 ${@bb.utils.contains('VIRTUAL-RUNTIME_init_manager','toybox','true','false',d)}; then + sed -e 's/# CONFIG_INIT is not set/CONFIG_INIT=y/' -i .config + fi +} + +do_compile() { + oe_runmake ${TOYBOX_BIN} + + # Create a list of links needed + ${BUILD_CC} -I . scripts/install.c -o generated/instlist + ./generated/instlist long | sed -e 's#^#/#' > toybox.links + if ${@bb.utils.contains('PACKAGECONFIG','no-iconv','true','false',d)}; then + sed -i -e '/iconv$/d' toybox.links + fi + if ${@bb.utils.contains('PACKAGECONFIG','no-getconf','true','false',d)}; then + sed -i -e '/getconf$/d' toybox.links + fi +} + +do_install() { + # Install manually instead of using 'make install' + install -d ${D}${base_bindir} + if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then + install -m 4755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox + else + install -m 0755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox + fi + + install -d ${D}${sysconfdir} + install -m 0644 ${B}/toybox.links ${D}${sysconfdir} +} + +# If you've chosen to install toybox you probably want it to take precedence +# over busybox where possible but not over other packages +ALTERNATIVE_PRIORITY = "60" + +python do_package:prepend () { + # Read links from /etc/toybox.links and create appropriate + # update-alternatives variables + + dvar = d.getVar('D') + pn = d.getVar('PN') + target = d.expand("${base_bindir}/toybox") + + f = open('%s/etc/toybox.links' % (dvar), 'r') + for alt_link_name in f: + alt_link_name = alt_link_name.strip() + alt_name = os.path.basename(alt_link_name) + d.appendVar('ALTERNATIVE:%s' % (pn), ' ' + alt_name) + d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) + d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) + f.close() +} |