toybox_0.8.4.bb 3.9 KB

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