[OE-core] [PATCH v2 1/1] recipes-core: breakout hwclock.sh from busybox
Alex Stewart
alex.stewart at ni.com
Mon Apr 9 19:57:06 UTC 2018
Bump.
Did this patch get blacklisted for inclusion or does anyone have any
outstanding concerns about it?
On 03/21/2018 01:55 PM, Alex Stewart wrote:
> * Move the hwclock.sh initscript from busybox into its own package and
> recipe (hwclock-init). This script is generally useful for distros
> that get their hwclock implementation from sources other than
> busybox (like util-linux).
>
> :busybox/*
> * Remove the busybox-hwclock package, as it no longer has a purpose.
> * If busybox is configured to include hwclock, the busybox package will
> RDEPEND on hwclock-init.
>
> :util-linux/*
> * util-linux-hwclock RDEPENDS on hwclock-init for its initscript.
>
> Signed-off-by: Alex Stewart <alex.stewart at ni.com>
> ---
> meta/recipes-core/busybox/busybox.inc | 16 +++--
> meta/recipes-core/busybox/busybox_1.27.2.bb | 1 -
> meta/recipes-core/busybox/files/hwclock.sh | 83 ----------------------
> meta/recipes-core/hwclock-init/files/hwclock.sh | 83 ++++++++++++++++++++++
> meta/recipes-core/hwclock-init/hwclock-init_1.0.bb | 31 ++++++++
> meta/recipes-core/util-linux/util-linux.inc | 1 +
> 6 files changed, 124 insertions(+), 91 deletions(-)
> delete mode 100644 meta/recipes-core/busybox/files/hwclock.sh
> create mode 100644 meta/recipes-core/hwclock-init/files/hwclock.sh
> create mode 100644 meta/recipes-core/hwclock-init/hwclock-init_1.0.bb
>
> diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
> index d1675c37aa..50cc837335 100644
> --- a/meta/recipes-core/busybox/busybox.inc
> +++ b/meta/recipes-core/busybox/busybox.inc
> @@ -20,19 +20,17 @@ export EXTRA_LDFLAGS = "${LDFLAGS}"
>
> 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"
> +PACKAGES =+ "${PN}-httpd ${PN}-udhcpd ${PN}-udhcpc ${PN}-syslog ${PN}-mdev"
>
> FILES_${PN}-httpd = "${sysconfdir}/init.d/busybox-httpd /srv/www"
> FILES_${PN}-syslog = "${sysconfdir}/init.d/syslog* ${sysconfdir}/syslog-startup.conf* ${sysconfdir}/syslog.conf* ${systemd_unitdir}/system/syslog.service ${sysconfdir}/default/busybox-syslog"
> FILES_${PN}-mdev = "${sysconfdir}/init.d/mdev ${sysconfdir}/mdev.conf ${sysconfdir}/mdev/*"
> FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd"
> FILES_${PN}-udhcpc = "${sysconfdir}/udhcpc.d ${datadir}/udhcpc"
> -FILES_${PN}-hwclock = "${sysconfdir}/init.d/hwclock.sh"
>
> -INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd ${PN}-mdev ${PN}-hwclock"
> +INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd ${PN}-mdev"
>
> INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd"
> -INITSCRIPT_NAME_${PN}-hwclock = "hwclock.sh"
> INITSCRIPT_NAME_${PN}-mdev = "mdev"
> INITSCRIPT_PARAMS_${PN}-mdev = "start 04 S ."
> INITSCRIPT_NAME_${PN}-syslog = "syslog"
> @@ -284,9 +282,6 @@ do_install () {
> 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
> @@ -375,6 +370,13 @@ python do_package_prepend () {
> else:
> set_alternative_vars("${sysconfdir}/busybox.links.nosuid", "${base_bindir}/busybox.nosuid")
> set_alternative_vars("${sysconfdir}/busybox.links.suid", "${base_bindir}/busybox.suid")
> +
> + # If busybox is configured to provide a hwclock implementation, add a
> + # package dependency on hwclock-init for the /etc/init.d/hwclock.sh
> + # initscript.
> + with open(d.getVar('B') + '/.config', 'r') as fp_conf:
> + if 'CONFIG_HWCLOCK=y' in fp_conf.read():
> + d.appendVar('RDEPENDS_busybox', ' hwclock-init ')
> }
>
> pkg_postinst_${PN} () {
> diff --git a/meta/recipes-core/busybox/busybox_1.27.2.bb b/meta/recipes-core/busybox/busybox_1.27.2.bb
> index 36a6342aaf..78d8e14a6b 100644
> --- a/meta/recipes-core/busybox/busybox_1.27.2.bb
> +++ b/meta/recipes-core/busybox/busybox_1.27.2.bb
> @@ -8,7 +8,6 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
> file://busybox-udhcpd \
> file://default.script \
> file://simple.script \
> - file://hwclock.sh \
> file://mount.busybox \
> file://syslog \
> file://syslog-startup.conf \
> diff --git a/meta/recipes-core/busybox/files/hwclock.sh b/meta/recipes-core/busybox/files/hwclock.sh
> deleted file mode 100644
> index be5f94d86c..0000000000
> --- a/meta/recipes-core/busybox/files/hwclock.sh
> +++ /dev/null
> @@ -1,83 +0,0 @@
> -#!/bin/sh
> -### BEGIN INIT INFO
> -# Provides: hwclock
> -# Required-Start:
> -# Required-Stop: $local_fs
> -# Default-Start: S
> -# Default-Stop: 0 6
> -# Short-Description: Set system clock
> -# Description: Set system clock to hardware clock, according to the UTC
> -# setting in /etc/default/rcS (see also rcS(5)).
> -### END INIT INFO
> -#
> -# WARNING: If your hardware clock is not in UTC/GMT, this script
> -# must know the local time zone. This information is
> -# stored in /etc/localtime. This might be a problem if
> -# your /etc/localtime is a symlink to something in
> -# /usr/share/zoneinfo AND /usr isn't in the root
> -# partition! The workaround is to define TZ either
> -# in /etc/default/rcS, or in the proper place below.
> -
> -[ ! -x /sbin/hwclock ] && exit 0
> -
> -[ -f /etc/default/rcS ] && . /etc/default/rcS
> -
> -[ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
> -case "$1" in
> - start)
> - if [ "$VERBOSE" != no ]
> - then
> - echo "System time was `date`."
> - echo "Setting the System Clock using the Hardware Clock as reference..."
> - fi
> -
> - if [ "$HWCLOCKACCESS" != no ]
> - then
> - if [ -z "$TZ" ]
> - then
> - hwclock $tz --hctosys
> - else
> - TZ="$TZ" hwclock $tz --hctosys
> - fi
> - fi
> -
> - if [ "$VERBOSE" != no ]
> - then
> - echo "System Clock set. System local time is now `date`."
> - fi
> - ;;
> - stop|restart|reload|force-reload)
> - #
> - # Updates the Hardware Clock with the System Clock time.
> - # This will *override* any changes made to the Hardware Clock.
> - #
> - # WARNING: If you disable this, any changes to the system
> - # clock will not be carried across reboots.
> - #
> - if [ "$VERBOSE" != no ]
> - then
> - echo "Saving the System Clock time to the Hardware Clock..."
> - fi
> - if [ "$HWCLOCKACCESS" != no ]
> - then
> - hwclock $tz --systohc
> - fi
> - if [ "$VERBOSE" != no ]
> - then
> - echo "Hardware Clock updated to `date`."
> - fi
> - exit 0
> - ;;
> - show)
> - if [ "$HWCLOCKACCESS" != no ]
> - then
> - hwclock $tz --show
> - fi
> - ;;
> - *)
> - echo "Usage: hwclock.sh {start|stop|show|reload|restart}" >&2
> - echo " start sets kernel (system) clock from hardware (RTC) clock" >&2
> - echo " stop and reload set hardware (RTC) clock from kernel (system) clock" >&2
> - exit 1
> - ;;
> -esac
> diff --git a/meta/recipes-core/hwclock-init/files/hwclock.sh b/meta/recipes-core/hwclock-init/files/hwclock.sh
> new file mode 100644
> index 0000000000..be5f94d86c
> --- /dev/null
> +++ b/meta/recipes-core/hwclock-init/files/hwclock.sh
> @@ -0,0 +1,83 @@
> +#!/bin/sh
> +### BEGIN INIT INFO
> +# Provides: hwclock
> +# Required-Start:
> +# Required-Stop: $local_fs
> +# Default-Start: S
> +# Default-Stop: 0 6
> +# Short-Description: Set system clock
> +# Description: Set system clock to hardware clock, according to the UTC
> +# setting in /etc/default/rcS (see also rcS(5)).
> +### END INIT INFO
> +#
> +# WARNING: If your hardware clock is not in UTC/GMT, this script
> +# must know the local time zone. This information is
> +# stored in /etc/localtime. This might be a problem if
> +# your /etc/localtime is a symlink to something in
> +# /usr/share/zoneinfo AND /usr isn't in the root
> +# partition! The workaround is to define TZ either
> +# in /etc/default/rcS, or in the proper place below.
> +
> +[ ! -x /sbin/hwclock ] && exit 0
> +
> +[ -f /etc/default/rcS ] && . /etc/default/rcS
> +
> +[ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
> +case "$1" in
> + start)
> + if [ "$VERBOSE" != no ]
> + then
> + echo "System time was `date`."
> + echo "Setting the System Clock using the Hardware Clock as reference..."
> + fi
> +
> + if [ "$HWCLOCKACCESS" != no ]
> + then
> + if [ -z "$TZ" ]
> + then
> + hwclock $tz --hctosys
> + else
> + TZ="$TZ" hwclock $tz --hctosys
> + fi
> + fi
> +
> + if [ "$VERBOSE" != no ]
> + then
> + echo "System Clock set. System local time is now `date`."
> + fi
> + ;;
> + stop|restart|reload|force-reload)
> + #
> + # Updates the Hardware Clock with the System Clock time.
> + # This will *override* any changes made to the Hardware Clock.
> + #
> + # WARNING: If you disable this, any changes to the system
> + # clock will not be carried across reboots.
> + #
> + if [ "$VERBOSE" != no ]
> + then
> + echo "Saving the System Clock time to the Hardware Clock..."
> + fi
> + if [ "$HWCLOCKACCESS" != no ]
> + then
> + hwclock $tz --systohc
> + fi
> + if [ "$VERBOSE" != no ]
> + then
> + echo "Hardware Clock updated to `date`."
> + fi
> + exit 0
> + ;;
> + show)
> + if [ "$HWCLOCKACCESS" != no ]
> + then
> + hwclock $tz --show
> + fi
> + ;;
> + *)
> + echo "Usage: hwclock.sh {start|stop|show|reload|restart}" >&2
> + echo " start sets kernel (system) clock from hardware (RTC) clock" >&2
> + echo " stop and reload set hardware (RTC) clock from kernel (system) clock" >&2
> + exit 1
> + ;;
> +esac
> diff --git a/meta/recipes-core/hwclock-init/hwclock-init_1.0.bb b/meta/recipes-core/hwclock-init/hwclock-init_1.0.bb
> new file mode 100644
> index 0000000000..74200450ac
> --- /dev/null
> +++ b/meta/recipes-core/hwclock-init/hwclock-init_1.0.bb
> @@ -0,0 +1,31 @@
> +SUMMARY = "Initscript for hwclock utility"
> +DESCRIPTION = "\
> +Installs an initscript that updates the system clock based on the available \
> +hwclock implementation."
> +
> +SECTION = "base"
> +
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
> +
> +SRC_URI = "file://hwclock.sh"
> +
> +S = "${WORKDIR}"
> +
> +inherit update-rc.d
> +
> +INITSCRIPT_PACKAGES = "${PN}"
> +
> +INITSCRIPT_NAME_${PN} = "hwclock.sh"
> +INITSCRIPT_PARAMS_${PN} = "defaults"
> +
> +do_install () {
> + install -d ${D}${sysconfdir}/init.d
> + install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
> +}
> +
> +PACKAGES = "${PN}"
> +
> +PACKAGE_ARCH = "all"
> +
> +FILES_${PN} = "${sysconfdir}/init.d/hwclock.sh"
> diff --git a/meta/recipes-core/util-linux/util-linux.inc b/meta/recipes-core/util-linux/util-linux.inc
> index 5e40b2019a..6df5723d5e 100644
> --- a/meta/recipes-core/util-linux/util-linux.inc
> +++ b/meta/recipes-core/util-linux/util-linux.inc
> @@ -302,6 +302,7 @@ python populate_packages_prepend() {
> }
>
> RDEPENDS_${PN}-bash-completion += "util-linux-lsblk"
> +RDEPENDS_${PN}-hwclock += "hwclock-init"
> RDEPENDS_${PN}-ptest = "bash grep coreutils which util-linux-blkid util-linux-fsck btrfs-tools"
>
> do_compile_ptest() {
--
Alex Stewart
Software Engineer - LabVIEW Real-Time
National Instruments
alex.stewart at ni.com
More information about the Openembedded-core
mailing list