[oe] [PATCH] busybox: fix defconfig handling problems triggered by "configure according to {MACHINE, DISTRO}_FEATURES"; added inetd handling (resent)

Hauser, Wolfgang (external) Wolfgang.Hauser.external at eads.com
Mon Aug 9 08:12:14 UTC 2010


busybox: fix defconfig/.config usage; add inetd, telnetd package; add
inetd support for ftpd, telnetd, httpd

*Use ${S}/.config instead of ${WORKINGDIR}/defconfig for installing
confguration dependend parts.
*This applies the changes done by DISTRO_FEATURES processing.
*Added configuration dependend packages for inetd, telnetd, httpd which
enable inetd based daemon starting or standalone starting.
*Enable starting of ftpd by inetd.
---
 recipes/busybox/busybox.inc           |  220
++++++++++++++++++++++++++++++---
 recipes/busybox/busybox_1.16.2.bb     |    7 +-
 recipes/busybox/files/busybox-inetd   |   43 +++++++
 recipes/busybox/files/busybox-telnetd |   39 ++++++
 recipes/busybox/files/inetd.conf      |    9 ++
 5 files changed, 296 insertions(+), 22 deletions(-)
 create mode 100644 recipes/busybox/files/busybox-inetd
 create mode 100644 recipes/busybox/files/busybox-telnetd
 create mode 100644 recipes/busybox/files/inetd.conf

diff --git a/recipes/busybox/busybox.inc b/recipes/busybox/busybox.inc
index a64c031..b4663f0 100644
--- a/recipes/busybox/busybox.inc
+++ b/recipes/busybox/busybox.inc
@@ -26,13 +26,23 @@ SRC_URI = "\
   file://syslog.conf \
   file://udhcpscript.patch \
   file://umount.busybox \
+  file://inetd.conf \
+  file://busybox-inetd \
+  file://busybox-telnetd \
 "
 
 SRC_URI_append_nylon = " file://xargs-double-size.patch"
 
 export EXTRA_CFLAGS = "${CFLAGS}"
 EXTRA_OEMAKE_append = " CROSS=${HOST_PREFIX}"
-PACKAGES =+ "${PN}-mountall ${PN}-httpd ${PN}-syslog ${PN}-udhcpd"
+PACKAGES =+ " ${PN}-mountall ${PN}-httpd ${PN}-syslog ${PN}-udhcpd
${PN}-telnetd ${PN}-inetd "
+
+DESCRIPTION_${PN}-inetd = "Add starting busybox inetd as daemon while
booting"
+DESCRIPTION_${PN}-httpd = "Add starting busybox httpd as daemon while
booting"
+DESCRIPTION_${PN}-syslog = "Add busybox syslog"
+DESCRIPTION_${PN}-udhcpd = "Add starting busybox udhcpd as daemon while
booting"
+DESCRIPTION_${PN}-telnetd = "Add starting busybox telnetd as daemon
while booting"
+DESCRIPTION_${PN}-mountall = "Add busybox mountall"
 
 # We need this RRECOMMENDS_${PN} because libc dlopens libgcc
 # and shlib mechanism can not detect it because its not
@@ -48,16 +58,25 @@ RRECOMMENDS_${PN} += "libgcc ${PN}-syslog"
 FILES_${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www"
 FILES_${PN}-syslog = "${sysconfdir}/init.d/syslog.${PN}
${sysconfdir}/syslog.conf"
 FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd"
+FILES_${PN}-telnetd = "${sysconfdir}/init.d/busybox-telnetd"
 
 FILES_${PN} += "${datadir}/udhcpc"
 
+FILES_${PN}-inetd = " \
+  ${sysconfdir}/init.d/busybox-inetd \
+  ${sysconfdir}/inetd.conf \
+"
+
 # syslog initscript is handled explicitly because order of
 # update-rc.d and update-alternatives is important (see below)
-INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-udhcpd"
+INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-udhcpd ${PN}-inetd
${PN}-telnetd"
 INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd"
 INITSCRIPT_NAME_${PN}-syslog = "syslog"
 INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd"
+INITSCRIPT_NAME_${PN}-inetd = "busybox-inetd"
+INITSCRIPT_NAME_${PN}-telnetd = "busybox-telnetd"
 CONFFILES_${PN}-syslog = "${sysconfdir}/syslog.conf"
+CONFFILES_${PN}-inetd = "${sysconfdir}/inetd.conf"
 
 # This disables the syslog startup links in slugos (see slugos-init)
 INITSCRIPT_PARAMS_${PN}-syslog_slugos = "start 20 ."
@@ -65,12 +84,14 @@ INITSCRIPT_PARAMS_${PN}-syslog_slugos = "start 20 ."
 RDEPENDS_${PN}-httpd += "${PN}"
 RDEPENDS_${PN}-syslog += "${PN}"
 RDEPENDS_${PN}-udhcpd += "${PN}"
+RDEPENDS_${PN}-inetd += "${PN}"
+RDEPENDS_${PN}-telnetd += "${PN}"
 
 # Use gcc for linking so LDFLAGS actually makes sense
 LD = "${CC} -nostdlib"
 
 inherit cml1 update-rc.d
-require busybox-config.inc
+require recipes/busybox/busybox-config.inc
 
 configmangle = '/CROSS_COMPILER_PREFIX/d; \
    /CONFIG_EXTRA_CFLAGS/d; \
@@ -135,11 +156,14 @@ do_install () {
 
  install -d ${D}${sysconfdir}/init.d
 
- if ! grep -q "CONFIG_FEATURE_INDIVIDUAL=y" ${WORKDIR}/defconfig; then
+        #use the fixed config file to get real build settings
+        BUSYBOX_CONFIG_FILE=${S}/.config
+
+ if ! grep -q "CONFIG_FEATURE_INDIVIDUAL=y" $BUSYBOX_CONFIG_FILE; then
    # Install /bin/busybox, and the /bin/sh link so the postinst script
    # can run. Let update-alternatives handle the rest.
    install -d ${D}${base_bindir}
-   if grep -q "CONFIG_FEATURE_SUID=y" ${WORKDIR}/defconfig; then
+   if grep -q "CONFIG_FEATURE_SUID=y" $BUSYBOX_CONFIG_FILE; then
      install -m 4755 ${S}/busybox ${D}${base_bindir}
    else
      install -m 0755 ${S}/busybox ${D}${base_bindir}
@@ -165,34 +189,97 @@ do_install () {
    fi
  fi
 
- if grep -q "CONFIG_SYSLOGD=y" ${WORKDIR}/defconfig; then
+ if grep -q "CONFIG_SYSLOGD=y" $BUSYBOX_CONFIG_FILE; then
    install -m 0755 ${WORKDIR}/syslog
${D}${sysconfdir}/init.d/syslog.${PN}
    install -m 644 ${WORKDIR}/syslog.conf ${D}${sysconfdir}/
  fi
- if grep "CONFIG_CROND=y" ${WORKDIR}/defconfig; then
+ if grep "CONFIG_CROND=y" $BUSYBOX_CONFIG_FILE; then
    install -m 0755 ${WORKDIR}/busybox-cron ${D}${sysconfdir}/init.d/
  fi
- if grep "CONFIG_HTTPD=y" ${WORKDIR}/defconfig; then
-   install -m 0755 ${WORKDIR}/busybox-httpd ${D}${sysconfdir}/init.d/
-   install -d ${D}/srv/www
- fi
- if grep "CONFIG_APP_UDHCPD=y" ${WORKDIR}/defconfig; then
+ if grep "CONFIG_APP_UDHCPD=y" $BUSYBOX_CONFIG_FILE; then
    install -m 0755 ${WORKDIR}/busybox-udhcpd ${D}${sysconfdir}/init.d/
  fi
- if grep "CONFIG_HWCLOCK=y" ${WORKDIR}/defconfig; then
+ if grep "CONFIG_HWCLOCK=y" $BUSYBOX_CONFIG_FILE; then
    install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
  fi
- if grep "CONFIG_APP_UDHCPC=y" ${WORKDIR}/defconfig; then
+ if grep "CONFIG_APP_UDHCPC=y" $BUSYBOX_CONFIG_FILE; 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_FEATURE_MOUNT_FSTAB=y" ${WORKDIR}/defconfig; then
+
+ if grep "CONFIG_FEATURE_MOUNT_FSTAB=y" $BUSYBOX_CONFIG_FILE; then
    install -d ${D}${sysconfdir}/default
    install -m 644 ${WORKDIR}/mountall
${D}${sysconfdir}/default/mountall.${PN}
  fi
 
+        #Startup and configuration for inetd deamon
+        Use_Inetd="no"
+ if grep "CONFIG_INETD=y" $BUSYBOX_CONFIG_FILE; then
+                Use_Inetd="yes"
+                install -m 0755 ${WORKDIR}/busybox-inetd
${D}${sysconfdir}/init.d/
+                if [ ! -f ${D}${sysconfdir}/inetd.conf ]; then
+                   install -m 0755 ${WORKDIR}/inetd.conf
${D}${sysconfdir}/
+                fi
+ fi
+
+        #Startup of telnetd deamon
+        if grep "CONFIG_TELNETD=y" $BUSYBOX_CONFIG_FILE; then
+
+          #insert line into inetd.conf 
+   if [ ${Use_Inetd} == "yes" ]; then
+                if [ ! -f ${D}${sysconfdir}/inetd.conf ]; then
+                   install -m 0755 ${WORKDIR}/inetd.conf
${D}${sysconfdir}/
+                fi
+                #remove old entry if available
+                grep -v telnet ${D}${sysconfdir}/inetd.conf >
${D}${sysconfdir}/inetd.conf_new
+                #add new entry for telnetd
+                echo "telnet stream tcp nowait root /usr/sbin/telnetd
telnetd -i -K" >>  ${D}${sysconfdir}/inetd.conf_new
+                mv ${D}${sysconfdir}/inetd.conf_new
${D}${sysconfdir}/inetd.conf
+          fi
+
+          #install start script 
+          install -m 0755 ${WORKDIR}/busybox-telnetd
${D}${sysconfdir}/init.d/
+
+        fi
+
+        #Startup of ftpd deamon  
+        if grep "CONFIG_FTPD=y" $BUSYBOX_CONFIG_FILE; then
+
+          #insert line into inetd.conf 
+   if [ ${Use_Inetd} == "yes" ]; then
+                if [ ! -f ${D}${sysconfdir}/inetd.conf ]; then
+                   install -m 0755 ${WORKDIR}/inetd.conf
${D}${sysconfdir}/
+                fi
+                #remove old entry if available
+                grep -v ftp ${D}${sysconfdir}/inetd.conf >
${D}${sysconfdir}/inetd.conf_new
+                #add new entry for telnetd
+                echo "ftp stream tcp nowait root /usr/sbin/ftpd ftpd
-w" >>  ${D}${sysconfdir}/inetd.conf_new
+                mv ${D}${sysconfdir}/inetd.conf_new
${D}${sysconfdir}/inetd.conf
+          fi
+        fi
+
+        #Startup of httpd deamon
+ if grep "CONFIG_HTTPD=y" $BUSYBOX_CONFIG_FILE; then
+
+          #insert line into inetd.conf 
+   if [ ${Use_Inetd} == "yes" ]; then
+                if [ ! -f ${D}${sysconfdir}/inetd.conf ]; then
+                   install -m 0755 ${WORKDIR}/inetd.conf
${D}${sysconfdir}/
+                fi
+                #remove old entry if available
+                grep -v http ${D}${sysconfdir}/inetd.conf >
${D}${sysconfdir}/inetd.conf_new
+                #add new entry for httpd
+                echo "http stream tcp nowait root /usr/sbin/httpd httpd
-i -h /srv/www" >>  ${D}${sysconfdir}/inetd.conf_new
+                mv ${D}${sysconfdir}/inetd.conf_new
${D}${sysconfdir}/inetd.conf
+          fi
+
+          install -m 0755 ${WORKDIR}/busybox-httpd
${D}${sysconfdir}/init.d/
+   install -d ${D}/srv/www
+
+ fi
+
  install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
 }
 
@@ -321,11 +408,104 @@ FILES_${PN}-linuxrc = "linuxrc"
 RDEPENDS_${PN}-linuxrc += "${PN}"
 
 pkg_postinst_${PN}-mdev() {
-if test "x$D" != "x"; then
- OPT="-r $D"
-else
- OPT="-s"
-fi
+        if test "x$D" != "x"; then
+         OPT="-r $D"
+        else
+         OPT="-s"
+        fi
  update-rc.d $OPT mdev start 06 S .
 }
 
+pkg_postinst_${PN}-inetd() {
+
+        if test "x$D" != "x"; then
+         OPT="-r $D"
+        else
+         OPT="-s"
+        fi
+
+        update-rc.d $OPT busybox-inetd defaults 25 75
+}
+
+pkg_postrm_${PN}-inetd () {
+ if test "x$D" != "x"; then
+   OPT="-r $D"
+ else
+   OPT=""
+ fi
+ if test "$1" = "remove" -o "$1" = "purge"; then
+   if ! test -e "/etc/init.d/busybox-inetd"; then
+     update-rc.d $OPT busybox-inetd remove
+   fi
+ fi
+
+        echo "Install ${PN}-<service> to enable nedded services e.g.
httpd, telnetd ..."
+}
+
+pkg_postinst_${PN}-httpd() {
+        if test "x$D" != "x"; then
+         OPT="-r $D"
+
+        else
+         OPT="-s"
+        fi
+
+        #remove from starting through inetd
+        if [ -f $D/etc/inetd.conf ]; then
+                #remove old entry if available
+                grep -v http $D/etc/inetd.conf > $D/etc/inetd.conf_new
+                mv $D/etc/inetd.conf_new $D/etc/inetd.conf
+        fi
+
+        update-rc.d $OPT busybox-httpd defaults  30 70
+}
+
+pkg_postrm_${PN}-httpd () {
+ if test "x$D" != "x"; then
+   OPT="-r $D"
+ else
+   OPT=""
+ fi
+ if test "$1" = "remove" -o "$1" = "purge"; then
+   if ! test -e "/etc/init.d/busybox-httpd"; then
+     update-rc.d $OPT busybox-httpd remove
+   fi
+ fi
+
+        echo "Install ${PN}-inetd again for enabling startup httpd by
inetd"
+}
+
+
+pkg_postinst_${PN}-telnetd() {
+        if test "x$D" != "x"; then
+         OPT="-r $D"
+        else
+         OPT="-s"
+        fi
+
+        update-rc.d $OPT busybox-telnetd defaults 35 65
+
+        #remove from starting through inetd
+        if [ -f $D/etc/inetd.conf ]; then
+                #remove old entry if available
+                grep -v telnet $D/etc/inetd.conf >
$D/etc/inetd.conf_new
+                mv $D/etc/inetd.conf_new $D/etc/inetd.conf
+        fi
+
+}
+
+pkg_postrm_${PN}-telnetd () {
+ if test "x$D" != "x"; then
+   OPT="-r $D"
+ else
+   OPT=""
+ fi
+ if test "$1" = "remove" -o "$1" = "purge"; then
+   if ! test -e "/etc/init.d/busybox-telnetd"; then
+     update-rc.d $OPT busybox-telnetd remove
+   fi
+ fi
+
+        echo "Install ${PN}-inetd again for enabling startup telnetd by
inetd"
+}
+
diff --git a/recipes/busybox/busybox_1.16.2.bb
b/recipes/busybox/busybox_1.16.2.bb
index c5d27b7..6401bfa 100644
--- a/recipes/busybox/busybox_1.16.2.bb
+++ b/recipes/busybox/busybox_1.16.2.bb
@@ -29,6 +29,9 @@ SRC_URI = "\
   file://defconfig \
   file://mdev \
   file://mdev.conf \
+  file://inetd.conf \
+  file://busybox-inetd \
+  file://busybox-telnetd \
 "
 
 SRC_URI[tarball.md5sum] = "2ba980f720a5bdce4ec05423519acc35"
@@ -49,11 +52,11 @@ do_install_append() {
     install -m 0755 ${WORKDIR}/find-touchscreen.sh
${D}${sysconfdir}/mdev/
     install -m 0755 ${WORKDIR}/mdev ${D}${sysconfdir}/init.d/
 
-    if grep "CONFIG_UDHCPD=y" ${WORKDIR}/defconfig; then
+    if grep "CONFIG_UDHCPD=y" ${S}/.config; then
           install -m 0755 ${WORKDIR}/busybox-udhcpd
${D}${sysconfdir}/init.d/
     fi
 
-    if grep "CONFIG_UDHCPC=y" ${WORKDIR}/defconfig; then
+    if grep "CONFIG_UDHCPC=y" ${S}/.config; then
           install -d ${D}${sysconfdir}/udhcpc.d
           install -d ${D}${datadir}/udhcpc
           install -m 0755 ${WORKDIR}/simple.script
${D}${sysconfdir}/udhcpc.d/50default
diff --git a/recipes/busybox/files/busybox-inetd
b/recipes/busybox/files/busybox-inetd
new file mode 100644
index 0000000..f910a69
--- /dev/null
+++ b/recipes/busybox/files/busybox-inetd
@@ -0,0 +1,43 @@
+#!/bin/sh
+DAEMON=/usr/sbin/inetd
+NAME=inetd
+DESC="Busybox INETD"
+ARGS="/etc/inetd.conf"
+
+test -f $DAEMON || exit 1
+
+set -e
+
+case "$1" in
+    start)
+        echo -n "starting $DESC: $NAME... "
+ if [ ! -f /etc/inetd.conf ]; then
+   echo "error: /etc/inetd.conf is missing."
+   exit 1
+ fi
+ /sbin/start-stop-daemon -S -b -n $NAME -a $DAEMON -- $ARGS
+ echo "done."
+ ;;
+    stop)
+        echo -n "stopping $DESC: $NAME... "
+ /sbin/start-stop-daemon -K -n $NAME
+ echo "done."
+ ;;
+    restart)
+        echo "restarting $DESC: $NAME... "
+   $0 stop
+ $0 start
+ echo "done."
+ ;;
+    reload)
+     echo -n "reloading $DESC: $NAME... "
+     killall -HUP $(basename ${DAEMON})
+ echo "done."
+ ;;
+    *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/recipes/busybox/files/busybox-telnetd
b/recipes/busybox/files/busybox-telnetd
new file mode 100644
index 0000000..9830e07
--- /dev/null
+++ b/recipes/busybox/files/busybox-telnetd
@@ -0,0 +1,39 @@
+#!/bin/sh
+DAEMON=/usr/sbin/telnetd
+NAME=telnetd
+DESC="Busybox TELNET Daemon"
+ARGS="-K"
+
+test -f $DAEMON || exit 1
+
+set -e
+
+case "$1" in
+    start)
+        echo -n "starting $DESC: $NAME... "
+ /sbin/start-stop-daemon -S -b -n $NAME -a $DAEMON -- $ARGS
+ echo "done."
+ ;;
+    stop)
+        echo -n "stopping $DESC: $NAME... "
+ /sbin/start-stop-daemon -K -n $NAME
+ echo "done."
+ ;;
+    restart)
+        echo "restarting $DESC: $NAME... "
+   $0 stop
+ $0 start
+ echo "done."
+ ;;
+    reload)
+     echo -n "reloading $DESC: $NAME... "
+     killall -HUP $(basename ${DAEMON})
+ echo "done."
+ ;;
+    *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/recipes/busybox/files/inetd.conf
b/recipes/busybox/files/inetd.conf
new file mode 100644
index 0000000..535e088
--- /dev/null
+++ b/recipes/busybox/files/inetd.conf
@@ -0,0 +1,9 @@
+# /etc/inetd.conf:  see inetd(8) for further informations.
+#
+# Internet superserver configuration database
+#
+#
+# Packages should modify this file by using update-inetd(8)
+#
+# <service_name> <sock_type> <proto> <flags> <user> <server_path>
<args>
+#
-- 
1.5.6.5

---
 recipes/busybox/busybox.inc       |    2 +-
 recipes/busybox/busybox_1.16.2.bb |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/recipes/busybox/busybox.inc b/recipes/busybox/busybox.inc
index b4663f0..f77613e 100644
--- a/recipes/busybox/busybox.inc
+++ b/recipes/busybox/busybox.inc
@@ -11,7 +11,7 @@ LICENSE = "GPLv2"
 SECTION = "base"
 PRIORITY = "required"
 
-INC_PR = "r32"
+INC_PR = "r33"
 
 SRC_URI = "\
   file://busybox-cron \
diff --git a/recipes/busybox/busybox_1.16.2.bb
b/recipes/busybox/busybox_1.16.2.bb
index 6401bfa..0e6a250 100644
--- a/recipes/busybox/busybox_1.16.2.bb
+++ b/recipes/busybox/busybox_1.16.2.bb
@@ -1,5 +1,5 @@
 require busybox.inc
-PR = "${INC_PR}.2"
+PR = "${INC_PR}.3"
 
 DEFAULT_PREFERENCE = "-1"
 DEFAULT_PREFERENCE_shr = "1"
-- 
1.5.6.5




More information about the Openembedded-devel mailing list