busybox: Install scripts only when needed
PATCH v5 1/3 busybox: Install scripts only when needed
Init scripts are only usefull with init system that supports them, it means that we don't want init scripts files unless Busybox or SysV has been chosen as the init.
---
v1 -> v2:
- Remove non needed space in ifeq (Thomas Petazzoni)
--- package/busybox/busybox.mk | 7 +++++++ 1 file changed, 7 insertions(+)
package/busybox/busybox.mk +7 -0
@@ -141,17 +141,23 @@ define BUSYBOX_SET_INIT endef endif +ifeq ($(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),y) define BUSYBOX_INSTALL_LOGGING_SCRIPT if grep -q CONFIG_SYSLOGD=y $(@D)/.config; then \ $(INSTALL) -m 0755 -D package/busybox/S01logging \ $(TARGET_DIR)/etc/init.d/S01logging; \ else rm -f $(TARGET_DIR)/etc/init.d/S01logging; fi endef +endif ifeq ($(BR2_PACKAGE_BUSYBOX_WATCHDOG),y) define BUSYBOX_SET_WATCHDOG $(call KCONFIG_ENABLE_OPT,CONFIG_WATCHDOG,$(BUSYBOX_BUILD_CONFIG)) endef +endif + +ifeq ($(BR2_PACKAGE_BUSYBOX_WATCHDOG),y) +ifeq ($(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),y) define BUSYBOX_INSTALL_WATCHDOG_SCRIPT $(INSTALL) -D -m 0755 package/busybox/S15watchdog \ $(TARGET_DIR)/etc/init.d/S15watchdog
@@ -167,6 +173,7 @@ define BUSYBOX_LINUX_PAM endef BUSYBOX_DEPENDENCIES += linux-pam endif +endif # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links.
Signature · 1 line
2.1.4
PATCH v5 2/3 initscripts: new package
The folder init.d is currently installed by default since it's part of our skeleton.
This patch creates a package out of it and make busybox/sysvinit depends on it.
This way, if you chose another init, you don't end up with a useless init.d folder.
---
v4 -> v5:
- Move inittab to their specifi packages (sysvinit and busybox)
- Make BR2_INIT_SYSV and BR2_INIT_BUSYBOX select initscripts
- Initscripts depends on BR2_INIT_SYSV or BR2_INIT_BUSYBOX so it can't be selected by anything else.
v3 -> v4:
- Fix bug with busybox
v2 -> v3:
- Fix rebase issues
v1 -> v2:
- Redo the patch using git format-patch -M
--- package/Config.in | 1 + package/busybox/busybox.mk | 7 +++++ package/busybox/inittab | 35 ++++++++++++++++++++++++ package/initscripts/Config.in | 5 ++++ package/initscripts/init.d/S20urandom | 51 +++++++++++++++++++++++++++++++++++ package/initscripts/init.d/S40network | 28 +++++++++++++++++++ package/initscripts/init.d/rcK | 27 +++++++++++++++++++ package/initscripts/init.d/rcS | 27 +++++++++++++++++++ package/initscripts/initscripts.mk | 15 +++++++++++ package/sysvinit/sysvinit.mk | 6 ++--- system/Config.in | 2 ++ system/skeleton/etc/init.d/S20urandom | 51 ----------------------------------- system/skeleton/etc/init.d/S40network | 28 ------------------- system/skeleton/etc/init.d/rcK | 27 ------------------- system/skeleton/etc/init.d/rcS | 27 ------------------- system/skeleton/etc/inittab | 35 ------------------------ 16 files changed, 200 insertions(+), 172 deletions(-) create mode 100644 package/busybox/inittab create mode 100644 package/initscripts/Config.in create mode 100755 package/initscripts/init.d/S20urandom create mode 100755 package/initscripts/init.d/S40network create mode 100755 package/initscripts/init.d/rcK create mode 100755 package/initscripts/init.d/rcS create mode 100644 package/initscripts/initscripts.mk delete mode 100755 system/skeleton/etc/init.d/S20urandom delete mode 100755 system/skeleton/etc/init.d/S40network delete mode 100755 system/skeleton/etc/init.d/rcK delete mode 100755 system/skeleton/etc/init.d/rcS delete mode 100644 system/skeleton/etc/inittab
package/Config.in +1 -0
@@ -1408,6 +1408,7 @@ endif source "package/ftop/Config.in" source "package/getent/Config.in" source "package/htop/Config.in" + source "package/initscripts/Config.in" source "package/iotop/Config.in" source "package/iprutils/Config.in" source "package/irqbalance/Config.in"
package/busybox/busybox.mk +7 -0
@@ -150,6 +150,12 @@ define BUSYBOX_INSTALL_LOGGING_SCRIPT endef endif +ifeq ($(BR2_INIT_BUSYBOX),y) +define BUSYBOX_INSTALL_INITTAB + $(INSTALL) -D -m 0644 package/busybox/inittab $(TARGET_DIR)/etc/inittab +endef +endif + ifeq ($(BR2_PACKAGE_BUSYBOX_WATCHDOG),y) define BUSYBOX_SET_WATCHDOG $(call KCONFIG_ENABLE_OPT,CONFIG_WATCHDOG,$(BUSYBOX_BUILD_CONFIG))
@@ -204,6 +210,7 @@ endef define BUSYBOX_INSTALL_TARGET_CMDS $(BUSYBOX_MAKE_ENV) $(MAKE) $(BUSYBOX_MAKE_OPTS) -C $(@D) install + $(BUSYBOX_INSTALL_INITTAB) $(BUSYBOX_INSTALL_UDHCPC_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) endef
package/busybox/inittab new file +35 -0
@@ -0,0 +1,35 @@ +# /etc/inittab +# +# Copyright (C) 2001 Erik Andersen <[email protected]> +# +# Note: BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use +# sysvinit. +# +# Format for each entry: <id>:<runlevels>:<action>:<process> +# +# id == tty to run on, or empty for /dev/console +# runlevels == ignored +# action == one of sysinit, respawn, askfirst, wait, and once +# process == program to run + +# Startup the system +null::sysinit:/bin/mount -t proc proc /proc +null::sysinit:/bin/mount -o remount,rw / +null::sysinit:/bin/mkdir -p /dev/pts +null::sysinit:/bin/mkdir -p /dev/shm +null::sysinit:/bin/mount -a +null::sysinit:/bin/hostname -F /etc/hostname +# now run any rc scripts +::sysinit:/etc/init.d/rcS + +# Put a getty on the serial port +#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL + +# Stuff to do for the 3-finger salute +::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/etc/init.d/rcK +::shutdown:/sbin/swapoff -a +::shutdown:/bin/umount -a -r
package/initscripts/Config.in new file +5 -0
@@ -0,0 +1,5 @@ +config BR2_PACKAGE_INITSCRIPTS + bool "initscripts" + depends on BR2_INIT_BUSYBOX || BR2_INIT_SYSV + help + The basics startup scripts for both SysV and Busybox
package/initscripts/init.d/S20urandom new file +51 -0
51 lines not on this page · raw message
package/initscripts/init.d/S40network new file +28 -0
@@ -0,0 +1,28 @@ +#!/bin/sh +# +# Start the network.... +# + +# Debian ifupdown needs the /run/network lock directory +mkdir -p /run/network + +case "$1" in + start) + echo "Starting network..." + /sbin/ifup -a + ;; + stop) + echo -n "Stopping network..." + /sbin/ifdown -a + ;; + restart|reload) + "$0" stop + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? +
package/initscripts/init.d/rcK new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh + + +# Stop all init scripts in /etc/init.d +# executing them in reversed numerical order. +# +for i in $(ls -r /etc/init.d/S??*) ;do + + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set stop + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i stop + ;; + esac +done +
package/initscripts/init.d/rcS new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh + + +# Start all init scripts in /etc/init.d +# executing them in numerical order. +# +for i in /etc/init.d/S??* ;do + + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set start + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i start + ;; + esac +done +
package/initscripts/initscripts.mk new file +15 -0
@@ -0,0 +1,15 @@ +################################################################################ +# +# initscripts +# +################################################################################ + +# source included in buildroot +INITSCRIPTS_SOURCE = + +define INITSCRIPTS_INSTALL_TARGET_CMDS + mkdir -p $(TARGET_DIR)/etc/init.d + $(INSTALL) -D -m 0755 package/initscripts/init.d/* $(TARGET_DIR)/etc/init.d/ +endef + +$(eval $(generic-package))
package/sysvinit/sysvinit.mk +2 -4
@@ -11,9 +11,9 @@ SYSVINIT_SITE = http://snapshot.debian.org/archive/debian/20141023T043132Z/pool/ SYSVINIT_LICENSE = GPLv2+ SYSVINIT_LICENSE_FILES = COPYING -# Override BusyBox implementations if BusyBox is enabled. +# Override Busybox implementations if Busybox is enabled. ifeq ($(BR2_PACKAGE_BUSYBOX),y) -SYSVINIT_DEPENDENCIES = busybox +SYSVINIT_DEPENDENCIES += busybox endif define SYSVINIT_DEBIAN_PATCHES
@@ -34,8 +34,6 @@ define SYSVINIT_INSTALL_TARGET_CMDS for x in halt init shutdown killall5; do \ $(INSTALL) -D -m 0755 $(@D)/src/$$x $(TARGET_DIR)/sbin/$$x || exit 1; \ done - # Override BusyBox's inittab with an inittab compatible with - # sysvinit $(INSTALL) -D -m 0644 package/sysvinit/inittab $(TARGET_DIR)/etc/inittab ln -sf /sbin/halt $(TARGET_DIR)/sbin/reboot ln -sf /sbin/halt $(TARGET_DIR)/sbin/poweroff
system/Config.in +2 -0
@@ -70,10 +70,12 @@ choice config BR2_INIT_BUSYBOX bool "BusyBox" select BR2_PACKAGE_BUSYBOX + select BR2_PACKAGE_INITSCRIPTS config BR2_INIT_SYSV bool "systemV" select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # sysvinit + select BR2_PACKAGE_INITSCRIPTS select BR2_PACKAGE_SYSVINIT config BR2_INIT_SYSTEMD
system/skeleton/etc/init.d/S20urandom deleted +0 -51
51 lines not on this page · raw message
system/skeleton/etc/init.d/S40network deleted +0 -28
@@ -1,28 +0,0 @@ -#!/bin/sh -# -# Start the network.... -# - -# Debian ifupdown needs the /run/network lock directory -mkdir -p /run/network - -case "$1" in - start) - echo "Starting network..." - /sbin/ifup -a - ;; - stop) - echo -n "Stopping network..." - /sbin/ifdown -a - ;; - restart|reload) - "$0" stop - "$0" start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 -esac - -exit $? -
system/skeleton/etc/init.d/rcK deleted +0 -27
@@ -1,27 +0,0 @@ -#!/bin/sh - - -# Stop all init scripts in /etc/init.d -# executing them in reversed numerical order. -# -for i in $(ls -r /etc/init.d/S??*) ;do - - # Ignore dangling symlinks (if any). - [ ! -f "$i" ] && continue - - case "$i" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - set stop - . $i - ) - ;; - *) - # No sh extension, so fork subprocess. - $i stop - ;; - esac -done -
system/skeleton/etc/init.d/rcS deleted +0 -27
@@ -1,27 +0,0 @@ -#!/bin/sh - - -# Start all init scripts in /etc/init.d -# executing them in numerical order. -# -for i in /etc/init.d/S??* ;do - - # Ignore dangling symlinks (if any). - [ ! -f "$i" ] && continue - - case "$i" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - set start - . $i - ) - ;; - *) - # No sh extension, so fork subprocess. - $i start - ;; - esac -done -
system/skeleton/etc/inittab deleted +0 -35
@@ -1,35 +0,0 @@ -# /etc/inittab -# -# Copyright (C) 2001 Erik Andersen <[email protected]> -# -# Note: BusyBox init doesn't support runlevels. The runlevels field is -# completely ignored by BusyBox init. If you want runlevels, use -# sysvinit. -# -# Format for each entry: <id>:<runlevels>:<action>:<process> -# -# id == tty to run on, or empty for /dev/console -# runlevels == ignored -# action == one of sysinit, respawn, askfirst, wait, and once -# process == program to run - -# Startup the system -null::sysinit:/bin/mount -t proc proc /proc -null::sysinit:/bin/mount -o remount,rw / -null::sysinit:/bin/mkdir -p /dev/pts -null::sysinit:/bin/mkdir -p /dev/shm -null::sysinit:/bin/mount -a -null::sysinit:/bin/hostname -F /etc/hostname -# now run any rc scripts -::sysinit:/etc/init.d/rcS - -# Put a getty on the serial port -#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL - -# Stuff to do for the 3-finger salute -::ctrlaltdel:/sbin/reboot - -# Stuff to do before rebooting -::shutdown:/etc/init.d/rcK -::shutdown:/sbin/swapoff -a -::shutdown:/bin/umount -a -r
Signature · 1 line
2.1.4
PATCH v5 3/3 package: busybox: Collocate ntp startup script
In reply to Maxime HadjinlianInstead of having an NTP startup scripts for NTPD, Busybox's NTPD, OpenNTPD, have only one available in Busybox and make the rest symlink to it.
The configuration file is also common.
--- package/busybox/S49ntp | 29 +++++++++++++++++++++++++++++ package/busybox/busybox.mk | 11 +++++++++++ package/busybox/ntp.conf | 4 ++++ package/ntp/S49ntp | 39 +-------------------------------------- package/ntp/ntp.conf | 1 + package/ntp/ntp.mk | 2 +- package/ntp/ntpd.etc.conf | 8 -------- package/openntpd/S49ntp | 26 +------------------------- 8 files changed, 48 insertions(+), 72 deletions(-) create mode 100644 package/busybox/S49ntp create mode 100644 package/busybox/ntp.conf mode change 100755 => 120000 package/ntp/S49ntp create mode 120000 package/ntp/ntp.conf delete mode 100644 package/ntp/ntpd.etc.conf mode change 100755 => 120000 package/openntpd/S49ntp
package/busybox/S49ntp new file +29 -0
@@ -0,0 +1,29 @@ +#! /bin/sh + +NAME=ntpd + +[ -x /usr/sbin/${NAME} ] || exit 0 +[ -f /etc/${NAME}.conf ] || exit 0 + +case "$1" in + start) + echo -n "Starting ${NAME}: " + start-stop-daemon -S -x /usr/sbin/${NAME} -- -p /run/${NAME}.pid + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + stop) + echo -n "Stopping ${NAME}: " + start-stop-daemon -K -q -p /run/${NAME}.pid + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + restart) + "$0" stop + sleep 1 + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + ;; +esac + +exit 0
package/busybox/busybox.mk +11 -0
@@ -135,6 +135,17 @@ define BUSYBOX_INSTALL_UDHCPC_SCRIPT fi endef +define BUSYBOX_INSTALL_NTPD_SCRIPT + if grep -q CONFIG_NTPD=y $(@D)/.config; then \ + $(INSTALL) -m 0755 -D package/busybox/S49ntp \ + $(TARGET_DIR)/etc/init.d/S49ntp; \ + fi + if grep -q CONFIG_FEATURE_NTPD_CONF=y $(@D)/.config; then \ + $(INSTALL) -m 0644 -D package/busybox/ntp.conf \ + $(TARGET_DIR)/etc/ntp.conf; \ + fi +endef + ifeq ($(BR2_INIT_BUSYBOX),y) define BUSYBOX_SET_INIT $(call KCONFIG_ENABLE_OPT,CONFIG_INIT,$(BUSYBOX_BUILD_CONFIG))
package/busybox/ntp.conf new file +4 -0
@@ -0,0 +1,4 @@ +server 0.pool.ntp.org +server 1.pool.ntp.org +server 3.pool.ntp.org +server 4.pool.ntp.org
package/ntp/S49ntp deleted +0 -38
@@ -1,38 +0,0 @@ -#! /bin/sh - -NAME=ntpd -DAEMON=/usr/sbin/$NAME - -# Gracefully exit if the package has been removed. -test -x $DAEMON || exit 0 - -# Read config file if it is present. -if [ -r /etc/default/$NAME ] -then - . /etc/default/$NAME -fi - -case "$1" in - start) - echo -n "Starting $NAME: " - start-stop-daemon -S -q -x $DAEMON -- -g - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - stop) - echo -n "Stopping $NAME: " - start-stop-daemon -K -q -n $NAME - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - restart|reload) - echo "Restarting $NAME: " - $0 stop - sleep 1 - $0 start - ;; - *) - echo "Usage: $0 {start|stop|restart|reload}" >&2 - exit 1 - ;; -esac - -exit 0
package/ntp/S49ntp new file +1 -0
@@ -0,0 +1 @@ +../busybox/S49ntp
package/ntp/ntp.conf new file +1 -0
@@ -0,0 +1 @@ +../busybox/ntp.conf
package/ntp/ntp.mk +1 -1
@@ -53,7 +53,7 @@ NTP_INSTALL_FILES_$(BR2_PACKAGE_NTP_TICKADJ) += util/tickadj define NTP_INSTALL_TARGET_CMDS $(if $(BR2_PACKAGE_NTP_NTPD), install -m 755 $(@D)/ntpd/ntpd $(TARGET_DIR)/usr/sbin/ntpd) test -z "$(NTP_INSTALL_FILES_y)" || install -m 755 $(addprefix $(@D)/,$(NTP_INSTALL_FILES_y)) $(TARGET_DIR)/usr/bin/ - $(INSTALL) -m 644 package/ntp/ntpd.etc.conf $(TARGET_DIR)/etc/ntp.conf + $(INSTALL) -m 644 package/ntp/ntp.conf $(TARGET_DIR)/etc/ntp.conf endef ifeq ($(BR2_PACKAGE_NTP_NTPD),y)
package/ntp/ntpd.etc.conf deleted +0 -8
@@ -1,8 +0,0 @@ -server 0.pool.ntp.org iburst -server 1.pool.ntp.org iburst - -# Allow only time queries, at a limited rate, sending KoD when in excess. -# Allow all local queries (IPv4, IPv6) -restrict default nomodify nopeer noquery limited kod -restrict 127.0.0.1 -restrict [::1]
package/openntpd/S49ntp deleted +0 -25
@@ -1,25 +0,0 @@ -#!/bin/sh - -[ -x /usr/sbin/ntpd ] || exit 0 -[ -f /etc/ntpd.conf ] || exit 0 - -case "$1" in - start) - echo -n "Starting openntpd: " - start-stop-daemon -S -x /usr/sbin/ntpd -- -p /run/ntpd.pid - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - stop) - echo -n "Stopping openntpd: " - start-stop-daemon -K -q -p /run/ntpd.pid - [ $? = 0 ] && echo "OK" || echo "FAIL" - ;; - restart) - "$0" stop - sleep 1 - "$0" start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - ;; -esac
package/openntpd/S49ntp new file +1 -0
@@ -0,0 +1 @@ +../busybox/S49ntp
Signature · 1 line
2.1.4
PATCH v5 1/3 busybox: Install scripts only when needed
In reply to Maxime HadjinlianDear Maxime Hadjinlian,
Quoted 5 lines · Maxime Hadjinlian
Init scripts are only usefull with init system that supports them, it means that we don't want init scripts files unless Busybox or SysV has been chosen as the init.
Signed-off-by Maxime Hadjinlian <[email protected]>
Completely unneeded: those macros are already called by BUSYBOX_INSTALL_INIT_SYSV, which guarantees it is only executed when Busybox init or SystemV init are used.
I'll mark the patch as Rejected in patchwork.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com