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" |
| 6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f0b8b3dd6431bcaa245da0a08bd0d511" |
| 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 \ |
| 11 | file://OE-path-changes.patch \ |
| 12 | " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13 | SRC_URI[md5sum] = "a8bb502a1be941f06dd2644fff25f547" |
| 14 | SRC_URI[sha256sum] = "3ada450ac1eab1dfc352fee915ea6129b9a4349c1885f1394b61bd2d89a46c04" |
| 15 | |
| 16 | SECTION = "base" |
| 17 | |
| 18 | TOYBOX_BIN = "generated/unstripped/toybox" |
| 19 | |
| 20 | EXTRA_OEMAKE = 'HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()}' |
| 21 | |
| 22 | do_configure() { |
Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame^] | 23 | # allow user to define their own defconfig in bbappend, taken from kernel.bbclass |
| 24 | if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then |
| 25 | mv "${S}/.config" "${B}/.config" |
| 26 | fi |
| 27 | |
| 28 | # Copy defconfig to .config if .config does not exist. This allows |
| 29 | # recipes to manage the .config themselves in do_configure_prepend(). |
| 30 | if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then |
| 31 | cp "${WORKDIR}/defconfig" "${B}/.config" |
| 32 | fi |
| 33 | |
| 34 | oe_runmake oldconfig || oe_runmake defconfig |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | |
| 36 | # Disable killall5 as it isn't managed by update-alternatives |
| 37 | sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config |
| 38 | |
| 39 | # Disable swapon as it doesn't handle the '-a' argument used during boot |
| 40 | sed -e 's/CONFIG_SWAPON=y/# CONFIG_SWAPON is not set/' -i .config |
| 41 | } |
| 42 | |
| 43 | do_compile() { |
| 44 | oe_runmake ${TOYBOX_BIN} |
| 45 | |
| 46 | # Create a list of links needed |
| 47 | ${BUILD_CC} -I . scripts/install.c -o generated/instlist |
| 48 | ./generated/instlist long | sed -e 's#^#/#' > toybox.links |
| 49 | } |
| 50 | |
| 51 | do_install() { |
| 52 | # Install manually instead of using 'make install' |
| 53 | install -d ${D}${base_bindir} |
| 54 | if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then |
| 55 | install -m 4755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox |
| 56 | else |
| 57 | install -m 0755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox |
| 58 | fi |
| 59 | |
| 60 | install -d ${D}${sysconfdir} |
| 61 | install -m 0644 ${B}/toybox.links ${D}${sysconfdir} |
| 62 | } |
| 63 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | # If you've chosen to install toybox you probably want it to take precedence |
| 65 | # over busybox where possible but not over other packages |
| 66 | ALTERNATIVE_PRIORITY = "60" |
| 67 | |
| 68 | python do_package_prepend () { |
| 69 | # Read links from /etc/toybox.links and create appropriate |
| 70 | # update-alternatives variables |
| 71 | |
| 72 | dvar = d.getVar('D') |
| 73 | pn = d.getVar('PN') |
Andrew Geissler | 1548c07 | 2019-02-22 16:03:50 -0600 | [diff] [blame] | 74 | target = d.expand("${base_bindir}/toybox") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 75 | |
| 76 | f = open('%s/etc/toybox.links' % (dvar), 'r') |
| 77 | for alt_link_name in f: |
| 78 | alt_link_name = alt_link_name.strip() |
| 79 | alt_name = os.path.basename(alt_link_name) |
| 80 | d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) |
| 81 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) |
| 82 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) |
| 83 | f.close() |
| 84 | } |