Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | SUMMARY = "Toybox combines common utilities together into a single executable." |
| 2 | HOMEPAGE = "http://www.landley.net/toybox/" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3 | DEPENDS = "attr virtual/crypt" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4 | |
| 5 | LICENSE = "BSD-0-Clause" |
Andrew Geissler | 2ee498a | 2020-05-29 15:52:06 -0500 | [diff] [blame] | 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=78659a599b9325da368f2f1eb88f19c7" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7 | |
Brad Bishop | ba6de43 | 2019-05-21 08:07:33 -0400 | [diff] [blame] | 8 | inherit cml1 update-alternatives |
| 9 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 10 | SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \ |
Andrew Geissler | 2ee498a | 2020-05-29 15:52:06 -0500 | [diff] [blame] | 11 | file://mips-no-STKFLT.patch \ |
| 12 | file://0001-Tackle-SIGEMT-and-SIGSTKFLT-is-not-glibc-specific.patch \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 13 | " |
Andrew Geissler | 2ee498a | 2020-05-29 15:52:06 -0500 | [diff] [blame] | 14 | SRC_URI[sha256sum] = "eab28fd29d19d4e61ef09704e5871940e6f35fd35a3bb1285e41f204504b5c01" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15 | |
| 16 | SECTION = "base" |
| 17 | |
Andrew Geissler | 89770b0 | 2020-06-13 10:40:47 -0500 | [diff] [blame^] | 18 | RDEPENDS_${PN} = "${@["", "toybox-inittab"][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'toybox')]}" |
| 19 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | TOYBOX_BIN = "generated/unstripped/toybox" |
| 21 | |
Andrew Geissler | 2ee498a | 2020-05-29 15:52:06 -0500 | [diff] [blame] | 22 | # Toybox is strict on what CC, CFLAGS and CROSS_COMPILE variables should contain. |
| 23 | # Fix CC, CFLAGS, CROSS_COMPILE to match expectations. |
| 24 | # CC = compiler name |
| 25 | # CFLAGS = only compiler flags |
| 26 | # CROSS_COMPILE = compiler prefix |
| 27 | CFLAGS += "${TOOLCHAIN_OPTIONS} ${TUNE_CCARGS}" |
| 28 | |
| 29 | COMPILER_toolchain-clang = "clang" |
| 30 | COMPILER ?= "gcc" |
| 31 | |
| 32 | EXTRA_OEMAKE = 'CROSS_COMPILE="${HOST_PREFIX}" \ |
| 33 | CC="${COMPILER}" \ |
| 34 | STRIP="strip" \ |
| 35 | CFLAGS="${CFLAGS}" \ |
| 36 | HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()} V=1' |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | |
| 38 | do_configure() { |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 39 | # allow user to define their own defconfig in bbappend, taken from kernel.bbclass |
| 40 | if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then |
| 41 | mv "${S}/.config" "${B}/.config" |
| 42 | fi |
| 43 | |
| 44 | # Copy defconfig to .config if .config does not exist. This allows |
| 45 | # recipes to manage the .config themselves in do_configure_prepend(). |
| 46 | if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then |
| 47 | cp "${WORKDIR}/defconfig" "${B}/.config" |
| 48 | fi |
| 49 | |
| 50 | oe_runmake oldconfig || oe_runmake defconfig |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | |
| 52 | # Disable killall5 as it isn't managed by update-alternatives |
| 53 | sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config |
| 54 | |
| 55 | # Disable swapon as it doesn't handle the '-a' argument used during boot |
| 56 | sed -e 's/CONFIG_SWAPON=y/# CONFIG_SWAPON is not set/' -i .config |
Andrew Geissler | 89770b0 | 2020-06-13 10:40:47 -0500 | [diff] [blame^] | 57 | |
| 58 | # Enable init if toybox was set as init manager |
| 59 | if [[ ${VIRTUAL-RUNTIME_init_manager} == *"toybox"* ]]; then |
| 60 | sed -e 's/# CONFIG_INIT is not set/CONFIG_INIT=y/' -i .config |
| 61 | fi |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | do_compile() { |
| 65 | oe_runmake ${TOYBOX_BIN} |
| 66 | |
| 67 | # Create a list of links needed |
| 68 | ${BUILD_CC} -I . scripts/install.c -o generated/instlist |
| 69 | ./generated/instlist long | sed -e 's#^#/#' > toybox.links |
| 70 | } |
| 71 | |
| 72 | do_install() { |
| 73 | # Install manually instead of using 'make install' |
| 74 | install -d ${D}${base_bindir} |
| 75 | if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then |
| 76 | install -m 4755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox |
| 77 | else |
| 78 | install -m 0755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox |
| 79 | fi |
| 80 | |
| 81 | install -d ${D}${sysconfdir} |
| 82 | install -m 0644 ${B}/toybox.links ${D}${sysconfdir} |
| 83 | } |
| 84 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 85 | # If you've chosen to install toybox you probably want it to take precedence |
| 86 | # over busybox where possible but not over other packages |
| 87 | ALTERNATIVE_PRIORITY = "60" |
| 88 | |
| 89 | python do_package_prepend () { |
| 90 | # Read links from /etc/toybox.links and create appropriate |
| 91 | # update-alternatives variables |
| 92 | |
| 93 | dvar = d.getVar('D') |
| 94 | pn = d.getVar('PN') |
Andrew Geissler | 1548c07 | 2019-02-22 16:03:50 -0600 | [diff] [blame] | 95 | target = d.expand("${base_bindir}/toybox") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 96 | |
| 97 | f = open('%s/etc/toybox.links' % (dvar), 'r') |
| 98 | for alt_link_name in f: |
| 99 | alt_link_name = alt_link_name.strip() |
| 100 | alt_name = os.path.basename(alt_link_name) |
| 101 | d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) |
| 102 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) |
| 103 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) |
| 104 | f.close() |
| 105 | } |