Hi Lamont, The attached commits apply the Ubuntu udev functionality to the Debian util-linux package, conditional on udev being running.
You can pull these directly from my stable/v2.15 branch if you like, I've merged them into ubuntu/stable/v2.15 as well to reduce the diff (though beware that I've also done a version update :p) The diff is now largely just the blkid stuff. Scott -- Scott James Remnant [email protected]
From 4bde2211c13ffe11e0ac96be3ef9676f9fd22fa5 Mon Sep 17 00:00:00 2001 From: Scott James Remnant <[email protected]> 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 92b5e11..fc22468 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 d768f90..0000000 --- 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 22c74ab..5c3d3d2 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 \ -- 1.6.0.5
From bb34cffdd4033f7226da6487f5db5c6c71b96b40 Mon Sep 17 00:00:00 2001 From: Scott James Remnant <[email protected]> Date: Tue, 14 Jul 2009 17:39:56 +0100 Subject: [PATCH] hwclock: make start a no-op when udev is running Since we set the system clock from a udev rule, we don't need to do it from an init script and we certainly don't need to do it twice! --- debian/hwclock.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/debian/hwclock.sh b/debian/hwclock.sh index 4ceb95e..80b17bc 100644 --- a/debian/hwclock.sh +++ b/debian/hwclock.sh @@ -67,6 +67,10 @@ hwclocksh() case "$1" in start) + if [ -d /dev/.udev ]; then + return 0 + fi + if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then echo "0.0 0 0.0" > /etc/adjtime fi -- 1.6.0.5
From 0419e06bbce052deb50f6fb2c769df9beeda6aa2 Mon Sep 17 00:00:00 2001 From: Scott James Remnant <[email protected]> Date: Tue, 14 Jul 2009 17:52:52 +0100 Subject: [PATCH] rules: Install udev rules into /lib/udev/rules.d Unconditionally install the udev rules, moving them on upgrade from /etc to /lib if necessary --- debian/README.Debian.hwclock | 7 +++++-- debian/rules | 5 ----- debian/util-linux.dirs | 3 +-- debian/util-linux.preinst | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 debian/util-linux.preinst diff --git a/debian/README.Debian.hwclock b/debian/README.Debian.hwclock index d3ac5ce..c8b840c 100644 --- a/debian/README.Debian.hwclock +++ b/debian/README.Debian.hwclock @@ -1,7 +1,10 @@ hwclock and Debian: -A Debian installation will, by default, call hwclock --hctosys during system -startup and hwclock --systohc during system shutdown. +When udev is running, hwclock -systz will be called when the RTC clock +device is created. When udev is not running, hwclock --hctosys will be +called during system startup. + +In both cases, hwclock --systohc will be called during system shutdown. To set the date/time of the system, just use the standard UNIX date facilities (such as date) or any of the advanced timekeeping utilities (ntp, ntpdate, diff --git a/debian/rules b/debian/rules index 5c3d3d2..5891073 100755 --- a/debian/rules +++ b/debian/rules @@ -36,9 +36,6 @@ CONFOPTS= --enable-raw --enable-rdev --enable-partx --with-slang ifeq ($(DEB_HOST_ARCH_OS),linux) CONFOPTS += --with-selinux endif -ifneq ($(DISTRO),Debian) -CONFOPTS += --with-fsprobe=volume_id -endif build: build-stamp build-stamp: @@ -110,11 +107,9 @@ endif -e '/Default-Start:/a# Default-Stop:' -e '/Default-Stop:/d' \ debian/util-linux/etc/init.d/hwclockfirst.sh; \ fi -ifneq ($(DISTRO),Debian) if [ -f debian/util-linux/sbin/hwclock ] ; then \ 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 \ ln util-linux/sbin/*fdisk fdisk-udeb/usr/sbin/; \ S=fdisk-udeb/usr/sbin/cfdisk; if [ -f $$S ]; then mv $$S cfdisk-udeb/usr/sbin/; fi; \ diff --git a/debian/util-linux.dirs b/debian/util-linux.dirs index db07a87..16ef4dd 100644 --- a/debian/util-linux.dirs +++ b/debian/util-linux.dirs @@ -2,8 +2,6 @@ bin/ sbin/ etc/ etc/init.d/ -etc/udev/ -etc/udev/rules.d/ usr/ usr/bin/ usr/sbin/ @@ -22,3 +20,4 @@ usr/share/lintian/ usr/share/lintian/overrides/ lib/ lib/udev/ +lib/udev/rules.d/ diff --git a/debian/util-linux.preinst b/debian/util-linux.preinst new file mode 100644 index 0000000..a6a6527 --- /dev/null +++ b/debian/util-linux.preinst @@ -0,0 +1,15 @@ +#! /bin/sh + +set -e + +if [ "$1" = install ] || [ "$1" = upgrade ]; then + if [ -e "/etc/udev/rules.d/85-hwclock.rules" ]; then + if [ "`md5sum \"/etc/udev/rules.d/85-hwclock.rules\" | sed -e \"s/ .*//\"`" = \ + "`dpkg-query -W -f='${Conffiles}' util-linux | sed -n -e \"\\\\' /etc/udev/rules.d/85-hwclock.rules's/.* //p\"`" ] + then + rm -f "/etc/udev/rules.d/85-hwclock.rules" + fi + fi +fi + +#DEBHELPER# -- 1.6.0.5
signature.asc
Description: This is a digitally signed message part
_______________________________________________ initscripts-ng-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/initscripts-ng-devel

