Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Tiny versions of many common UNIX utilities in a single small executable" |
| 2 | DESCRIPTION = "BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides minimalist replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete POSIX environment for any small or embedded system." |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 3 | HOMEPAGE = "https://www.busybox.net" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | BUGTRACKER = "https://bugs.busybox.net/" |
| 5 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 6 | DEPENDS += "kern-tools-native virtual/crypt" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 8 | # bzip2 applet in busybox is based on lightly-modified bzip2-1.0.4 source |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | # the GPL is version 2 only |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 10 | LICENSE = "GPL-2.0-only & bzip2-1.0.4" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 11 | LIC_FILES_CHKSUM = "file://LICENSE;md5=de10de48642ab74318e893a61105afbb \ |
| 12 | file://archival/libarchive/bz/LICENSE;md5=28e3301eae987e8cfe19988e98383dae" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
| 14 | SECTION = "base" |
| 15 | |
| 16 | # Whether to split the suid apps into a seperate binary |
| 17 | BUSYBOX_SPLIT_SUID ?= "1" |
| 18 | |
| 19 | export EXTRA_CFLAGS = "${CFLAGS}" |
| 20 | export EXTRA_LDFLAGS = "${LDFLAGS}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 21 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 22 | EXTRA_OEMAKE = "CC='${CC}' LD='${CCLD}' V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y HOSTCC='${BUILD_CC}' HOSTCPP='${BUILD_CPP}'" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | |
| 24 | PACKAGES =+ "${PN}-httpd ${PN}-udhcpd ${PN}-udhcpc ${PN}-syslog ${PN}-mdev ${PN}-hwclock" |
| 25 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 26 | FILES:${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www" |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 27 | FILES:${PN}-syslog = "${sysconfdir}/init.d/syslog* ${sysconfdir}/syslog-startup.conf* ${sysconfdir}/syslog.conf* ${systemd_system_unitdir}/syslog.service ${sysconfdir}/default/busybox-syslog" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 28 | FILES:${PN}-mdev = "${sysconfdir}/init.d/mdev ${sysconfdir}/mdev.conf ${sysconfdir}/mdev/*" |
| 29 | FILES:${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd" |
| 30 | FILES:${PN}-udhcpc = "${sysconfdir}/udhcpc.d ${datadir}/udhcpc" |
| 31 | FILES:${PN}-hwclock = "${sysconfdir}/init.d/hwclock.sh" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | |
| 33 | INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd ${PN}-mdev ${PN}-hwclock" |
| 34 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 35 | INITSCRIPT_NAME:${PN}-httpd = "busybox-httpd" |
| 36 | INITSCRIPT_NAME:${PN}-hwclock = "hwclock.sh" |
| 37 | INITSCRIPT_NAME:${PN}-mdev = "mdev" |
| 38 | INITSCRIPT_PARAMS:${PN}-mdev = "start 04 S ." |
| 39 | INITSCRIPT_NAME:${PN}-syslog = "syslog" |
| 40 | INITSCRIPT_NAME:${PN}-udhcpd = "busybox-udhcpd" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | |
| 42 | SYSTEMD_PACKAGES = "${PN}-syslog" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 43 | SYSTEMD_SERVICE:${PN}-syslog = "${@bb.utils.contains('SRC_URI', 'file://syslog.cfg', 'busybox-syslog.service', '', d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 45 | RDEPENDS:${PN}-syslog = "busybox" |
| 46 | CONFFILES:${PN}-syslog = "${sysconfdir}/syslog-startup.conf" |
| 47 | RCONFLICTS:${PN}-syslog = "rsyslog sysklogd syslog-ng" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 48 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 49 | CONFFILES:${PN}-mdev = "${sysconfdir}/mdev.conf" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 51 | RRECOMMENDS:${PN} = "${PN}-udhcpc" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 53 | RDEPENDS:${PN} = "${@["", "busybox-inittab"][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'busybox')]}" |
Brad Bishop | 0011132 | 2018-04-01 22:23:53 -0400 | [diff] [blame] | 54 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | inherit cml1 systemd update-rc.d ptest |
| 56 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 57 | # busybox's unzip test case needs zip command, which busybox itself does not provide |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 58 | RDEPENDS:${PN}-ptest = "zip" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 59 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | # internal helper |
| 61 | def busybox_cfg(feature, tokens, cnf, rem): |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 62 | if type(tokens) == type(""): |
| 63 | tokens = [tokens] |
| 64 | rem.extend(['/^[# ]*' + token + '[ =]/d' for token in tokens]) |
| 65 | if feature: |
| 66 | cnf.extend([token + '=y' for token in tokens]) |
| 67 | else: |
| 68 | cnf.extend(['# ' + token + ' is not set' for token in tokens]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | |
| 70 | # Map distro features to config settings |
| 71 | def features_to_busybox_settings(d): |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 72 | cnf, rem = ([], []) |
| 73 | busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d), 'CONFIG_FEATURE_IPV6', cnf, rem) |
| 74 | busybox_cfg(True, 'CONFIG_LFS', cnf, rem) |
| 75 | busybox_cfg(True, 'CONFIG_FDISK_SUPPORT_LARGE_DISKS', cnf, rem) |
| 76 | busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'nls', True, False, d), 'CONFIG_LOCALE_SUPPORT', cnf, rem) |
| 77 | busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv4', True, False, d), 'CONFIG_FEATURE_IFUPDOWN_IPV4', cnf, rem) |
| 78 | busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d), 'CONFIG_FEATURE_IFUPDOWN_IPV6', cnf, rem) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 79 | busybox_cfg(bb.utils.contains_any('DISTRO_FEATURES', 'bluetooth wifi', True, False, d), 'CONFIG_RFKILL', cnf, rem) |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 80 | return "\n".join(cnf), "\n".join(rem) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 82 | # X, Y = ${@features_to_busybox_settings(d)} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | # unfortunately doesn't seem to work with bitbake, workaround: |
| 84 | def features_to_busybox_conf(d): |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 85 | cnf, rem = features_to_busybox_settings(d) |
| 86 | return cnf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | def features_to_busybox_del(d): |
Brad Bishop | a5c52ff | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 88 | cnf, rem = features_to_busybox_settings(d) |
| 89 | return rem |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 91 | configmangle = '/CONFIG_EXTRA_CFLAGS/d; \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 92 | ' |
| 93 | OE_FEATURES := "${@features_to_busybox_conf(d)}" |
| 94 | OE_DEL := "${@features_to_busybox_del(d)}" |
| 95 | DO_IPv4 := "${@bb.utils.contains('DISTRO_FEATURES', 'ipv4', 1, 0, d)}" |
| 96 | DO_IPv6 := "${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 1, 0, d)}" |
| 97 | |
| 98 | python () { |
| 99 | if "${OE_DEL}": |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 100 | d.setVar('configmangle:append', "${OE_DEL}" + "\n") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | if "${OE_FEATURES}": |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 102 | d.setVar('configmangle:append', |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | "/^### DISTRO FEATURES$/a\\\n%s\n\n" % |
| 104 | ("\\n".join((d.expand("${OE_FEATURES}").split("\n"))))) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 105 | d.setVar('configmangle:append', |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 106 | "/^### CROSS$/a\\\n%s\n" % |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 107 | ("\\n".join(["CONFIG_EXTRA_CFLAGS=\"${CFLAGS} ${HOST_CC_ARCH}\"" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | ]) |
| 109 | )) |
| 110 | } |
| 111 | |
| 112 | do_prepare_config () { |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 113 | export KCONFIG_NOTIMESTAMP=1 |
| 114 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 115 | sed -e '/CONFIG_STATIC/d' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | < ${WORKDIR}/defconfig > ${S}/.config |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 117 | echo "# CONFIG_STATIC is not set" >> .config |
| 118 | for i in 'CROSS' 'DISTRO FEATURES'; do echo "### $i"; done >> \ |
| 119 | ${S}/.config |
| 120 | sed -i -e '${configmangle}' ${S}/.config |
| 121 | if test ${DO_IPv4} -eq 0 && test ${DO_IPv6} -eq 0; then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 122 | # disable networking applets |
| 123 | mv ${S}/.config ${S}/.config.oe-tmp |
| 124 | awk 'BEGIN{net=0} |
| 125 | /^# Networking Utilities/{net=1} |
| 126 | /^#$/{if(net){net=net+1}} |
| 127 | {if(net==2&&$0 !~ /^#/&&$1){print("# "$1" is not set")}else{print}}' \ |
| 128 | ${S}/.config.oe-tmp > ${S}/.config |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | fi |
| 130 | sed -i 's/CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n"/CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -b"/' ${S}/.config |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 131 | if [ -n "${DEBUG_PREFIX_MAP}" ]; then |
| 132 | sed -i 's|${DEBUG_PREFIX_MAP}||g' ${S}/.config |
| 133 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | } |
| 135 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 136 | do_configure () { |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 137 | set -x |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 138 | do_prepare_config |
| 139 | merge_config.sh -m .config ${@" ".join(find_cfgs(d))} |
| 140 | cml1_do_configure |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 141 | |
| 142 | # Save a copy of .config and autoconf.h. |
| 143 | cp .config .config.orig |
| 144 | cp include/autoconf.h include/autoconf.h.orig |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | do_compile() { |
| 148 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 149 | export KCONFIG_NOTIMESTAMP=1 |
| 150 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 151 | # Ensure we start do_compile with the original .config and autoconf.h. |
| 152 | # These files should always have matching timestamps. |
| 153 | cp .config.orig .config |
| 154 | cp include/autoconf.h.orig include/autoconf.h |
| 155 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 157 | # Guard againt interrupted do_compile: clean temporary files. |
| 158 | rm -f .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps |
| 159 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 160 | # split the .config into two parts, and make two busybox binaries |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | oe_runmake busybox.cfg.suid |
| 162 | oe_runmake busybox.cfg.nosuid |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 163 | |
| 164 | # workaround for suid bug 10346 |
| 165 | if ! grep -q "CONFIG_SH_IS_NONE" busybox.cfg.nosuid; then |
| 166 | echo "CONFIG_SH_IS_NONE" >> busybox.cfg.suid |
| 167 | fi |
| 168 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | for i in `cat busybox.cfg.suid busybox.cfg.nosuid`; do |
| 170 | echo "# $i is not set" >> .config.disable.apps |
| 171 | done |
| 172 | merge_config.sh -m .config.orig .config.disable.apps |
| 173 | cp .config .config.nonapps |
| 174 | for s in suid nosuid; do |
| 175 | cat busybox.cfg.$s | while read item; do |
| 176 | grep -w "$item" .config.orig |
| 177 | done > .config.app.$s |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 178 | |
| 179 | # workaround for suid bug 10346 |
| 180 | if [ "$s" = "suid" ] ; then |
| 181 | sed "s/.*CONFIG_SH_IS_NONE.*$/CONFIG_SH_IS_NONE=y/" -i .config.app.suid |
| 182 | fi |
| 183 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 184 | merge_config.sh -m .config.nonapps .config.app.$s |
| 185 | oe_runmake busybox_unstripped |
| 186 | mv busybox_unstripped busybox.$s |
| 187 | oe_runmake busybox.links |
Brad Bishop | e2d5b61 | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 188 | sort busybox.links > busybox.links.$s |
| 189 | rm busybox.links |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 190 | done |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 191 | |
| 192 | # hard fail if sh is being linked to the suid busybox (detects bug 10346) |
| 193 | if grep -q -x "/bin/sh" busybox.links.suid; then |
| 194 | bbfatal "busybox suid binary incorrectly provides /bin/sh" |
| 195 | fi |
| 196 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | # cleanup |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 198 | rm .config.app.suid .config.app.nosuid .config.disable.apps .config.nonapps |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 199 | else |
| 200 | oe_runmake busybox_unstripped |
| 201 | cp busybox_unstripped busybox |
| 202 | oe_runmake busybox.links |
| 203 | fi |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 204 | |
| 205 | # restore original .config and autoconf.h, because the install process |
| 206 | # may check these files |
| 207 | cp .config.orig .config |
| 208 | cp include/autoconf.h.orig include/autoconf.h |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | do_install () { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 212 | sed -i "s:^/bin/:BASE_BINDIR/:" busybox.links* |
| 213 | sed -i "s:^/sbin/:BASE_SBINDIR/:" busybox.links* |
| 214 | sed -i "s:^/usr/bin/:BINDIR/:" busybox.links* |
| 215 | sed -i "s:^/usr/sbin/:SBINDIR/:" busybox.links* |
| 216 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 217 | # Move arch/link to BINDIR to match coreutils |
| 218 | sed -i "s:^BASE_BINDIR/arch:BINDIR/arch:" busybox.links* |
| 219 | sed -i "s:^BASE_BINDIR/link:BINDIR/link:" busybox.links* |
| 220 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 221 | sed -i "s:^BASE_BINDIR/:${base_bindir}/:" busybox.links* |
| 222 | sed -i "s:^BASE_SBINDIR/:${base_sbindir}/:" busybox.links* |
| 223 | sed -i "s:^BINDIR/:${bindir}/:" busybox.links* |
| 224 | sed -i "s:^SBINDIR/:${sbindir}/:" busybox.links* |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 225 | |
| 226 | install -d ${D}${sysconfdir}/init.d |
| 227 | |
| 228 | if ! grep -q "CONFIG_FEATURE_INDIVIDUAL=y" ${B}/.config; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 229 | # Install ${base_bindir}/busybox, and the ${base_bindir}/sh link so the postinst script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 230 | # can run. Let update-alternatives handle the rest. |
| 231 | install -d ${D}${base_bindir} |
| 232 | if [ "${BUSYBOX_SPLIT_SUID}" = "1" ]; then |
| 233 | install -m 4755 ${B}/busybox.suid ${D}${base_bindir} |
| 234 | install -m 0755 ${B}/busybox.nosuid ${D}${base_bindir} |
| 235 | install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir} |
| 236 | install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 237 | if grep -q "CONFIG_SH_IS_ASH=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 238 | ln -sf busybox.nosuid ${D}${base_bindir}/sh |
| 239 | fi |
| 240 | # Keep a default busybox for people who want to invoke busybox directly. |
| 241 | # This is also useful for the on device upgrade. Because we want |
| 242 | # to use the busybox command in postinst. |
| 243 | ln -sf busybox.nosuid ${D}${base_bindir}/busybox |
| 244 | else |
| 245 | if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then |
| 246 | install -m 4755 ${B}/busybox ${D}${base_bindir} |
| 247 | else |
| 248 | install -m 0755 ${B}/busybox ${D}${base_bindir} |
| 249 | fi |
| 250 | install -m 0644 ${S}/busybox.links ${D}${sysconfdir} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 251 | if grep -q "CONFIG_SH_IS_ASH=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | ln -sf busybox ${D}${base_bindir}/sh |
| 253 | fi |
| 254 | # We make this symlink here to eliminate the error when upgrading together |
| 255 | # with busybox-syslog. Without this symlink, the opkg may think of the |
| 256 | # busybox.nosuid as obsolete and remove it, resulting in dead links like |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 257 | # ${base_bindir}/sed -> ${base_bindir}/busybox.nosuid. This will make upgrading busybox-syslog fail. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 258 | # This symlink will be safely deleted in postinst, thus no negative effect. |
| 259 | ln -sf busybox ${D}${base_bindir}/busybox.nosuid |
| 260 | fi |
| 261 | else |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 262 | install -d ${D}${base_bindir} ${D}${bindir} ${D}${libdir} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 263 | cat busybox.links | while read FILE; do |
| 264 | NAME=`basename "$FILE"` |
| 265 | install -m 0755 "0_lib/$NAME" "${D}$FILE.${BPN}" |
| 266 | done |
| 267 | # add suid bit where needed |
| 268 | for i in `grep -E "APPLET.*BB_SUID_((MAYBE|REQUIRE))" include/applets.h | grep -v _BB_SUID_DROP | cut -f 3 -d '(' | cut -f 1 -d ','`; do |
| 269 | find ${D} -name $i.${BPN} -exec chmod a+s {} \; |
| 270 | done |
| 271 | install -m 0755 0_lib/libbusybox.so.${PV} ${D}${libdir}/libbusybox.so.${PV} |
| 272 | ln -sf sh.${BPN} ${D}${base_bindir}/sh |
| 273 | ln -sf ln.${BPN} ${D}${base_bindir}/ln |
| 274 | ln -sf test.${BPN} ${D}${bindir}/test |
| 275 | if [ -f ${D}/linuxrc.${BPN} ]; then |
| 276 | mv ${D}/linuxrc.${BPN} ${D}/linuxrc |
| 277 | fi |
| 278 | install -m 0644 ${S}/busybox.links ${D}${sysconfdir} |
| 279 | fi |
| 280 | |
| 281 | if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 282 | install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/syslog |
| 283 | install -m 644 ${WORKDIR}/syslog-startup.conf ${D}${sysconfdir}/syslog-startup.conf |
| 284 | install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/syslog.conf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 285 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 286 | if grep -q "CONFIG_CROND=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 287 | install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/ |
| 288 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 289 | if grep -q "CONFIG_HTTPD=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 290 | install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/ |
| 291 | install -d ${D}/srv/www |
| 292 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 293 | if grep -q "CONFIG_UDHCPD=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 294 | install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/ |
| 295 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 296 | if grep -q "CONFIG_HWCLOCK=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 297 | install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/ |
| 298 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 299 | if grep -q "CONFIG_UDHCPC=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 300 | install -d ${D}${sysconfdir}/udhcpc.d |
| 301 | install -d ${D}${datadir}/udhcpc |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 302 | install -m 0755 ${WORKDIR}/simple.script ${D}${sysconfdir}/udhcpc.d/50default |
| 303 | sed -i "s:/SBIN_DIR/:${base_sbindir}/:" ${D}${sysconfdir}/udhcpc.d/50default |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script |
| 305 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 306 | if grep -q "CONFIG_INETD=y" ${B}/.config; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 307 | install -m 0755 ${WORKDIR}/inetd ${D}${sysconfdir}/init.d/inetd.${BPN} |
| 308 | sed -i "s:/usr/sbin/:${sbindir}/:" ${D}${sysconfdir}/init.d/inetd.${BPN} |
| 309 | install -m 0644 ${WORKDIR}/inetd.conf ${D}${sysconfdir}/ |
| 310 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 311 | if grep -q "CONFIG_MDEV=y" ${B}/.config; then |
| 312 | install -m 0755 ${WORKDIR}/mdev ${D}${sysconfdir}/init.d/mdev |
| 313 | if grep "CONFIG_FEATURE_MDEV_CONF=y" ${B}/.config; then |
| 314 | install -m 644 ${WORKDIR}/mdev.conf ${D}${sysconfdir}/mdev.conf |
| 315 | install -d ${D}${sysconfdir}/mdev |
| 316 | install -m 0755 ${WORKDIR}/find-touchscreen.sh ${D}${sysconfdir}/mdev |
| 317 | install -m 0755 ${WORKDIR}/mdev-mount.sh ${D}${sysconfdir}/mdev |
| 318 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 319 | fi |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 320 | if grep -q "CONFIG_INIT=y" ${B}/.config && ${@bb.utils.contains('VIRTUAL-RUNTIME_init_manager','busybox','true','false',d)}; then |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 321 | install -D -m 0755 ${WORKDIR}/rcS ${D}${sysconfdir}/init.d/rcS |
| 322 | install -D -m 0755 ${WORKDIR}/rcK ${D}${sysconfdir}/init.d/rcK |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 323 | install -D -m 0755 ${WORKDIR}/rcS.default ${D}${sysconfdir}/default/rcS |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 324 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 325 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 326 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then |
| 327 | if grep -q "CONFIG_KLOGD=y" ${B}/.config; then |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 328 | install -d ${D}${systemd_system_unitdir} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 329 | sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-klogd.service.in \ |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 330 | > ${D}${systemd_system_unitdir}/busybox-klogd.service |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 331 | fi |
Brad Bishop | bba38f3 | 2018-08-23 16:11:46 +0800 | [diff] [blame] | 332 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 333 | if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 334 | install -d ${D}${systemd_system_unitdir} |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 335 | sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-syslog.service.in \ |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 336 | > ${D}${systemd_system_unitdir}/busybox-syslog.service |
| 337 | if [ ! -e ${D}${systemd_system_unitdir}/busybox-klogd.service ] ; then |
| 338 | sed -i '/klog/d' ${D}${systemd_system_unitdir}/busybox-syslog.service |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 339 | fi |
| 340 | if [ -f ${WORKDIR}/busybox-syslog.default ] ; then |
| 341 | install -d ${D}${sysconfdir}/default |
| 342 | install -m 0644 ${WORKDIR}/busybox-syslog.default ${D}${sysconfdir}/default/busybox-syslog |
| 343 | fi |
| 344 | fi |
| 345 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 346 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 347 | # Remove the sysvinit specific configuration file for systemd systems to avoid confusion |
| 348 | if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'false', 'true', d)}; then |
| 349 | rm -f ${D}${sysconfdir}/syslog-startup.conf |
| 350 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 351 | } |
| 352 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 353 | PTEST_BINDIR = "1" |
| 354 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 355 | do_install_ptest () { |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 356 | cp -r ${B}/testsuite ${D}${PTEST_PATH}/ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 357 | # These access the internet which is not guaranteed to work on machines running the tests |
| 358 | rm -rf ${D}${PTEST_PATH}/testsuite/wget |
| 359 | sort ${B}/.config > ${D}${PTEST_PATH}/.config |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 360 | ln -s ${base_bindir}/busybox ${D}${PTEST_PATH}/busybox |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 361 | } |
| 362 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 363 | inherit update-alternatives |
| 364 | |
| 365 | ALTERNATIVE_PRIORITY = "50" |
| 366 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 367 | python do_package:prepend () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 368 | # We need to load the full set of busybox provides from the /etc/busybox.links |
| 369 | # Use this to see the update-alternatives with the right information |
| 370 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 371 | dvar = d.getVar('D') |
| 372 | pn = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 373 | def set_alternative_vars(links, target): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 374 | links = d.expand(links) |
| 375 | target = d.expand(target) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 376 | f = open('%s%s' % (dvar, links), 'r') |
| 377 | for alt_link_name in f: |
| 378 | alt_link_name = alt_link_name.strip() |
| 379 | alt_name = os.path.basename(alt_link_name) |
| 380 | # Match coreutils |
| 381 | if alt_name == '[': |
| 382 | alt_name = 'lbracket' |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 383 | if alt_name == 'klogd' or alt_name == 'syslogd': |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 384 | d.appendVar('ALTERNATIVE:%s-syslog' % (pn), ' ' + alt_name) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 385 | else: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 386 | d.appendVar('ALTERNATIVE:%s' % (pn), ' ' + alt_name) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 387 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name) |
| 388 | if os.path.exists('%s%s' % (dvar, target)): |
| 389 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target) |
| 390 | f.close() |
| 391 | return |
| 392 | |
| 393 | if os.path.exists('%s/etc/busybox.links' % (dvar)): |
| 394 | set_alternative_vars("${sysconfdir}/busybox.links", "${base_bindir}/busybox") |
| 395 | else: |
| 396 | set_alternative_vars("${sysconfdir}/busybox.links.nosuid", "${base_bindir}/busybox.nosuid") |
| 397 | set_alternative_vars("${sysconfdir}/busybox.links.suid", "${base_bindir}/busybox.suid") |
| 398 | } |
| 399 | |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 400 | # This part of code is dedicated to the on target upgrade problem. It's known |
| 401 | # that if we don't make appropriate symlinks before update-alternatives calls, |
| 402 | # there will be errors indicating missing commands such as 'sed'. |
| 403 | # These symlinks will later be updated by update-alternatives calls. |
| 404 | # The update-alternatives.bbclass' postinst script runs firstly before other |
| 405 | # postinst, but this part of code needs run firstly, so add this funtion. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 406 | python populate_packages_updatealternatives:append() { |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 407 | postinst = """ |
| 408 | test -n 2 > /dev/null || alias test='busybox test' |
| 409 | if test "x$D" = "x"; then |
| 410 | # Remove busybox.nosuid if it's a symlink, because this situation indicates |
| 411 | # that we're installing or upgrading to a one-binary busybox. |
| 412 | if test -h ${base_bindir}/busybox.nosuid; then |
| 413 | rm -f ${base_bindir}/busybox.nosuid |
| 414 | fi |
| 415 | for suffix in "" ".nosuid" ".suid"; do |
| 416 | if test -e ${sysconfdir}/busybox.links$suffix; then |
| 417 | while read link; do |
| 418 | if test ! -e "$link"; then |
| 419 | # we can use busybox here because even if we are using splitted busybox |
| 420 | # we've made a symlink from /bin/busybox to /bin/busybox.nosuid. |
| 421 | busybox rm -f $link |
| 422 | busybox ln -s "${base_bindir}/busybox$suffix" $link |
| 423 | fi |
| 424 | done < ${sysconfdir}/busybox.links$suffix |
| 425 | fi |
| 426 | done |
| 427 | fi |
| 428 | if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links*; then |
| 429 | grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells |
| 430 | fi |
| 431 | |
| 432 | """ |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 433 | d.prependVar('pkg_postinst:%s' % pkg, postinst) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 434 | } |
| 435 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 436 | pkg_postinst:${PN}:prepend () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 437 | # Need path to saved utils, but they may have be removed on upgrade of busybox |
| 438 | # Only use shell to get paths. Also capture if busybox was saved. |
| 439 | BUSYBOX="" |
| 440 | if [ "x$D" = "x" ] ; then |
| 441 | for busybox_rmdir in /tmp/busyboxrm-*; do |
| 442 | if [ "$busybox_rmdir" != '/tmp/busyboxrm-*' ] ; then |
| 443 | export PATH=$busybox_rmdir:$PATH |
| 444 | if [ -e $busybox_rmdir/busybox* ] ; then |
| 445 | BUSYBOX="$busybox_rmdir/busybox*" |
| 446 | fi |
| 447 | fi |
| 448 | done |
| 449 | fi |
| 450 | } |
| 451 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 452 | pkg_postinst:${PN}:append () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 453 | # If busybox exists in the remove directory it is because it was the only shell left. |
| 454 | if [ "x$D" = "x" ] ; then |
| 455 | if [ "x$BUSYBOX" != "x" ] ; then |
| 456 | update-alternatives --remove sh $BUSYBOX |
| 457 | rm -f $BUSYBOX |
| 458 | fi |
| 459 | fi |
| 460 | } |
| 461 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 462 | pkg_prerm:${PN} () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 463 | # This is so you can make busybox commit suicide - removing busybox with no other packages |
| 464 | # providing its files, this will make update-alternatives work, but the update-rc.d part |
| 465 | # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh |
| 466 | tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX` |
| 467 | ln -s ${base_bindir}/busybox $tmpdir/[ |
| 468 | ln -s ${base_bindir}/busybox $tmpdir/test |
| 469 | ln -s ${base_bindir}/busybox $tmpdir/head |
| 470 | ln -s ${base_bindir}/busybox $tmpdir/sh |
| 471 | ln -s ${base_bindir}/busybox $tmpdir/basename |
| 472 | ln -s ${base_bindir}/busybox $tmpdir/echo |
| 473 | ln -s ${base_bindir}/busybox $tmpdir/mv |
| 474 | ln -s ${base_bindir}/busybox $tmpdir/ln |
| 475 | ln -s ${base_bindir}/busybox $tmpdir/dirname |
| 476 | ln -s ${base_bindir}/busybox $tmpdir/rm |
| 477 | ln -s ${base_bindir}/busybox $tmpdir/sed |
| 478 | ln -s ${base_bindir}/busybox $tmpdir/sort |
| 479 | ln -s ${base_bindir}/busybox $tmpdir/grep |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 480 | ln -s ${base_bindir}/busybox $tmpdir/tail |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 481 | export PATH=$PATH:$tmpdir |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 482 | |
| 483 | # If busybox is the shell, we need to save it since its the lowest priority shell |
| 484 | # Register saved bitbake as the lowest priority shell possible as back up. |
| 485 | if [ -n "$(readlink -f /bin/sh | grep busybox)" ] ; then |
| 486 | BUSYBOX=$(readlink -f /bin/sh) |
| 487 | cp $BUSYBOX $tmpdir/$(basename $BUSYBOX) |
| 488 | update-alternatives --install /bin/sh sh $tmpdir/$(basename $BUSYBOX) 1 |
| 489 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 490 | } |
| 491 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 492 | pkg_postrm:${PN} () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 493 | # Add path to remove dir in case we removed our only grep |
| 494 | if [ "x$D" = "x" ] ; then |
| 495 | for busybox_rmdir in /tmp/busyboxrm-*; do |
| 496 | if [ "$busybox_rmdir" != '/tmp/busyboxrm-*' ] ; then |
| 497 | export PATH=$busybox_rmdir:$PATH |
| 498 | fi |
| 499 | done |
| 500 | fi |
| 501 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 502 | if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then |
| 503 | printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells |
| 504 | fi |
| 505 | } |
| 506 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 507 | pkg_prerm:${PN}-syslog () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 508 | # remove syslog |
| 509 | if test "x$D" = "x"; then |
| 510 | if test "$1" = "upgrade" -o "$1" = "remove"; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 511 | ${sysconfdir}/init.d/syslog stop || : |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 512 | fi |
| 513 | fi |
| 514 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 515 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 516 | RPROVIDES:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/ash', '', d)}" |