diff options
Diffstat (limited to 'meta-oe/recipes-core/toybox/toybox_0.8.6.bb')
-rw-r--r-- | meta-oe/recipes-core/toybox/toybox_0.8.6.bb | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/meta-oe/recipes-core/toybox/toybox_0.8.6.bb b/meta-oe/recipes-core/toybox/toybox_0.8.6.bb new file mode 100644 index 000000000..50ce50d1c --- /dev/null +++ b/meta-oe/recipes-core/toybox/toybox_0.8.6.bb | |||
@@ -0,0 +1,114 @@ | |||
1 | SUMMARY = "Toybox combines common utilities together into a single executable." | ||
2 | HOMEPAGE = "http://www.landley.net/toybox/" | ||
3 | DEPENDS = "attr virtual/crypt" | ||
4 | |||
5 | LICENSE = "0BSD" | ||
6 | LIC_FILES_CHKSUM = "file://LICENSE;md5=78659a599b9325da368f2f1eb88f19c7" | ||
7 | |||
8 | inherit cml1 update-alternatives | ||
9 | |||
10 | SRC_URI = "http://www.landley.net/toybox/downloads/${BPN}-${PV}.tar.gz \ | ||
11 | " | ||
12 | SRC_URI[sha256sum] = "4298c90a2b238348e4fdc9f89eb4988356c80da3f0cf78c279d2e82b9119034b" | ||
13 | |||
14 | SECTION = "base" | ||
15 | |||
16 | RDEPENDS:${PN} = "${@["", "toybox-inittab"][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'toybox')]}" | ||
17 | |||
18 | TOYBOX_BIN = "generated/unstripped/toybox" | ||
19 | |||
20 | # Toybox is strict on what CC, CFLAGS and CROSS_COMPILE variables should contain. | ||
21 | # Fix CC, CFLAGS, CROSS_COMPILE to match expectations. | ||
22 | # CC = compiler name | ||
23 | # CFLAGS = only compiler flags | ||
24 | # CROSS_COMPILE = compiler prefix | ||
25 | CFLAGS += "${TOOLCHAIN_OPTIONS} ${TUNE_CCARGS}" | ||
26 | |||
27 | COMPILER:toolchain-clang = "clang" | ||
28 | COMPILER ?= "gcc" | ||
29 | |||
30 | PACKAGECONFIG ??= "no-iconv no-getconf" | ||
31 | |||
32 | PACKAGECONFIG[no-iconv] = ",," | ||
33 | PACKAGECONFIG[no-getconf] = ",," | ||
34 | |||
35 | EXTRA_OEMAKE = 'CROSS_COMPILE="${HOST_PREFIX}" \ | ||
36 | CC="${COMPILER}" \ | ||
37 | STRIP="strip" \ | ||
38 | CFLAGS="${CFLAGS}" \ | ||
39 | HOSTCC="${BUILD_CC}" CPUS=${@oe.utils.cpu_count()} V=1' | ||
40 | |||
41 | do_configure() { | ||
42 | # allow user to define their own defconfig in bbappend, taken from kernel.bbclass | ||
43 | if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then | ||
44 | mv "${S}/.config" "${B}/.config" | ||
45 | fi | ||
46 | |||
47 | # Copy defconfig to .config if .config does not exist. This allows | ||
48 | # recipes to manage the .config themselves in do_configure:prepend(). | ||
49 | if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then | ||
50 | cp "${WORKDIR}/defconfig" "${B}/.config" | ||
51 | fi | ||
52 | |||
53 | oe_runmake oldconfig || oe_runmake defconfig | ||
54 | |||
55 | # Disable killall5 as it isn't managed by update-alternatives | ||
56 | sed -e 's/CONFIG_KILLALL5=y/# CONFIG_KILLALL5 is not set/' -i .config | ||
57 | |||
58 | # Disable swapon as it doesn't handle the '-a' argument used during boot | ||
59 | sed -e 's/CONFIG_SWAPON=y/# CONFIG_SWAPON is not set/' -i .config | ||
60 | |||
61 | # Enable init if toybox was set as init manager | ||
62 | if ${@bb.utils.contains('VIRTUAL-RUNTIME_init_manager','toybox','true','false',d)}; then | ||
63 | sed -e 's/# CONFIG_INIT is not set/CONFIG_INIT=y/' -i .config | ||
64 | fi | ||
65 | } | ||
66 | |||
67 | do_compile() { | ||
68 | oe_runmake ${TOYBOX_BIN} | ||
69 | |||
70 | # Create a list of links needed | ||
71 | ${BUILD_CC} -I . scripts/install.c -o generated/instlist | ||
72 | ./generated/instlist long | sed -e 's#^#/#' > toybox.links | ||
73 | if ${@bb.utils.contains('PACKAGECONFIG','no-iconv','true','false',d)}; then | ||
74 | sed -i -e '/iconv$/d' toybox.links | ||
75 | fi | ||
76 | if ${@bb.utils.contains('PACKAGECONFIG','no-getconf','true','false',d)}; then | ||
77 | sed -i -e '/getconf$/d' toybox.links | ||
78 | fi | ||
79 | } | ||
80 | |||
81 | do_install() { | ||
82 | # Install manually instead of using 'make install' | ||
83 | install -d ${D}${base_bindir} | ||
84 | if grep -q "CONFIG_TOYBOX_SUID=y" ${B}/.config; then | ||
85 | install -m 4755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox | ||
86 | else | ||
87 | install -m 0755 ${B}/${TOYBOX_BIN} ${D}${base_bindir}/toybox | ||
88 | fi | ||
89 | |||
90 | install -d ${D}${sysconfdir} | ||
91 | install -m 0644 ${B}/toybox.links ${D}${sysconfdir} | ||
92 | } | ||
93 | |||
94 | # If you've chosen to install toybox you probably want it to take precedence | ||
95 | # over busybox where possible but not over other packages | ||
96 | ALTERNATIVE_PRIORITY = "60" | ||
97 | |||
98 | python do_package:prepend () { | ||
99 | # Read links from /etc/toybox.links and create appropriate | ||
100 | # update-alternatives variables | ||
101 | |||
102 | dvar = d.getVar('D') | ||
103 | pn = d.getVar('PN') | ||
104 | target = d.expand("${base_bindir}/toybox") | ||
105 | |||
106 | f = open('%s/etc/toybox.links' % (dvar), 'r') | ||
107 | for alt_link_name in f: | ||
108 | alt_link_name = alt_link_name.strip() | ||
109 | alt_name = os.path.basename(alt_link_name) | ||
110 | d.appendVar('ALTERNATIVE:%s' % (pn), ' ' + alt_name) | ||
111 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) | ||
112 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) | ||
113 | f.close() | ||
114 | } | ||