]> err.no Git - util-linux/commitdiff
hwclock: only call --systz from the udev rule
authorScott James Remnant <scott@ubuntu.com>
Wed, 18 Feb 2009 14:56:02 +0000 (14:56 +0000)
committerScott James Remnant <scott@ubuntu.com>
Tue, 14 Jul 2009 16:37:14 +0000 (17:37 +0100)
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
debian/hwclock.udev [deleted file]
debian/rules

index 92b5e114262270f669e9885bf3220162b0c80bab..fc22468ce7bbe01c4eafb8836e3fe04f1d5746c3 100644 (file)
@@ -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 (file)
index d768f90..0000000
+++ /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
index 22c74ab7b9f03669a5f08b525c5bfbc897c14794..5c3d3d29527b8af6d386b7dd3fd28a908bbc4711 100755 (executable)
@@ -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 \