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