summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox.inc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/busybox/busybox.inc')
-rw-r--r--meta/recipes-core/busybox/busybox.inc324
1 files changed, 183 insertions, 141 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index f67bbbc420..bf6ddae7d1 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -1,9 +1,9 @@
SUMMARY = "Tiny versions of many common UNIX utilities in a single small executable"
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."
-HOMEPAGE = "http://www.busybox.net"
+HOMEPAGE = "https://www.busybox.net"
BUGTRACKER = "https://bugs.busybox.net/"
-DEPENDS += "kern-tools-native"
+DEPENDS += "kern-tools-native virtual/crypt"
# bzip2 applet in busybox is based on lightly-modified bzip2 source
# the GPL is version 2 only
@@ -18,7 +18,6 @@ BUSYBOX_SPLIT_SUID ?= "1"
export EXTRA_CFLAGS = "${CFLAGS}"
export EXTRA_LDFLAGS = "${LDFLAGS}"
-# We don't want '-e MAKEFLAGS=' in EXTRA_OEMAKE
EXTRA_OEMAKE = "CC='${CC}' LD='${CCLD}' V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y HOSTCC='${BUILD_CC}' HOSTCPP='${BUILD_CPP}'"
PACKAGES =+ "${PN}-httpd ${PN}-udhcpd ${PN}-udhcpc ${PN}-syslog ${PN}-mdev ${PN}-hwclock"
@@ -40,46 +39,53 @@ INITSCRIPT_NAME_${PN}-syslog = "syslog"
INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd"
SYSTEMD_PACKAGES = "${PN}-syslog"
-SYSTEMD_SERVICE_${PN}-syslog = "busybox-syslog.service"
+SYSTEMD_SERVICE_${PN}-syslog = "${@bb.utils.contains('SRC_URI', 'file://syslog.cfg', 'busybox-syslog.service', '', d)}"
+
+RDEPENDS_${PN}-syslog = "busybox"
+CONFFILES_${PN}-syslog = "${sysconfdir}/syslog-startup.conf"
+RCONFLICTS_${PN}-syslog = "rsyslog sysklogd syslog-ng"
-CONFFILES_${PN}-syslog = "${sysconfdir}/syslog-startup.conf.${BPN}"
CONFFILES_${PN}-mdev = "${sysconfdir}/mdev.conf"
-RRECOMMENDS_${PN} = "${PN}-syslog ${PN}-udhcpc"
+RRECOMMENDS_${PN} = "${PN}-udhcpc"
+
+RDEPENDS_${PN} = "${@["", "busybox-inittab"][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'busybox')]}"
inherit cml1 systemd update-rc.d ptest
+# busybox's unzip test case needs zip command, which busybox itself does not provide
+RDEPENDS_${PN}-ptest = "zip"
+
# internal helper
def busybox_cfg(feature, tokens, cnf, rem):
- if type(tokens) == type(""):
- tokens = [tokens]
- rem.extend(['/^[# ]*' + token + '[ =]/d' for token in tokens])
- if feature:
- cnf.extend([token + '=y' for token in tokens])
- else:
- cnf.extend(['# ' + token + ' is not set' for token in tokens])
+ if type(tokens) == type(""):
+ tokens = [tokens]
+ rem.extend(['/^[# ]*' + token + '[ =]/d' for token in tokens])
+ if feature:
+ cnf.extend([token + '=y' for token in tokens])
+ else:
+ cnf.extend(['# ' + token + ' is not set' for token in tokens])
# Map distro features to config settings
def features_to_busybox_settings(d):
- cnf, rem = ([], [])
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d), 'CONFIG_FEATURE_IPV6', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'largefile', True, False, d), 'CONFIG_LFS', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'largefile', True, False, d), 'CONFIG_FDISK_SUPPORT_LARGE_DISKS', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'nls', True, False, d), 'CONFIG_LOCALE_SUPPORT', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv4', True, False, d), 'CONFIG_FEATURE_IFUPDOWN_IPV4', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d), 'CONFIG_FEATURE_IFUPDOWN_IPV6', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'wifi', True, False, d), 'CONFIG_RFKILL', cnf, rem)
- busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'bluetooth', True, False, d), 'CONFIG_RFKILL', cnf, rem)
- return "\n".join(cnf), "\n".join(rem)
-
-# X, Y = ${@features_to_uclibc_settings(d)}
+ cnf, rem = ([], [])
+ busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d), 'CONFIG_FEATURE_IPV6', cnf, rem)
+ busybox_cfg(True, 'CONFIG_LFS', cnf, rem)
+ busybox_cfg(True, 'CONFIG_FDISK_SUPPORT_LARGE_DISKS', cnf, rem)
+ busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'nls', True, False, d), 'CONFIG_LOCALE_SUPPORT', cnf, rem)
+ busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv4', True, False, d), 'CONFIG_FEATURE_IFUPDOWN_IPV4', cnf, rem)
+ busybox_cfg(bb.utils.contains('DISTRO_FEATURES', 'ipv6', True, False, d), 'CONFIG_FEATURE_IFUPDOWN_IPV6', cnf, rem)
+ busybox_cfg(bb.utils.contains_any('DISTRO_FEATURES', 'bluetooth wifi', True, False, d), 'CONFIG_RFKILL', cnf, rem)
+ return "\n".join(cnf), "\n".join(rem)
+
+# X, Y = ${@features_to_busybox_settings(d)}
# unfortunately doesn't seem to work with bitbake, workaround:
def features_to_busybox_conf(d):
- cnf, rem = features_to_busybox_settings(d)
- return cnf
+ cnf, rem = features_to_busybox_settings(d)
+ return cnf
def features_to_busybox_del(d):
- cnf, rem = features_to_busybox_settings(d)
- return rem
+ cnf, rem = features_to_busybox_settings(d)
+ return rem
configmangle = '/CONFIG_EXTRA_CFLAGS/d; \
'
@@ -103,6 +109,9 @@ python () {
}
do_prepare_config () {
+ if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
+ export KCONFIG_NOTIMESTAMP=1
+ fi
sed -e '/CONFIG_STATIC/d' \
< ${WORKDIR}/defconfig > ${S}/.config
echo "# CONFIG_STATIC is not set" >> .config
@@ -110,15 +119,18 @@ do_prepare_config () {
${S}/.config
sed -i -e '${configmangle}' ${S}/.config
if test ${DO_IPv4} -eq 0 && test ${DO_IPv6} -eq 0; then
- # disable networking applets
- mv ${S}/.config ${S}/.config.oe-tmp
- awk 'BEGIN{net=0}
- /^# Networking Utilities/{net=1}
- /^#$/{if(net){net=net+1}}
- {if(net==2&&$0 !~ /^#/&&$1){print("# "$1" is not set")}else{print}}' \
- ${S}/.config.oe-tmp > ${S}/.config
+ # disable networking applets
+ mv ${S}/.config ${S}/.config.oe-tmp
+ awk 'BEGIN{net=0}
+ /^# Networking Utilities/{net=1}
+ /^#$/{if(net){net=net+1}}
+ {if(net==2&&$0 !~ /^#/&&$1){print("# "$1" is not set")}else{print}}' \
+ ${S}/.config.oe-tmp > ${S}/.config
fi
sed -i 's/CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n"/CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -b"/' ${S}/.config
+ if [ -n "${DEBUG_PREFIX_MAP}" ]; then
+ sed -i 's|${DEBUG_PREFIX_MAP}||g' ${S}/.config
+ fi
}
# returns all the elements from the src uri that are .cfg files
@@ -132,6 +144,7 @@ def find_cfgs(d):
return sources_list
do_configure () {
+ set -x
do_prepare_config
merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
cml1_do_configure
@@ -139,11 +152,24 @@ do_configure () {
do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
+ if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
+ export KCONFIG_NOTIMESTAMP=1
+ fi
if [ "${BUSYBOX_SPLIT_SUID}" = "1" -a x`grep "CONFIG_FEATURE_INDIVIDUAL=y" .config` = x ]; then
- # split the .config into two parts, and make two busybox binaries
+ # split the .config into two parts, and make two busybox binaries
+ if [ -e .config.orig ]; then
+ # Need to guard again an interrupted do_compile - restore any backup
+ cp .config.orig .config
+ fi
cp .config .config.orig
oe_runmake busybox.cfg.suid
oe_runmake busybox.cfg.nosuid
+
+ # workaround for suid bug 10346
+ if ! grep -q "CONFIG_SH_IS_NONE" busybox.cfg.nosuid; then
+ echo "CONFIG_SH_IS_NONE" >> busybox.cfg.suid
+ fi
+
for i in `cat busybox.cfg.suid busybox.cfg.nosuid`; do
echo "# $i is not set" >> .config.disable.apps
done
@@ -153,12 +179,25 @@ do_compile() {
cat busybox.cfg.$s | while read item; do
grep -w "$item" .config.orig
done > .config.app.$s
+
+ # workaround for suid bug 10346
+ if [ "$s" = "suid" ] ; then
+ sed "s/.*CONFIG_SH_IS_NONE.*$/CONFIG_SH_IS_NONE=y/" -i .config.app.suid
+ fi
+
merge_config.sh -m .config.nonapps .config.app.$s
oe_runmake busybox_unstripped
mv busybox_unstripped busybox.$s
oe_runmake busybox.links
- mv busybox.links busybox.links.$s
+ sort busybox.links > busybox.links.$s
+ rm busybox.links
done
+
+ # hard fail if sh is being linked to the suid busybox (detects bug 10346)
+ if grep -q -x "/bin/sh" busybox.links.suid; then
+ bbfatal "busybox suid binary incorrectly provides /bin/sh"
+ fi
+
# copy .config.orig back to .config, because the install process may check this file
cp .config.orig .config
# cleanup
@@ -176,6 +215,10 @@ do_install () {
sed -i "s:^/usr/bin/:BINDIR/:" busybox.links*
sed -i "s:^/usr/sbin/:SBINDIR/:" busybox.links*
+ # Move arch/link to BINDIR to match coreutils
+ sed -i "s:^BASE_BINDIR/arch:BINDIR/arch:" busybox.links*
+ sed -i "s:^BASE_BINDIR/link:BINDIR/link:" busybox.links*
+
sed -i "s:^BASE_BINDIR/:${base_bindir}/:" busybox.links*
sed -i "s:^BASE_SBINDIR/:${base_sbindir}/:" busybox.links*
sed -i "s:^BINDIR/:${bindir}/:" busybox.links*
@@ -192,7 +235,7 @@ do_install () {
install -m 0755 ${B}/busybox.nosuid ${D}${base_bindir}
install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir}
install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir}
- if grep -q "CONFIG_FEATURE_SH_IS_ASH=y" ${B}/.config; then
+ if grep -q "CONFIG_SH_IS_ASH=y" ${B}/.config; then
ln -sf busybox.nosuid ${D}${base_bindir}/sh
fi
# Keep a default busybox for people who want to invoke busybox directly.
@@ -206,7 +249,7 @@ do_install () {
install -m 0755 ${B}/busybox ${D}${base_bindir}
fi
install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
- if grep -q "CONFIG_FEATURE_SH_IS_ASH=y" ${B}/.config; then
+ if grep -q "CONFIG_SH_IS_ASH=y" ${B}/.config; then
ln -sf busybox ${D}${base_bindir}/sh
fi
# We make this symlink here to eliminate the error when upgrading together
@@ -217,8 +260,7 @@ do_install () {
ln -sf busybox ${D}${base_bindir}/busybox.nosuid
fi
else
- install -d ${D}${base_bindir} ${D}${base_sbindir}
- install -d ${D}${libdir} ${D}${bindir} ${D}${sbindir}
+ install -d ${D}${base_bindir} ${D}${bindir} ${D}${libdir}
cat busybox.links | while read FILE; do
NAME=`basename "$FILE"`
install -m 0755 "0_lib/$NAME" "${D}$FILE.${BPN}"
@@ -238,114 +280,94 @@ do_install () {
fi
if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then
- install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/syslog.${BPN}
- install -m 644 ${WORKDIR}/syslog-startup.conf ${D}${sysconfdir}/syslog-startup.conf.${BPN}
- install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/syslog.conf.${BPN}
+ install -m 0755 ${WORKDIR}/syslog ${D}${sysconfdir}/init.d/syslog
+ install -m 644 ${WORKDIR}/syslog-startup.conf ${D}${sysconfdir}/syslog-startup.conf
+ install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/syslog.conf
fi
- if grep "CONFIG_CROND=y" ${B}/.config; then
+ if grep -q "CONFIG_CROND=y" ${B}/.config; then
install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
fi
- if grep "CONFIG_HTTPD=y" ${B}/.config; then
+ if grep -q "CONFIG_HTTPD=y" ${B}/.config; then
install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
install -d ${D}/srv/www
fi
- if grep "CONFIG_UDHCPD=y" ${B}/.config; then
+ if grep -q "CONFIG_UDHCPD=y" ${B}/.config; then
install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
fi
- if grep "CONFIG_HWCLOCK=y" ${B}/.config; then
+ if grep -q "CONFIG_HWCLOCK=y" ${B}/.config; then
install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
fi
- if grep "CONFIG_UDHCPC=y" ${B}/.config; then
+ if grep -q "CONFIG_UDHCPC=y" ${B}/.config; then
install -d ${D}${sysconfdir}/udhcpc.d
install -d ${D}${datadir}/udhcpc
install -m 0755 ${WORKDIR}/simple.script ${D}${sysconfdir}/udhcpc.d/50default
sed -i "s:/SBIN_DIR/:${base_sbindir}/:" ${D}${sysconfdir}/udhcpc.d/50default
install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script
fi
- if grep "CONFIG_INETD=y" ${B}/.config; then
+ if grep -q "CONFIG_INETD=y" ${B}/.config; then
install -m 0755 ${WORKDIR}/inetd ${D}${sysconfdir}/init.d/inetd.${BPN}
sed -i "s:/usr/sbin/:${sbindir}/:" ${D}${sysconfdir}/init.d/inetd.${BPN}
install -m 0644 ${WORKDIR}/inetd.conf ${D}${sysconfdir}/
fi
- if grep "CONFIG_MDEV=y" ${B}/.config; then
- install -m 0755 ${WORKDIR}/mdev ${D}${sysconfdir}/init.d/mdev
- if grep "CONFIG_FEATURE_MDEV_CONF=y" ${B}/.config; then
- install -m 644 ${WORKDIR}/mdev.conf ${D}${sysconfdir}/mdev.conf
- install -d ${D}${sysconfdir}/mdev
- install -m 0755 ${WORKDIR}/find-touchscreen.sh ${D}${sysconfdir}/mdev
- install -m 0755 ${WORKDIR}/mdev-mount.sh ${D}${sysconfdir}/mdev
- fi
+ if grep -q "CONFIG_MDEV=y" ${B}/.config; then
+ install -m 0755 ${WORKDIR}/mdev ${D}${sysconfdir}/init.d/mdev
+ if grep "CONFIG_FEATURE_MDEV_CONF=y" ${B}/.config; then
+ install -m 644 ${WORKDIR}/mdev.conf ${D}${sysconfdir}/mdev.conf
+ install -d ${D}${sysconfdir}/mdev
+ install -m 0755 ${WORKDIR}/find-touchscreen.sh ${D}${sysconfdir}/mdev
+ install -m 0755 ${WORKDIR}/mdev-mount.sh ${D}${sysconfdir}/mdev
+ fi
+ fi
+ if grep -q "CONFIG_INIT=y" ${B}/.config; then
+ install -D -m 0755 ${WORKDIR}/rcS ${D}${sysconfdir}/init.d/rcS
+ install -D -m 0755 ${WORKDIR}/rcK ${D}${sysconfdir}/init.d/rcK
fi
- if grep "CONFIG_INIT=y" ${B}/.config; then
- install -D -m 0777 ${WORKDIR}/rcS ${D}${sysconfdir}/init.d/rcS
- install -D -m 0777 ${WORKDIR}/rcK ${D}${sysconfdir}/init.d/rcK
- install -D -m 0755 ${WORKDIR}/runlevel ${D}${base_sbindir}/runlevel
- if grep "CONFIG_FEATURE_USE_INITTAB=y" ${B}/.config; then
- install -D -m 0777 ${WORKDIR}/inittab ${D}${sysconfdir}/inittab
- tmp="${SERIAL_CONSOLES}"
- for i in $tmp
- do
- j=`echo ${i} | sed s/\;/\ /g`
- id=`echo ${i} | sed -e 's/^.*;//' -e 's/;.*//'`
- echo "$id::respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
- done
- fi
- fi
- if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
- if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then
- install -d ${D}${systemd_unitdir}/system
- sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-syslog.service.in \
- > ${D}${systemd_unitdir}/system/busybox-syslog.service
- if [ -f ${WORKDIR}/busybox-syslog.default ] ; then
- install -d ${D}${sysconfdir}/default
- install -m 0644 ${WORKDIR}/busybox-syslog.default ${D}${sysconfdir}/default/busybox-syslog
- fi
- ln -sf /dev/null ${D}${systemd_unitdir}/system/syslog.service
- fi
- if grep -q "CONFIG_KLOGD=y" ${B}/.config; then
- install -d ${D}${systemd_unitdir}/system
- sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-klogd.service.in \
- > ${D}${systemd_unitdir}/system/busybox-klogd.service
- fi
- fi
+ if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+ if grep -q "CONFIG_KLOGD=y" ${B}/.config; then
+ install -d ${D}${systemd_unitdir}/system
+ sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-klogd.service.in \
+ > ${D}${systemd_unitdir}/system/busybox-klogd.service
+ fi
- # Remove the sysvinit specific configuration file for systemd systems to avoid confusion
- if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'false', 'true', d)}; then
- rm -f ${D}${sysconfdir}/syslog-startup.conf.${BPN}
- fi
+ if grep -q "CONFIG_SYSLOGD=y" ${B}/.config; then
+ install -d ${D}${systemd_unitdir}/system
+ sed 's,@base_sbindir@,${base_sbindir},g' < ${WORKDIR}/busybox-syslog.service.in \
+ > ${D}${systemd_unitdir}/system/busybox-syslog.service
+ if [ ! -e ${D}${systemd_unitdir}/system/busybox-klogd.service ] ; then
+ sed -i '/klog/d' ${D}${systemd_unitdir}/system/busybox-syslog.service
+ fi
+ if [ -f ${WORKDIR}/busybox-syslog.default ] ; then
+ install -d ${D}${sysconfdir}/default
+ install -m 0644 ${WORKDIR}/busybox-syslog.default ${D}${sysconfdir}/default/busybox-syslog
+ fi
+ fi
+ fi
+
+ # Remove the sysvinit specific configuration file for systemd systems to avoid confusion
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'false', 'true', d)}; then
+ rm -f ${D}${sysconfdir}/syslog-startup.conf
+ fi
}
+PTEST_BINDIR = "1"
+
do_install_ptest () {
- cp -r ${B}/testsuite ${D}${PTEST_PATH}/
- cp ${B}/.config ${D}${PTEST_PATH}/
- ln -s /bin/busybox ${D}${PTEST_PATH}/busybox
+ cp -r ${B}/testsuite ${D}${PTEST_PATH}/
+ cp ${B}/.config ${D}${PTEST_PATH}/
+ ln -s /bin/busybox ${D}${PTEST_PATH}/busybox
}
inherit update-alternatives
ALTERNATIVE_PRIORITY = "50"
-ALTERNATIVE_${PN}-syslog += "syslog-conf"
-ALTERNATIVE_LINK_NAME[syslog-conf] = "${sysconfdir}/syslog.conf"
-
-python () {
- if bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
- pn = d.getVar('PN', True)
- d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' syslog-init')
- d.setVarFlag('ALTERNATIVE_LINK_NAME', 'syslog-init', '%s/init.d/syslog' % (d.getVar('sysconfdir', True)))
- d.setVarFlag('ALTERNATIVE_TARGET', 'syslog-init', '%s/init.d/syslog.%s' % (d.getVar('sysconfdir', True), d.getVar('BPN', True)))
- d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' syslog-startup-conf')
- d.setVarFlag('ALTERNATIVE_LINK_NAME', 'syslog-startup-conf', '%s/syslog-startup.conf' % (d.getVar('sysconfdir', True)))
- d.setVarFlag('ALTERNATIVE_TARGET', 'syslog-startup-conf', '%s/syslog-startup.conf.%s' % (d.getVar('sysconfdir', True), d.getVar('BPN', True)))
-}
-
python do_package_prepend () {
# We need to load the full set of busybox provides from the /etc/busybox.links
# Use this to see the update-alternatives with the right information
- dvar = d.getVar('D', True)
- pn = d.getVar('PN', True)
+ dvar = d.getVar('D')
+ pn = d.getVar('PN')
def set_alternative_vars(links, target):
links = d.expand(links)
target = d.expand(target)
@@ -356,7 +378,10 @@ python do_package_prepend () {
# Match coreutils
if alt_name == '[':
alt_name = 'lbracket'
- d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name)
+ if alt_name == 'klogd' or alt_name == 'syslogd':
+ d.appendVar('ALTERNATIVE_%s-syslog' % (pn), ' ' + alt_name)
+ else:
+ d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name)
d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name)
if os.path.exists('%s%s' % (dvar, target)):
d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target)
@@ -370,31 +395,40 @@ python do_package_prepend () {
set_alternative_vars("${sysconfdir}/busybox.links.suid", "${base_bindir}/busybox.suid")
}
-pkg_postinst_${PN} () {
- # This part of code is dedicated to the on target upgrade problem.
- # It's known that if we don't make appropriate symlinks before update-alternatives calls,
- # there will be errors indicating missing commands such as 'sed'.
- # These symlinks will later be updated by update-alternatives calls.
- test -n 2 > /dev/null || alias test='busybox test'
- if test "x$D" = "x"; then
- # Remove busybox.nosuid if it's a symlink, because this situation indicates
- # that we're installing or upgrading to a one-binary busybox.
- if test -h ${base_bindir}/busybox.nosuid; then
- rm -f ${base_bindir}/busybox.nosuid
- fi
- for suffix in "" ".nosuid" ".suid"; do
- if test -e ${sysconfdir}/busybox.links$suffix; then
- while read link; do
- if test ! -e "$link"; then
- # we can use busybox here because even if we are using splitted busybox
- # we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
- busybox rm -f $link
- busybox ln -s "${base_bindir}/busybox$suffix" $link
- fi
- done < ${sysconfdir}/busybox.links$suffix
- fi
- done
- fi
+# This part of code is dedicated to the on target upgrade problem. It's known
+# that if we don't make appropriate symlinks before update-alternatives calls,
+# there will be errors indicating missing commands such as 'sed'.
+# These symlinks will later be updated by update-alternatives calls.
+# The update-alternatives.bbclass' postinst script runs firstly before other
+# postinst, but this part of code needs run firstly, so add this funtion.
+python populate_packages_updatealternatives_append() {
+ postinst = """
+test -n 2 > /dev/null || alias test='busybox test'
+if test "x$D" = "x"; then
+ # Remove busybox.nosuid if it's a symlink, because this situation indicates
+ # that we're installing or upgrading to a one-binary busybox.
+ if test -h ${base_bindir}/busybox.nosuid; then
+ rm -f ${base_bindir}/busybox.nosuid
+ fi
+ for suffix in "" ".nosuid" ".suid"; do
+ if test -e ${sysconfdir}/busybox.links$suffix; then
+ while read link; do
+ if test ! -e "$link"; then
+ # we can use busybox here because even if we are using splitted busybox
+ # we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
+ busybox rm -f $link
+ busybox ln -s "${base_bindir}/busybox$suffix" $link
+ fi
+ done < ${sysconfdir}/busybox.links$suffix
+ fi
+ done
+fi
+if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links*; then
+ grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
+fi
+
+"""
+ d.prependVar('pkg_postinst_%s' % pkg, postinst)
}
pkg_prerm_${PN} () {
@@ -419,11 +453,19 @@ pkg_prerm_${PN} () {
export PATH=$PATH:$tmpdir
}
+pkg_postrm_${PN} () {
+ if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then
+ printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
+ fi
+}
+
pkg_prerm_${PN}-syslog () {
# remove syslog
if test "x$D" = "x"; then
if test "$1" = "upgrade" -o "$1" = "remove"; then
- ${sysconfdir}/init.d/syslog stop
+ ${sysconfdir}/init.d/syslog stop || :
fi
fi
}
+
+RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/ash', '', d)}"