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 | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 8 | SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \ |
| 9 | file://OE-path-changes.patch \ |
| 10 | " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | SRC_URI[md5sum] = "a8bb502a1be941f06dd2644fff25f547" |
| 12 | SRC_URI[sha256sum] = "3ada450ac1eab1dfc352fee915ea6129b9a4349c1885f1394b61bd2d89a46c04" |
| 13 | |
| 14 | SECTION = "base" |
| 15 | |
| 16 | TOYBOX_BIN = "generated/unstripped/toybox" |
| 17 | |
| 18 | EXTRA_OEMAKE = 'HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()}' |
| 19 | |
| 20 | do_configure() { |
| 21 | oe_runmake defconfig |
| 22 | |
| 23 | # Disable killall5 as it isn't managed by update-alternatives |
| 24 | sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config |
| 25 | |
| 26 | # Disable swapon as it doesn't handle the '-a' argument used during boot |
| 27 | sed -e 's/CONFIG_SWAPON=y/# CONFIG_SWAPON is not set/' -i .config |
| 28 | } |
| 29 | |
| 30 | do_compile() { |
| 31 | oe_runmake ${TOYBOX_BIN} |
| 32 | |
| 33 | # Create a list of links needed |
| 34 | ${BUILD_CC} -I . scripts/install.c -o generated/instlist |
| 35 | ./generated/instlist long | sed -e 's#^#/#' > toybox.links |
| 36 | } |
| 37 | |
| 38 | do_install() { |
| 39 | # Install manually instead of using 'make install' |
| 40 | install -d ${D}${base_bindir} |
| 41 | if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then |
| 42 | install -m 4755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox |
| 43 | else |
| 44 | install -m 0755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox |
| 45 | fi |
| 46 | |
| 47 | install -d ${D}${sysconfdir} |
| 48 | install -m 0644 ${B}/toybox.links ${D}${sysconfdir} |
| 49 | } |
| 50 | |
| 51 | inherit update-alternatives |
| 52 | |
| 53 | # If you've chosen to install toybox you probably want it to take precedence |
| 54 | # over busybox where possible but not over other packages |
| 55 | ALTERNATIVE_PRIORITY = "60" |
| 56 | |
| 57 | python do_package_prepend () { |
| 58 | # Read links from /etc/toybox.links and create appropriate |
| 59 | # update-alternatives variables |
| 60 | |
| 61 | dvar = d.getVar('D') |
| 62 | pn = d.getVar('PN') |
| 63 | target = "/bin/toybox" |
| 64 | |
| 65 | f = open('%s/etc/toybox.links' % (dvar), 'r') |
| 66 | for alt_link_name in f: |
| 67 | alt_link_name = alt_link_name.strip() |
| 68 | alt_name = os.path.basename(alt_link_name) |
| 69 | d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name) |
| 70 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) |
| 71 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) |
| 72 | f.close() |
| 73 | } |