blob: 2f8297833419515cf94cd264b7ebee35507b8b71 [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/"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08003DEPENDS = "attr virtual/crypt"
Brad Bishop316dfdd2018-06-25 12:45:53 -04004
5LICENSE = "BSD-0-Clause"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=f0b8b3dd6431bcaa245da0a08bd0d511"
7
Brad Bishopba6de432019-05-21 08:07:33 -04008inherit cml1 update-alternatives
9
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \
11 file://OE-path-changes.patch \
12 "
Brad Bishop316dfdd2018-06-25 12:45:53 -040013SRC_URI[md5sum] = "a8bb502a1be941f06dd2644fff25f547"
14SRC_URI[sha256sum] = "3ada450ac1eab1dfc352fee915ea6129b9a4349c1885f1394b61bd2d89a46c04"
15
16SECTION = "base"
17
18TOYBOX_BIN = "generated/unstripped/toybox"
19
20EXTRA_OEMAKE = 'HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()}'
21
22do_configure() {
Andrew Geissler7f40b712020-05-15 14:09:53 -050023 # 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 Bishop316dfdd2018-06-25 12:45:53 -040035
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
43do_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
51do_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 Bishop316dfdd2018-06-25 12:45:53 -040064# If you've chosen to install toybox you probably want it to take precedence
65# over busybox where possible but not over other packages
66ALTERNATIVE_PRIORITY = "60"
67
68python 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 Geissler1548c072019-02-22 16:03:50 -060074 target = d.expand("${base_bindir}/toybox")
Brad Bishop316dfdd2018-06-25 12:45:53 -040075
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}