diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-08-31 18:51:14 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-08-31 18:51:14 +0200 |
commit | e717d934ab702bdabeab90b0b8166e5d92533b70 (patch) | |
tree | a303808e5fc3ff66c8995743441aa1d1ce5b0001 | |
parent | 047690be24fe7cdc315c7bbdaa6349abeaf16113 (diff) | |
download | meta-gluon-e717d934ab702bdabeab90b0b8166e5d92533b70.tar meta-gluon-e717d934ab702bdabeab90b0b8166e5d92533b70.zip |
busybox: fix installation with merged /usr
-rw-r--r-- | recipes-core/busybox/busybox_%.bbappend | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/recipes-core/busybox/busybox_%.bbappend b/recipes-core/busybox/busybox_%.bbappend new file mode 100644 index 0000000..1c6ab1c --- /dev/null +++ b/recipes-core/busybox/busybox_%.bbappend @@ -0,0 +1,207 @@ +do_install () { + sed -i "s:^/bin/:BASE_BINDIR/:" busybox.links* + sed -i "s:^/sbin/:BASE_SBINDIR/:" busybox.links* + sed -i "s:^/usr/bin/:BINDIR/:" busybox.links* + sed -i "s:^/usr/sbin/:SBINDIR/:" 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* + sed -i "s:^SBINDIR/:${sbindir}/:" busybox.links* + + install -d ${D}${sysconfdir}/init.d + + if ! grep -q "CONFIG_FEATURE_INDIVIDUAL=y" ${B}/.config; then + # Install ${base_bindir}/busybox, and the ${base_bindir}/sh link so the postinst script + # can run. Let update-alternatives handle the rest. + install -d ${D}${base_bindir} + if [ "${BUSYBOX_SPLIT_SUID}" = "1" ]; then + install -m 4755 ${B}/busybox.suid ${D}${base_bindir} + 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 + ln -sf busybox.nosuid ${D}${base_bindir}/sh + fi + # Keep a default busybox for people who want to invoke busybox directly. + # This is also useful for the on device upgrade. Because we want + # to use the busybox command in postinst. + ln -sf busybox.nosuid ${D}${base_bindir}/busybox + else + if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then + install -m 4755 ${B}/busybox ${D}${base_bindir} + else + 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 + ln -sf busybox ${D}${base_bindir}/sh + fi + # We make this symlink here to eliminate the error when upgrading together + # with busybox-syslog. Without this symlink, the opkg may think of the + # busybox.nosuid as obsolete and remove it, resulting in dead links like + # ${base_bindir}/sed -> ${base_bindir}/busybox.nosuid. This will make upgrading busybox-syslog fail. + # This symlink will be safely deleted in postinst, thus no negative effect. + 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} + cat busybox.links | while read FILE; do + NAME=`basename "$FILE"` + install -m 0755 "0_lib/$NAME" "${D}$FILE.${BPN}" + done + # add suid bit where needed + 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 + find ${D} -name $i.${BPN} -exec chmod a+s {} \; + done + install -m 0755 0_lib/libbusybox.so.${PV} ${D}${libdir}/libbusybox.so.${PV} + ln -sf sh.${BPN} ${D}${base_bindir}/sh + ln -sf ln.${BPN} ${D}${base_bindir}/ln + ln -sf test.${BPN} ${D}${bindir}/test + if [ -f ${D}/linuxrc.${BPN} ]; then + mv ${D}/linuxrc.${BPN} ${D}/linuxrc + fi + install -m 0644 ${S}/busybox.links ${D}${sysconfdir} + 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} + fi + if grep "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 + install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/ + install -d ${D}/srv/www + fi + if grep "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 + install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/ + fi + if grep "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 + install -m 0755 ${WORKDIR}/default.script ${D}${datadir}/udhcpc/default.script + fi + if grep "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 + 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 + + # 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 +} + +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) + def set_alternative_vars(links, target): + f = open('%s%s' % (dvar, links), 'r') + for alt_link_name in f: + alt_link_name = alt_link_name.strip() + alt_name = os.path.basename(alt_link_name) + # Match coreutils + if alt_name == '[': + alt_name = 'lbracket' + 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) + f.close() + return + + base_bindir = d.getVar('base_bindir', True) + + if os.path.exists('%s/etc/busybox.links' % (dvar)): + set_alternative_vars("/etc/busybox.links", base_bindir + "/busybox") + else: + set_alternative_vars("/etc/busybox.links.nosuid", base_bindir + "/busybox.nosuid") + set_alternative_vars("/etc/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 /etc/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 ${base_bindir}/busybox to ${base_bindir}/busybox.nosuid. + busybox rm -f $link + busybox ln -s ${base_bindir}/busybox$suffix $link + fi + done < /etc/busybox.links$suffix + fi + done + fi +} + +pkg_prerm_${PN} () { + # This is so you can make busybox commit suicide - removing busybox with no other packages + # providing its files, this will make update-alternatives work, but the update-rc.d part + # for syslog, httpd and/or udhcpd will fail if there is no other package providing sh + tmpdir=`mktemp -d /tmp/busyboxrm-XXXXXX` + ln -s ${base_bindir}/busybox $tmpdir/[ + ln -s ${base_bindir}/busybox $tmpdir/test + ln -s ${base_bindir}/busybox $tmpdir/head + ln -s ${base_bindir}/busybox $tmpdir/sh + ln -s ${base_bindir}/busybox $tmpdir/basename + ln -s ${base_bindir}/busybox $tmpdir/echo + ln -s ${base_bindir}/busybox $tmpdir/mv + ln -s ${base_bindir}/busybox $tmpdir/ln + ln -s ${base_bindir}/busybox $tmpdir/dirname + ln -s ${base_bindir}/busybox $tmpdir/rm + ln -s ${base_bindir}/busybox $tmpdir/sed + ln -s ${base_bindir}/busybox $tmpdir/sort + ln -s ${base_bindir}/busybox $tmpdir/grep + export PATH=$PATH:$tmpdir +} |