On Sat, Feb 18, 2012 at 05:41:45PM +0000, Roger Leigh wrote: > On Sat, Feb 18, 2012 at 05:15:04PM +0000, Debian Bug Tracking System wrote: > > I've attached a further minor addition (again against current git) > which obsoletes UTC= in /etc/default/rcS after we've migrated to > /etc/adjtime. Since we're the only user of this value, it's most > appropriate for this to be done in util-linux rather than initscripts, > since I won't know in initscripts when the migration has happened.
I have attached an updated patch against current util-linux in unstable. Using this patch, I have tested as detailed below. The short form is that all tests worked correctly, and I see no regressions as a result of this change, at least for the hardware I have tested on. If anything, it's now much more reliable--you can freely run hwclock --utc|--localtime and edit the config and it all behaves as documented; since we no longer override the configured setting in the initscripts, it's basically impossible to screw up the clock. Regards, Roger TZ HWCLOCK UDEV RESULT ---- ------- ---- ------- UTC UTC YES CORRECT BST UTC YES CORRECT PDT UTC YES CORRECT EEST UTC YES CORRECT UTC LOCAL YES CORRECT BST LOCAL YES CORRECT PDT LOCAL YES CORRECT EEST LOCAL YES CORRECT UTC UTC NO CORRECT BST UTC NO CORRECT PDT UTC NO CORRECT EEST UTC NO CORRECT UTC LOCAL NO CORRECT BST LOCAL NO CORRECT PDT LOCAL NO CORRECT EEST LOCAL NO CORRECT Wall clock time is in UTC. hwclock UTC time is correct with using a UTC hardware clock, and LOCAL time is correct when using a local time hardware clock. Testing protocol: 1) Timezone was set with sudo dpkg-reconfigure tzdata Timezones tested: Etc/UTC (UTC) Europe/London (BST) US/Pacific (PDT) Asia/Damascus (EEST) This tests positive and negative offsets from UTC as well as daylight savings time. 2) The hardware clock was set with hwclock --systohc with --utc or --localtime to set UTC or LOCAL in /etc/adjtime. 3) The machine was rebooted. 4) The attached script, tzshow, was run to print the configurations as shown below. The wall clock time was manually entered from a real clock. This was repeated for all combinations of timezone and UTC and LOCAL time. To test without udev, the following was done: rm /lib/udev/hwclock-set /lib/udev/rules.d/85-hwclock.rules sudo update-initramfs -k all -c udev checks were removed from /etc/init.d/hwclock WALL CLOCK: 15:50 SYSTEM TIMEZONE: Etc/UTC -------------------------------------------------------- ADJTIME: 0.016599 1333727342 0.000000 1333727342 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 15:50:49 UTC -0.906760 seconds LOCAL Fri 06 Apr 2012 15:50:50 UTC -0.989222 seconds -------------------------------------------------------- DATE: Fri Apr 6 08:50:50 PDT 2012 Fri Apr 6 15:50:50 UTC 2012 Fri Apr 6 16:50:50 BST 2012 Fri Apr 6 18:50:50 EEST 2012 -------------------------------------------------------- WALL CLOCK: 15:53 SYSTEM TIMEZONE: Europe/London -------------------------------------------------------- ADJTIME: 0.016599 1333727520 0.000000 1333727520 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 16:53:32 BST -0.438081 seconds LOCAL Fri 06 Apr 2012 15:53:33 BST -0.969332 seconds -------------------------------------------------------- DATE: Fri Apr 6 08:53:32 PDT 2012 Fri Apr 6 15:53:32 UTC 2012 Fri Apr 6 16:53:32 BST 2012 Fri Apr 6 18:53:32 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:02 SYSTEM TIMEZONE: US/Pacific -------------------------------------------------------- ADJTIME: 0.016599 1333727943 0.000000 1333727943 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 09:02:21 PDT -0.766192 seconds LOCAL Fri 06 Apr 2012 16:02:22 PDT -1.000568 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:02:21 PDT 2012 Fri Apr 6 16:02:21 UTC 2012 Fri Apr 6 17:02:21 BST 2012 Fri Apr 6 19:02:21 EEST 2012 -------------------------------------------------------- WALL CLOCK: 15:57 SYSTEM TIMEZONE: Asia/Damascus -------------------------------------------------------- ADJTIME: 0.016599 1333727741 0.000000 1333727741 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 18:57:10 EEST -0.578544 seconds LOCAL Fri 06 Apr 2012 15:57:11 EEST -0.969234 seconds -------------------------------------------------------- DATE: Fri Apr 6 08:57:11 PDT 2012 Fri Apr 6 15:57:11 UTC 2012 Fri Apr 6 16:57:11 BST 2012 Fri Apr 6 18:57:11 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:06 SYSTEM TIMEZONE: Etc/UTC -------------------------------------------------------- ADJTIME: 0.016599 1333728301 0.000000 1333728301 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 16:06:43 UTC -1.000476 seconds LOCAL Fri 06 Apr 2012 16:06:44 UTC -1.000570 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:06:43 PDT 2012 Fri Apr 6 16:06:43 UTC 2012 Fri Apr 6 17:06:43 BST 2012 Fri Apr 6 19:06:43 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:09 SYSTEM TIMEZONE: Europe/London -------------------------------------------------------- ADJTIME: 0.016599 1333728485 0.000000 1333728485 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 18:09:34 BST -0.938010 seconds LOCAL Fri 06 Apr 2012 17:09:35 BST -0.984936 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:09:35 PDT 2012 Fri Apr 6 16:09:35 UTC 2012 Fri Apr 6 17:09:35 BST 2012 Fri Apr 6 19:09:35 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:12 SYSTEM TIMEZONE: US/Pacific -------------------------------------------------------- ADJTIME: 0.016599 1333728653 0.000000 1333728653 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 02:12:26 PDT -0.063051 seconds LOCAL Fri 06 Apr 2012 09:12:27 PDT -0.969252 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:12:27 PDT 2012 Fri Apr 6 16:12:27 UTC 2012 Fri Apr 6 17:12:27 BST 2012 Fri Apr 6 19:12:27 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:15 SYSTEM TIMEZONE: Asia/Damascus -------------------------------------------------------- ADJTIME: 0.016599 1333728814 0.000000 1333728814 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 22:15:46 EEST -0.160983 seconds LOCAL Fri 06 Apr 2012 19:15:47 EEST -0.953626 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:15:46 PDT 2012 Fri Apr 6 16:15:46 UTC 2012 Fri Apr 6 17:15:46 BST 2012 Fri Apr 6 19:15:46 EEST 2012 -------------------------------------------------------- NO UDEV: WALL CLOCK: 16:21 SYSTEM TIMEZONE: Etc/UTC -------------------------------------------------------- ADJTIME: 0.016599 1333729189 0.000000 1333729189 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 16:21:45 UTC -0.860255 seconds LOCAL Fri 06 Apr 2012 16:21:46 UTC -0.985297 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:21:46 PDT 2012 Fri Apr 6 16:21:46 UTC 2012 Fri Apr 6 17:21:46 BST 2012 Fri Apr 6 19:21:46 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:25 SYSTEM TIMEZONE: Europe/London -------------------------------------------------------- ADJTIME: 0.016599 1333729408 0.000000 1333729408 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 17:25:11 BST -0.203682 seconds LOCAL Fri 06 Apr 2012 16:25:12 BST -0.985347 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:25:12 PDT 2012 Fri Apr 6 16:25:12 UTC 2012 Fri Apr 6 17:25:12 BST 2012 Fri Apr 6 19:25:12 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:28 SYSTEM TIMEZONE: US/Pacific -------------------------------------------------------- ADJTIME: 0.016599 1333729593 0.000000 1333729593 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 09:28:02 PDT -0.266309 seconds LOCAL Fri 06 Apr 2012 16:28:03 PDT -0.985406 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:28:03 PDT 2012 Fri Apr 6 16:28:03 UTC 2012 Fri Apr 6 17:28:03 BST 2012 Fri Apr 6 19:28:03 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:31 SYSTEM TIMEZONE: Asia/Damascus -------------------------------------------------------- ADJTIME: 0.016599 1333729750 0.000000 1333729750 UTC -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 19:31:24 EEST -0.625566 seconds LOCAL Fri 06 Apr 2012 16:31:25 EEST -0.984937 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:31:25 PDT 2012 Fri Apr 6 16:31:25 UTC 2012 Fri Apr 6 17:31:25 BST 2012 Fri Apr 6 19:31:25 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:34 SYSTEM TIMEZONE: Etc/UTC -------------------------------------------------------- ADJTIME: 0.016599 1333729952 0.000000 1333729952 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 16:34:28 UTC -0.063057 seconds LOCAL Fri 06 Apr 2012 16:34:29 UTC -0.984974 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:34:29 PDT 2012 Fri Apr 6 16:34:29 UTC 2012 Fri Apr 6 17:34:29 BST 2012 Fri Apr 6 19:34:29 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:37 SYSTEM TIMEZONE: Europe/London -------------------------------------------------------- ADJTIME: 0.016599 1333730122 0.000000 1333730122 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 18:37:00 BST -0.078701 seconds LOCAL Fri 06 Apr 2012 17:37:01 BST -0.985032 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:37:01 PDT 2012 Fri Apr 6 16:37:01 UTC 2012 Fri Apr 6 17:37:01 BST 2012 Fri Apr 6 19:37:01 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:39 SYSTEM TIMEZONE: US/Pacific -------------------------------------------------------- ADJTIME: 0.016599 1333730279 0.000000 1333730279 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 02:39:25 PDT -0.469256 seconds LOCAL Fri 06 Apr 2012 09:39:26 PDT -0.985057 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:39:26 PDT 2012 Fri Apr 6 16:39:26 UTC 2012 Fri Apr 6 17:39:26 BST 2012 Fri Apr 6 19:39:26 EEST 2012 -------------------------------------------------------- WALL CLOCK: 16:42 SYSTEM TIMEZONE: Asia/Damascus -------------------------------------------------------- ADJTIME: 0.016599 1333730442 0.000000 1333730442 LOCAL -------------------------------------------------------- HWCLOCK: UTC Fri 06 Apr 2012 22:42:27 EEST -0.578694 seconds LOCAL Fri 06 Apr 2012 19:42:28 EEST -0.985045 seconds -------------------------------------------------------- DATE: Fri Apr 6 09:42:28 PDT 2012 Fri Apr 6 16:42:28 UTC 2012 Fri Apr 6 17:42:28 BST 2012 Fri Apr 6 19:42:28 EEST 2012 -------------------------------------------------------- -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
#!/bin/sh set -e unset TZ echo "WALL CLOCK: XX" echo -n "SYSTEM TIMEZONE: " cat /etc/timezone echo "--------------------------------------------------------" echo "ADJTIME:" cat /etc/adjtime echo "--------------------------------------------------------" echo HWCLOCK: for clock in utc local; do if [ "$clock" = "utc" ]; then CLOCK="UTC " OPT="--utc" else CLOCK="LOCAL " OPT="--localtime" fi echo -n "$CLOCK" hwclock -r "$OPT" done echo "--------------------------------------------------------" echo "DATE:" for zone in US/Pacific UTC Europe/London Asia/Damascus; do TZ="$zone" date done echo "--------------------------------------------------------"
--- util-linux-2.20.1.original/debian/changelog 2012-04-05 23:42:05.000000000 +0100 +++ util-linux-2.20.1/debian/changelog 2012-04-06 15:43:46.515313440 +0100 @@ -1,3 +1,39 @@ +util-linux (2.20.1-5) unstable; urgency=low + + [Roger Leigh] + * Improve handling of the hardware clock + - Remove redundant hwclockfirst.sh and hwclock.sh. The reason for + this redundant script existing (/etc/localtime not being present + until after /usr was mounted AFAICT) no longer exists. The + hwclock script has been adjusted to run before checkroot. + - Migrate existing + UTC= setting in /etc/default/rcS to UTC/LOCAL in /etc/adjtime. + This removes needless duplication of the setting, and prevents the + behaviour of hwclock being overridden, and its configuration + overwritten every shutdown. Closes: #554345 + - The hwclock init scripts now use /etc/adjtime instead of the + --utc and --localtime options (based on the UTC setting). + - Add /etc/default/hwclock and hwclock(5) which permit + configuration without editing the initscript, and also document + all the undocumented variables used by the scripts. Closes: + #481357, #659654 + - The udev hwclock-set script runs hwclock --tzset unconditionally + in all cases (it's a no-op for UTC). + - The user running "hwclock --systohc (--utc|--localtime)" is now + handled correctly. The clock state is recorded in /etc/adjtime + and correctly handled on system restart. This means the UTC + setting in /etc/default/rcS doesn't create problems by requiring + two separate changes (changing the UTC setting and running + hwclock) to do the same thing. + - Comment out the now-obsolete UTC= setting in /etc/default/rcS, + with a reference to /etc/adjtime and hwclock(8). + - systemd uses /etc/adjtime as for hwclock to store the hardware + clock UTC/LOCAL configuration. This change means there's a + single place to store the hardware clock configuration for all + init systems. + + -- Roger Leigh <rle...@debian.org> Fri, 06 Apr 2012 17:42:55 +0300 + util-linux (2.20.1-4) unstable; urgency=low [Michał Kułach] --- util-linux-2.20.1.original/debian/hwclock.5 1970-01-01 01:00:00.000000000 +0100 +++ util-linux-2.20.1/debian/hwclock.5 2012-04-06 11:30:23.452308106 +0100 @@ -0,0 +1,40 @@ +.TH HWCLOCK 5 "Feb 2012" "" "Debian Administrator's Manual" +.SH NAME +hwclock \- variables that affect the behaviour of the hwclock boot script +.SH DESCRIPTION +The +.I /etc/default/rcS +file contains variable settings in POSIX format: +.IP "" .5i +VAR=VAL +.PP +Only one assignment is allowed per line. +Comments (starting with '#') are also allowed. + +.SH OPTIONS +The following variables can be set. + +.IP \fBBADYEAR\fP +This is used to specify that the hardware clock is incapable of storing +years outside the range of 1994-1999. Set to \fByes\fP if the hardware is +broken or \fBno\fP if working correctly. + +.IP \fBHWCLOCKACCESS\fP +If the hardware clock is not accessible, set to \fBno\fP, in which +case hwclock will not be run. Otherwise, set to \fByes\fP. + +.IP \fBHWCLOCKPARS\fP +Additional options for hwclock. Unset by default. For example, this +may be use to specify the machine hardware clock type for Alphas. + +.IP \fBHCTOSYS_DEVICE\fP +The hardware clock device you want to use. Defaults to \fBrtc0\fP. +It should probably match the CONFIG_RTC_HCTOSYS_DEVICE kernel config +option. + +.SH AUTHOR +Roger Leigh <rle...@debian.org> + +.SH SEE ALSO +.BR hwclock (8), +.BR rcS (5). --- util-linux-2.20.1.original/debian/hwclock.default 1970-01-01 01:00:00.000000000 +0100 +++ util-linux-2.20.1/debian/hwclock.default 2012-04-05 23:36:11.869619645 +0100 @@ -0,0 +1,19 @@ +# Defaults for the hwclock init script. See hwclock(5) and hwclock(8). + +# This is used to specify that the hardware clock incapable of storing +# years outside the range of 1994-1999. Set to yes if the hardware is +# broken or no if working correctly. +#BADYEAR=no + +# Set this to yes if it is possible to access the hardware clock, +# or no if it is not. +#HWCLOCKACCESS=yes + +# Set this to any options you might need to give to hwclock, such +# as machine hardware clock type for Alphas. +#HWCLOCKPARS= + +# Set this to the hardware clock device you want to use, it should +# probably match the CONFIG_RTC_HCTOSYS_DEVICE kernel config option. +#HCTOSYS_DEVICE=rtc0 + --- util-linux-2.20.1.original/debian/hwclock-set 2012-04-05 23:42:05.000000000 +0100 +++ util-linux-2.20.1/debian/hwclock-set 2012-04-05 23:38:53.468411912 +0100 @@ -10,15 +10,19 @@ if [ -f /etc/default/rcS ] ; then . /etc/default/rcS -fi +fi + +# These defaults are user-overridable in /etc/default/hwclock +BADYEAR=no +HWCLOCKACCESS=yes +HWCLOCKPARS= +HCTOSYS_DEVICE=rtc0 if [ -f /etc/default/hwclock ] ; then . /etc/default/hwclock fi -if [ yes != "$UTC" ] ; then - if [ yes = "$BADYEAR" ] ; then - /sbin/hwclock --rtc=$dev --systz --localtime --noadjfile --badyear - else - /sbin/hwclock --rtc=$dev --systz --localtime --noadjfile - fi +if [ yes = "$BADYEAR" ] ; then + /sbin/hwclock --rtc=$dev --systz --badyear +else + /sbin/hwclock --rtc=$dev --systzif [ yes != "$UTC" ] ; then fi --- util-linux-2.20.1.original/debian/hwclock.sh 2012-04-05 23:42:05.000000000 +0100 +++ util-linux-2.20.1/debian/hwclock.sh 2012-04-06 15:39:17.498600072 +0100 @@ -1,6 +1,5 @@ #!/bin/sh -# hwclock.sh Set and adjust the CMOS clock, according to the UTC -# setting in /etc/default/rcS (see also rcS(5)). +# hwclock.sh Set and adjust the CMOS clock. # # Version: @(#)hwclock.sh 2.00 14-Dec-1998 miqu...@cistron.nl # @@ -11,6 +10,10 @@ # during startup/shutdown. # - Added comments to alert users of hwclock issues # and discourage tampering without proper doc reading. +# 2012-02-16 Roger Leigh <rle...@debian.org> +# - Use the UTC/LOCAL setting in /etc/adjtime rather than +# the UTC setting in /etc/default/rcS. Additionally +# source /etc/default/hwclock to permit configuration. # WARNING: Please read /usr/share/doc/util-linux/README.Debian.hwclock # before changing this file. You risk serious clock @@ -18,22 +21,23 @@ ### BEGIN INIT INFO # Provides: hwclock -# Required-Start: checkroot +# Required-Start: mountdevsubfs # Required-Stop: $local_fs # Default-Start: S +# X-Start-Before: checkroot # Default-Stop: 0 6 ### END INIT INFO -FIRST=no # debian/rules sets this to 'yes' when creating hwclockfirst.sh - -# Set this to any options you might need to give to hwclock, such -# as machine hardware clock type for Alphas. +# These defaults are user-overridable in /etc/default/hwclock +BADYEAR=no +HWCLOCKACCESS=yes HWCLOCKPARS= - -# Set this to the hardware clock device you want to use, it should -# probably match the CONFIG_RTC_HCTOSYS_DEVICE kernel config option. HCTOSYS_DEVICE=rtc0 +# We only want to use the system timezone or else we'll get +# potential inconsistency at startup. +unset TZ + hwclocksh() { [ ! -x /sbin/hwclock ] && return 0 @@ -43,23 +47,6 @@ . /lib/lsb/init-functions verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; } - [ "$GMT" = "-u" ] && UTC="yes" - case "$UTC" in - no|"") GMT="--localtime" - UTC="" - if [ "X$FIRST" = "Xyes" ] && [ ! -r /etc/localtime ]; then - if [ -z "$TZ" ]; then - log_action_msg "System clock was not updated at this time" - return 1 - fi - fi - ;; - yes) GMT="--utc" - UTC="--utc" - ;; - *) log_action_msg "Unknown UTC setting: \"$UTC\""; return 1 ;; - esac - case "$BADYEAR" in no|"") BADYEAR="" ;; yes) BADYEAR="--badyear" ;; @@ -68,52 +55,29 @@ case "$1" in start) - if [ -d /run/udev ] || [ -d /dev/.udev ]; then - return 0 - fi - + # If the admin deleted the hwclock config, create a blank + # template with the defaults. if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then - echo "0.0 0 0.0" > /etc/adjtime - fi - - if [ ! -w /etc/adjtime ]; then - NOADJ="--noadjfile" - else - NOADJ="" + printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime fi - if [ "$FIRST" != yes ]; then - # Uncomment the hwclock --adjust line below if you want - # hwclock to try to correct systematic drift errors in the - # Hardware Clock. - # - # 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 - # 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 - # 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 - : + if [ -d /run/udev ] || [ -d /dev/.udev ]; then + return 0 fi if [ "$HWCLOCKACCESS" != no ]; then log_action_msg "Setting the system clock" + # Just for reporting. + if head -n 3 /etc/adjtime | tail -n 1 | grep -q '^UTC$' ; then + UTC="--utc" + else + UTC= + fi # 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 --rtc=/dev/$HCTOSYS_DEVICE --hctosys $HWCLOCKPARS $BADYEAR; then # Announce the local time. verbose_log_action_msg "System Clock set to: `date $UTC`" else @@ -131,18 +95,10 @@ # WARNING: If you disable this, any changes to the system # clock will not be carried across reboots. # - if [ ! -w /etc/adjtime ]; then - NOADJ="--noadjfile" - else - NOADJ="" - fi if [ "$HWCLOCKACCESS" != no ]; then log_action_msg "Saving the system clock" - if [ "$GMT" = "-u" ]; then - GMT="--utc" - fi - if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $GMT $HWCLOCKPARS $BADYEAR $NOADJ; then + if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $HWCLOCKPARS $BADYEAR; then verbose_log_action_msg "Hardware Clock updated to `date`" fi else @@ -150,14 +106,8 @@ fi ;; show) - if [ ! -w /etc/adjtime ]; then - NOADJ="--noadjfile" - else - NOADJ="" - fi - if [ "$HWCLOCKACCESS" != no ]; then - /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $GMT $HWCLOCKPARS $BADYEAR $NOADJ + /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $HWCLOCKPARS $BADYEAR fi ;; *) --- util-linux-2.20.1.original/debian/rules 2012-04-05 23:42:05.000000000 +0100 +++ util-linux-2.20.1/debian/rules 2012-04-05 23:36:11.869619645 +0100 @@ -124,15 +124,8 @@ install -m 644 debian/mime.util-linux debian/util-linux/usr/lib/mime/packages/util-linux if [ -f debian/util-linux/sbin/hwclock ] ; then \ install -m 755 debian/hwclock.sh debian/util-linux/etc/init.d/hwclock.sh; \ - install -m 755 debian/hwclock.sh debian/util-linux/etc/init.d/hwclockfirst.sh; \ - sed -i -e '/^FIRST=/s/no/yes/' -e '/Provides:/s/ck/ckfirst/' \ - -e '/Required-Start:/s/checkroot/mountdevsubfs/' \ - -e '/Required-Start:/a# Required-Stop:' -e '/Required-Stop:/d' \ - -e '/Default-Start:/a# X-Start-Before: checkroot' \ - -e '/Default-Start:/a# Default-Stop:' -e '/Default-Stop:/d' \ - debian/util-linux/etc/init.d/hwclockfirst.sh; \ - fi - if [ -f debian/util-linux/sbin/hwclock ] ; then \ + install -m 644 debian/hwclock.default debian/util-linux/etc/default/hwclock; \ + install -m 644 debian/hwclock.5 debian/util-linux/usr/share/man/man5; \ install -m 644 debian/hwclock.rules debian/util-linux/lib/udev/rules.d/85-hwclock.rules; \ install -m 755 debian/hwclock-set debian/util-linux/lib/udev/hwclock-set; \ fi --- util-linux-2.20.1.original/debian/util-linux.postinst 2012-04-05 23:42:05.000000000 +0100 +++ util-linux-2.20.1/debian/util-linux.postinst 2012-04-06 18:14:46.959773233 +0100 @@ -31,6 +31,25 @@ fi fi +# Do a one-time migration of the local time setting to /etc/adjtime + +if [ -n "$2" ] && dpkg --compare-versions "$2" lt "2.20.1-5"; then + if [ -f /etc/default/rcS ]; then + . /etc/default/rcS + fi + if [ ! -e /etc/adjtime ]; then + printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime + fi + if [ "$UTC" = "no" ]; then + sed -i -e 's:^UTC$:LOCAL:' /etc/adjtime + else + sed -i -e 's:^LOCAL$:UTC:' /etc/adjtime + fi + if [ -f /etc/default/rcS ]; then + sed -i -e 's:^\(UTC=.*\)$:#\1 # OBSOLETE; see /etc/adjtime and hwclock(8).:' /etc/default/rcS + fi +fi + if [ -x /usr/sbin/update-mime ]; then update-mime fi --- util-linux-2.20.1.original/debian/util-linux.preinst 2012-04-05 23:42:05.000000000 +0100 +++ util-linux-2.20.1/debian/util-linux.preinst 2012-04-06 16:39:59.980403888 +0100 @@ -2,6 +2,26 @@ set -e +# Remove a no-longer used conffile +rm_conffile() { + local PKGNAME="$1" + local CONFFILE="$2" + + [ -e "$CONFFILE" ] || return 0 + + local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')" + local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \ + sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")" + if [ "$md5sum" != "$old_md5sum" ]; then + echo "Obsolete conffile $CONFFILE has been modified by you." + echo "Saving as $CONFFILE.dpkg-bak ..." + mv -f "$CONFFILE" "$CONFFILE".dpkg-bak + else + echo "Removing obsolete conffile $CONFFILE ..." + rm -f "$CONFFILE" + fi +} + 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/ .*//\"`" = \ @@ -10,6 +30,11 @@ rm -f "/etc/udev/rules.d/85-hwclock.rules" fi fi + + if dpkg --compare-versions "$2" lt "2.20.1-5"; then + rm_conffile util-linux "/etc/init.d/hwclockfirst.sh" + fi + update-rc.d hwclockfirst.sh remove >/dev/null fi #DEBHELPER#