Hi, Please ignore my patch in my previous email, as it had a few mistakes in it.
The attached patch could be applied to util-linux (2.20.1-4). This patch is intended to migrate the hwclock part of util-linux to /run, as requested in bug #620787. The patch contains the following changes: - Introduced a variable, HWCLOCK_ADJFILE, that holds the name of the hwclock adjust file. HWCLOCK_ADJFILE can be overridden in "/etc/default/hwclock". - Removed the -d /etc check (the legacy dir for adjtime) - Added --adjfile switch to all invocations of "/sbin/hwclock". - Migrated "/etc/adjtime" to "/run/adjtime". - Added symbolic link from /run/adjtime to /etc/adjtime in order to insure backwards compatiblity. - Depend on initscripts (>= 2.88dsf-13.3) to guarantee the existence of "/run" and and also "/run/udev", in case udev is being used. - Removed the redundant -d /dev/.udev check, as the initscripts (>= 2.88dsf-13.3) dependency, guarantees that /dev/.udev is no more around. Regards -- Pieter
From 4c4141b9d0eecb1d7f2be633be57fb3177c505dd Mon Sep 17 00:00:00 2001 From: Pieter du Preez <pdupr...@gmail.com> Date: Tue, 6 Mar 2012 11:20:04 +0100 Subject: [PATCH] hwclock: Migrate to the /run directory. This patch is intended to migrate the hwclock part of util-linux to /run, as requested in bug #620787. The patch contains the following changes: - Introduced a variable, HWCLOCK_ADJFILE, that holds the name of the hwclock adjust file. HWCLOCK_ADJFILE can be overridden in "/etc/default/hwclock". - Removed the -d /etc check (the legacy dir for adjtime) - Added --adjfile switch to all invocations of "/sbin/hwclock". - Migrated "/etc/adjtime" to "/run/adjtime". - Added symbolic link from /run/adjtime to /etc/adjtime in order to insure backwards compatiblity. - Depend on initscripts (>= 2.88dsf-13.3) to guarantee the existence of "/run" and and also "/run/udev", in case udev is being used. - Removed the redundant -d /dev/.udev check, as the initscripts (>= 2.88dsf-13.3) dependency, guarantees that /dev/.udev is no more around. (Closes: #620787) Signed-off-by: Pieter du Preez <pdupr...@gmail.com> --- debian/README.Debian.hwclock | 3 ++- debian/changelog | 8 ++++++++ debian/control | 2 +- debian/hwclock-set | 8 ++++++-- debian/hwclock.sh | 26 +++++++++++++++----------- debian/util-linux.postinst | 9 +++++++++ debian/util-linux.postrm | 2 +- 7 files changed, 42 insertions(+), 16 deletions(-) diff --git a/debian/README.Debian.hwclock b/debian/README.Debian.hwclock index c8b840c..71b5a82 100644 --- a/debian/README.Debian.hwclock +++ b/debian/README.Debian.hwclock @@ -54,7 +54,8 @@ chrony, as well as your computer's System Setup BIOS program, and any other OS you have in your machine will change the clock. Also, if hwclock --adjust is used, one must make sure the drift file -(/etc/adjtime) is deleted every time the system clock is set to a very +(/run/adjtime, overridable with the HWCLOCK_ADJFILE variable in +/etc/run/hwclock) is deleted every time the system clock is set to a very different value (even if you're using hwclock itself to do it!), or the drift computation might become invalid and cause the hardware clock to be incorrectly set the next time hwclock --adjust is used. diff --git a/debian/changelog b/debian/changelog index 38263b6..be4eaaf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +util-linux (2.20.1-4.1) unstable; urgency=low + + * Non-maintainer upload. + * Stopped using /dev/.udev and moved /etc/adjtime + to /run/adjtime. Closes: #620787 + + -- Pieter du Preez <pdupr...@gmail.com> Tue, 06 Mar 2012 09:43:23 +0100 + util-linux (2.20.1-4) unstable; urgency=low [Michał Kułach] diff --git a/debian/control b/debian/control index e1fa45e..ce11fa3 100644 --- a/debian/control +++ b/debian/control @@ -14,7 +14,7 @@ Architecture: any Section: utils Priority: required Essential: yes -Depends: lsb-base (>= 3.0-6), tzdata (>=2006c-2), initscripts, dpkg (>= 1.15.4) | install-info, ${misc:Depends} +Depends: lsb-base (>= 3.0-6), tzdata (>=2006c-2), initscripts (>= 2.88dsf-13.3), dpkg (>= 1.15.4) | install-info, ${misc:Depends} Pre-Depends: ${shlibs:Depends} Suggests: util-linux-locales, kbd | console-tools, dosfstools Replaces: fstrim, schedutils, miscutils, setterm, fdisk, linux32, sparc-utils, e2fsprogs, ${util-linux:Conflicts} diff --git a/debian/hwclock-set b/debian/hwclock-set index 8a3ae74..f93dd19 100644 --- a/debian/hwclock-set +++ b/debian/hwclock-set @@ -4,6 +4,10 @@ dev=$1 +# Set the default adjust file name. /sbin/hwclock will be invoked +# with the --adjfile=$HWCLOCK_ADJFILE switch. +HWCLOCK_ADJFILE=/run/adjtime + if [ -e /sys/fs/cgroup/systemd ] ; then exit 0 fi @@ -17,8 +21,8 @@ fi if [ yes != "$UTC" ] ; then if [ yes = "$BADYEAR" ] ; then - /sbin/hwclock --rtc=$dev --systz --localtime --noadjfile --badyear + /sbin/hwclock --adjfile=$HWCLOCK_ADJFILE --rtc=$dev --systz --localtime --noadjfile --badyear else - /sbin/hwclock --rtc=$dev --systz --localtime --noadjfile + /sbin/hwclock --adjfile=$HWCLOCK_ADJFILE --rtc=$dev --systz --localtime --noadjfile fi fi diff --git a/debian/hwclock.sh b/debian/hwclock.sh index d542a55..eb7daa0 100644 --- a/debian/hwclock.sh +++ b/debian/hwclock.sh @@ -34,6 +34,10 @@ HWCLOCKPARS= # probably match the CONFIG_RTC_HCTOSYS_DEVICE kernel config option. HCTOSYS_DEVICE=rtc0 +# Set the default adjust file name. /sbin/hwclock will be invoked +# with the --adjfile=$HWCLOCK_ADJFILE switch. +HWCLOCK_ADJFILE=/run/adjtime + hwclocksh() { [ ! -x /sbin/hwclock ] && return 0 @@ -72,11 +76,11 @@ hwclocksh() return 0 fi - if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then - echo "0.0 0 0.0" > /etc/adjtime + if [ ! -f $HWCLOCK_ADJFILE ] && [ ! -e $HWCLOCK_ADJFILE ]; then + echo "0.0 0 0.0" 2>/dev/null > $HWCLOCK_ADJFILE || true fi - if [ ! -w /etc/adjtime ]; then + if [ ! -w $HWCLOCK_ADJFILE ]; then NOADJ="--noadjfile" else NOADJ="" @@ -89,21 +93,21 @@ hwclocksh() # # WARNING: If you uncomment this option, you must either make # sure *nothing* changes the Hardware Clock other than - # hwclock --systohc, or you must delete /etc/adjtime + # hwclock --systohc, or you must delete $HWCLOCK_ADJFILE # every time someone else modifies the Hardware Clock. # # Common "vilains" are: ntp, MS Windows, the BIOS Setup # program. # # WARNING: You must remember to invalidate (delete) - # /etc/adjtime if you ever need to set the system clock + # $HWCLOCK_ADJFILE if you ever need to set the system clock # to a very different value and hwclock --adjust is being # used. # # Please read /usr/share/doc/util-linux/README.Debian.hwclock # before enabling hwclock --adjust. - #/sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --adjust $GMT $BADYEAR + #/sbin/hwclock --adjfile=$HWCLOCK_ADJFILE --rtc=/dev/$HCTOSYS_DEVICE --adjust $GMT $BADYEAR : fi @@ -113,7 +117,7 @@ hwclocksh() # Copies Hardware Clock time to System Clock using the correct # timezone for hardware clocks in local time, and sets kernel # timezone. DO NOT REMOVE. - if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --hctosys $GMT $HWCLOCKPARS $BADYEAR $NOADJ; then + if /sbin/hwclock --adjfile=$HWCLOCK_ADJFILE --rtc=/dev/$HCTOSYS_DEVICE --hctosys $GMT $HWCLOCKPARS $BADYEAR $NOADJ; then # Announce the local time. verbose_log_action_msg "System Clock set to: `date $UTC`" else @@ -131,7 +135,7 @@ hwclocksh() # WARNING: If you disable this, any changes to the system # clock will not be carried across reboots. # - if [ ! -w /etc/adjtime ]; then + if [ ! -w $HWCLOCK_ADJFILE ]; then NOADJ="--noadjfile" else NOADJ="" @@ -142,7 +146,7 @@ hwclocksh() if [ "$GMT" = "-u" ]; then GMT="--utc" fi - if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $GMT $HWCLOCKPARS $BADYEAR $NOADJ; then + if /sbin/hwclock --adjfile=$HWCLOCK_ADJFILE --rtc=/dev/$HCTOSYS_DEVICE --systohc $GMT $HWCLOCKPARS $BADYEAR $NOADJ; then verbose_log_action_msg "Hardware Clock updated to `date`" fi else @@ -150,14 +154,14 @@ hwclocksh() fi ;; show) - if [ ! -w /etc/adjtime ]; then + if [ ! -w $HWCLOCK_ADJFILE ]; then NOADJ="--noadjfile" else NOADJ="" fi if [ "$HWCLOCKACCESS" != no ]; then - /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $GMT $HWCLOCKPARS $BADYEAR $NOADJ + /sbin/hwclock --adjfile=$HWCLOCK_ADJFILE --rtc=/dev/$HCTOSYS_DEVICE --show $GMT $HWCLOCKPARS $BADYEAR $NOADJ fi ;; *) diff --git a/debian/util-linux.postinst b/debian/util-linux.postinst index b536eac..934335f 100644 --- a/debian/util-linux.postinst +++ b/debian/util-linux.postinst @@ -22,6 +22,15 @@ fi if [ "$(uname -s)" = "Linux" ]; then model=$(uname -m) if [ ${model%x} != "s390" ]; then + # The following may be removed once "wheezy" becomes a "stable" release. + # Migrate /etc/adjtime to /run/adjtime. + if [ -L "/etc/adjtime" ]; then + : # /etc/adjtime is a symlink, so we leave it alone. + elif [ -e "/etc/adjtime" ]; then + mv -f /etc/adjtime /run/ + # Create a symlink for backwards compatibility. + ln -s /run/adjtime /etc/ + fi update-rc.d -f hwclock.sh remove 2>/dev/null > /dev/null update-rc.d hwclock.sh start 11 S . stop 25 0 6 . > /dev/null update-rc.d -f hwclockfirst.sh remove 2>/dev/null > /dev/null diff --git a/debian/util-linux.postrm b/debian/util-linux.postrm index f12aa29..827d1e8 100644 --- a/debian/util-linux.postrm +++ b/debian/util-linux.postrm @@ -6,7 +6,7 @@ case "$1" in purge) update-rc.d hwclock.sh remove >/dev/null || true update-rc.d hwclockfirst.sh remove >/dev/null || true - rm -f /etc/adjtime + rm -f /run/adjtime /etc/adjtime ;; *) ;; -- 1.7.9.1