From 4bde2211c13ffe11e0ac96be3ef9676f9fd22fa5 Mon Sep 17 00:00:00 2001 From: Scott James Remnant Date: Wed, 18 Feb 2009 14:56:02 +0000 Subject: [PATCH] hwclock: only call --systz from the udev rule Use the new --systz option in the udev rule for /dev/rtc0, stepping the clock if the hardware clock wasn't in localtime and updating the kernel timezone. Since udev can directly import /etc/default/rcS to get the UTC and BADYEAR settings, we don't need a wrapper shell script for this saving a bit of time. --- debian/hwclock.rules | 9 +++++++-- debian/hwclock.udev | 29 ----------------------------- debian/rules | 3 +-- 3 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 debian/hwclock.udev diff --git a/debian/hwclock.rules b/debian/hwclock.rules index 92b5e114..fc22468c 100644 --- a/debian/hwclock.rules +++ b/debian/hwclock.rules @@ -1,3 +1,8 @@ -# This file causes the hardware clock to be set when /dev/rtc is available. +# Reset the System Clock to UTC if the hardware clock from which it was +# copied by the kernel was in localtime. -KERNEL=="rtc", ACTION=="add", RUN+="set_hwclock" +KERNEL=="rtc0", IMPORT{file}="/etc/default/rcS" +KERNEL=="rtc0", ENV{UTC}!="yes", ENV{BADYEAR}!="yes", \ + RUN+="/sbin/hwclock --rtc=$root/$name --systz --localtime --noadjfile" +KERNEL=="rtc0", ENV{UTC}!="yes", ENV{BADYEAR}=="yes", \ + RUN+="/sbin/hwclock --rtc=$root/$name --systz --localtime --noadjfile --badyear" diff --git a/debian/hwclock.udev b/debian/hwclock.udev deleted file mode 100644 index d768f900..00000000 --- a/debian/hwclock.udev +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# udev helper for hwclock -# -# This is based on the hwclock.sh init script, but somewhat simplified. - -[ ! -x /sbin/hwclock ] && exit 0 -. /etc/default/rcS - -[ "$GMT" = "-u" ] && UTC="yes" -case "$UTC" in - no|"") GMT="--localtime" - UTC="" - ;; - yes) GMT="--utc" - UTC="--utc" - ;; - *) exit 1 ;; -esac - -case "$BADYEAR" in - no|"") BADYEAR="" ;; - yes) BADYEAR="--badyear" ;; - *) exit 1 ;; -esac - -# Copies Hardware Clock time to System Clock using the correct -# timezone for hardware clocks in local time, and sets kernel -# timezone. DO NOT REMOVE. -/sbin/hwclock --hctosys $GMT $HWCLOCKPARS $BADYEAR diff --git a/debian/rules b/debian/rules index 22c74ab7..5c3d3d29 100755 --- a/debian/rules +++ b/debian/rules @@ -112,8 +112,7 @@ endif fi ifneq ($(DISTRO),Debian) if [ -f debian/util-linux/sbin/hwclock ] ; then \ - install -m 755 debian/hwclock.udev debian/util-linux/lib/udev/set_hwclock && \ - install -m 644 debian/hwclock.rules debian/util-linux/etc/udev/rules.d/85-hwclock.rules; \ + install -m 644 debian/hwclock.rules debian/util-linux/lib/udev/rules.d/85-hwclock.rules; \ fi endif cd debian; if [ -f util-linux/sbin/fdisk ]; then \ -- 2.39.5