[oe] [PATCH 10/12] Add hwclock script to util-linux-ng
Martyn Welch
martyn.welch at ge.com
Mon Mar 22 09:35:43 UTC 2010
Busybox provides a script for managing the RTC, this is not provided by
anything else and will be required for busybox-less builds. Add it to
util-linux-ng for now.
This script is a part of busybox and is used by the boot process.
---
recipes/util-linux-ng/files/hwclock.sh | 76 +++++++++++++++++++++++++++++++
recipes/util-linux-ng/util-linux-ng.inc | 6 ++
2 files changed, 81 insertions(+), 1 deletions(-)
diff --git a/recipes/util-linux-ng/files/hwclock.sh b/recipes/util-linux-ng/files/hwclock.sh
new file mode 100644
index 0000000..6c0af34
--- /dev/null
+++ b/recipes/util-linux-ng/files/hwclock.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+# hwclock.sh Set system clock to hardware clock, according to the UTC
+# setting in /etc/default/rcS (see also rcS(5)).
+#
+# 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
+
+. /etc/default/rcS
+
+[ "$UTC" = yes ] && UTC=--utc || UTC=--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 -s $UTC;# --hctosys
+ else
+ TZ="$TZ" hwclock -s $UTC;# --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 -w $UTC;# --systohc
+ fi
+ if [ "$VERBOSE" != no ]
+ then
+ echo "Hardware Clock updated to `date`."
+ fi
+ exit 0
+ ;;
+ show)
+ if [ "$HWCLOCKACCESS" != no ]
+ then
+ hwclock -r $UTC;# --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/recipes/util-linux-ng/util-linux-ng.inc b/recipes/util-linux-ng/util-linux-ng.inc
index 1c6e8a8..b2045d7 100644
--- a/recipes/util-linux-ng/util-linux-ng.inc
+++ b/recipes/util-linux-ng/util-linux-ng.inc
@@ -12,7 +12,8 @@ INC_PR = "r16"
# allows for a release candidate
RC ?= ""
-SRC_URI = "${KERNELORG_MIRROR}/pub/linux/utils/util-linux-ng/v${PV}/util-linux-ng-${PV}${RC}.tar.bz2;name=archive"
+SRC_URI = "${KERNELORG_MIRROR}/pub/linux/utils/util-linux-ng/v${PV}/util-linux-ng-${PV}${RC}.tar.bz2;name=archive \
+ file://hwclock.sh "
SRC_URI_append_chinook-compat = " file://chinook_libtool.patch;patch=1 "
@@ -157,6 +158,9 @@ do_install () {
fi
done
+ install -d ${D}${sysconfdir}/init.d/
+ install -m 0755 ${WORKDIR}/hwclock.sh ${D}${sysconfdir}/init.d/
+
install -d ${D}${sysconfdir}/default/
echo 'MOUNTALL="-t nonfs,nosmbfs,noncpfs"' > ${D}${sysconfdir}/default/mountall.${PN}
--
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms | Wales (3828642) at 100
T +44(0)127322748 | Barbirolli Square, Manchester,
E martyn.welch at ge.com | M2 3AB VAT:GB 927559189
More information about the Openembedded-devel
mailing list