Package: util-linux
Version: 2.20.1-5.1ubuntu8
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Dear Maintainer,

please consider applying the following patch which adds upstart
integration for hwclock, as there already exists systemd, udev and
init.d integration.

The patch below follows debian policy on alternative init systems [1]
and recommended practices in making upstart compatible init scripts
[2]. The upstart jobs attached will continue to honour existing
settings for additional arguments, clock access and rtc device
names. The utc/localtime setting is derived using /etc/adjtime similar
to the current init.d script.

I have tested proposed changes on debian sid, with both sysvinit and
upstart.

[1] http://www.debian.org/doc/debian-policy/ch-opersys.html#s-alternateinit
[2] https://wiki.ubuntu.com/UpstartCompatibleInitScripts

Regards,

Dmitrijs.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQIcBAEBCAAGBQJRuGpeAAoJEIh7YGGLPBau2EgP/jEk8wl1nJN7awbMKsjfSPWI
sRxMgp5e8uM19G4KXe5I6EzIy1MJLz7YF11UpiJxoY4Wp1Gox7A5Rg/QYsY/OK4h
48Pff5HD1SZT4X7kIqFaracqyzaZz4QMvY//YLH5Qff4iM7M51ljRlvR3Vcvz+sx
Mbgu9oKEd/H1eb2cBcgrod52m9OT1jGlh2MKZzISfJmzWiGw17Ov8gkcxsD1Jcp0
VnnLsyZ3lYq/IDwF1wYNymh0jGjKJOuWVI8cWZzYrTNAQOuU9Dsa3UtDVkJAwp2c
5JjWz6RbV+OndtCjXv8Jq6MA4CR/gZYibM7MKViXSsfN1aqThtz8+ft6U44bmMjk
oUEdDvaNs55NH+NfjJmslDAOz2um/vhe+tpqN4zek9rK02qeLBTgu077fIN1wUnn
ighV/Ukz35UmSKas3lquH54/Qt4sNcX3n83f1r+c4l8tG55TMLM5rKhfHBJxyQUp
rd/5zD6/wGzVxK8wNYS1CQ7WGVGQNsJ3nOXywJRg+vr+cuSFI3tXTET2ALM2UYjF
ActMIa7jJmU1SWxpqMTtCopH9YocVZ7EG1dHyebe4Jb6cl7U7sWwsQ8/0jLh2C+z
2FEswYsH3qsoT14OWIJvgLfdwiGIhEE6zdujofnW113bKBwRpCZeqif4pH1PdpIj
gb1ayp1vtYKOnx/Ahse6
=DPOf
-----END PGP SIGNATURE-----
diff -u util-linux-2.20.1/debian/changelog util-linux-2.20.1/debian/changelog
--- util-linux-2.20.1/debian/changelog
+++ util-linux-2.20.1/debian/changelog
@@ -1,3 +1,15 @@
+util-linux (2.20.1-5.5) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * Add upstart integration:
+    - Deactivate udev rules if init is upstart.
+    - Add upstart jobs to set system clock & store hardware clock. Both
+    use same settings files, as the init.d script.
+    - Add a compatibility job for insserv correctly detect this package is
+    now upstart compatible.
+
+ -- Dmitrijs Ledkovs <dmitrij.led...@ubuntu.com>  Wed, 12 Jun 2013 10:02:39 +0100
+
 util-linux (2.20.1-5.4) unstable; urgency=low
 
   * Non-maintainer upload.
reverted:
--- util-linux-2.20.1/debian/hwclock.sh
+++ util-linux-2.20.1.orig/debian/hwclock.sh
@@ -1,122 +0,0 @@
-#!/bin/sh
-# hwclock.sh	Set and adjust the CMOS clock.
-#
-# Version:	@(#)hwclock.sh  2.00  14-Dec-1998  miqu...@cistron.nl
-#
-# Patches:
-#		2000-01-30 Henrique M. Holschuh <h...@rcm.org.br>
-#		 - Minor cosmetic changes in an attempt to help new
-#		   users notice something IS changing their clocks
-#		   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
-#		misbehaviour otherwise.
-
-### BEGIN INIT INFO
-# Provides:          hwclock
-# Required-Start:    mountdevsubfs
-# Required-Stop:     $local_fs
-# Default-Start:     S
-# X-Start-Before:    checkroot
-# Default-Stop:      0 6
-### END INIT INFO
-
-# These defaults are user-overridable in /etc/default/hwclock
-BADYEAR=no
-HWCLOCKACCESS=yes
-HWCLOCKPARS=
-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
-    [ ! -r /etc/default/rcS ] || . /etc/default/rcS
-    [ ! -r /etc/default/hwclock ] || . /etc/default/hwclock
-
-    . /lib/lsb/init-functions
-    verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; }
-
-    case "$BADYEAR" in
-       no|"")	BADYEAR="" ;;
-       yes)	BADYEAR="--badyear" ;;
-       *)	log_action_msg "unknown BADYEAR setting: \"$BADYEAR\""; return 1 ;;
-    esac
-
-    case "$1" in
-	start)
-	    # If the admin deleted the hwclock config, create a blank
-	    # template with the defaults.
-	    if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then
-	        printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime
-	    fi
-
-	    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 $HWCLOCKPARS $BADYEAR; then
-		    #	Announce the local time.
-		    verbose_log_action_msg "System Clock set to: `date $UTC`"
-		else
-		    log_warning_msg "Unable to set System Clock to: `date $UTC`"
-		fi
-	    else
-		verbose_log_action_msg "Not setting System Clock"
-	    fi
-	    ;;
-	stop|restart|reload|force-reload)
-	    #
-	    # Updates the Hardware Clock with the System Clock time.
-	    # This will *override* any changes made to the Hardware Clock.
-	    #
-	    # WARNING: If you disable this, any changes to the system
-	    #          clock will not be carried across reboots.
-	    #
-
-	    if [ "$HWCLOCKACCESS" != no ]; then
-		log_action_msg "Saving the system clock"
-		if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $HWCLOCKPARS $BADYEAR; then
-		    verbose_log_action_msg "Hardware Clock updated to `date`"
-		fi
-	    else
-		verbose_log_action_msg "Not saving System Clock"
-	    fi
-	    ;;
-	show)
-	    if [ "$HWCLOCKACCESS" != no ]; then
-		/sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $HWCLOCKPARS $BADYEAR
-	    fi
-	    ;;
-	*)
-	    log_success_msg "Usage: hwclock.sh {start|stop|reload|force-reload|show}"
-	    log_success_msg "       start sets kernel (system) clock from hardware (RTC) clock"
-	    log_success_msg "       stop and reload set hardware (RTC) clock from kernel (system) clock"
-	    return 1
-	    ;;
-    esac
-}
-
-hwclocksh "$@"
diff -u util-linux-2.20.1/debian/rules util-linux-2.20.1/debian/rules
--- util-linux-2.20.1/debian/rules
+++ util-linux-2.20.1/debian/rules
@@ -123,7 +123,6 @@
 	for pkg in bsdutils mount uuid-runtime; do install -m 644 debian/$${pkg}.lintian-overrides debian/$${pkg}/usr/share/lintian/overrides/$${pkg}; done
 	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 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; \
@@ -195,7 +194,11 @@
 	dh_testdir -s
 	dh_testroot -s
 	dh_lintian -s
-	dh_installinit -s -- defaults 15 85
+	if [ -f debian/util-linux/sbin/hwclock ]; then \
+		dh_installinit -putil-linux --name=hwclock.sh --noscripts; \
+		dh_installinit -putil-linux --name=hwclock --no-start; \
+		dh_installinit -putil-linux --name=hwclock-save --no-start; \
+	fi
 	[ -n "$(STRIP)" ] || dh_strip -s
 	dh_makeshlibs -s
 	dh_installdebconf -s
diff -u util-linux-2.20.1/debian/control util-linux-2.20.1/debian/control
--- util-linux-2.20.1/debian/control
+++ util-linux-2.20.1/debian/control
@@ -14,7 +14,7 @@
 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 (>= 4.1+Debian3), tzdata (>=2006c-2), initscripts, 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 -u util-linux-2.20.1/debian/hwclock-set util-linux-2.20.1/debian/hwclock-set
--- util-linux-2.20.1/debian/hwclock-set
+++ util-linux-2.20.1/debian/hwclock-set
@@ -8,6 +8,10 @@
     exit 0
 fi
 
+if which initctl >/dev/null && initctl version | grep -q upstart ; then
+    exit 0
+fi
+
 if [ -f /etc/default/rcS ] ; then
     . /etc/default/rcS
 fi
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/debian/util-linux.hwclock-save.upstart
+++ util-linux-2.20.1/debian/util-linux.hwclock-save.upstart
@@ -0,0 +1,19 @@
+# hwclock-save - save system clock to hardware clock
+#
+# This task saves the time from the system clock back to the hardware
+# clock on shutdown.
+
+description	"save system clock to hardware clock"
+
+start on runlevel [06]
+
+task
+
+script
+    . /etc/default/rcS || :
+    . /etc/default/hwclock || :
+    [ "$HWCLOCKACCESS" = "no" ] && { stop; exit 0; }
+    [ "$BADYEAR" = "yes" ] && badyear="--badyear"
+    [ -n "$HCTOSYS_DEVICE" ] && hctosys_device="--rtc=/dev/$HCTOSYS_DEVICE"
+    exec hwclock --systohc $hctosys_device $HWCLOCKPARS $badyear
+end script
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/debian/util-linux.hwclock.sh.init
+++ util-linux-2.20.1/debian/util-linux.hwclock.sh.init
@@ -0,0 +1,136 @@
+#!/bin/sh
+# hwclock.sh	Set and adjust the CMOS clock.
+#
+# Version:	@(#)hwclock.sh  2.00  14-Dec-1998  miqu...@cistron.nl
+#
+# Patches:
+#		2000-01-30 Henrique M. Holschuh <h...@rcm.org.br>
+#		 - Minor cosmetic changes in an attempt to help new
+#		   users notice something IS changing their clocks
+#		   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
+#		misbehaviour otherwise.
+
+### BEGIN INIT INFO
+# Provides:          hwclock
+# Required-Start:    mountdevsubfs
+# Required-Stop:     $local_fs
+# Default-Start:     S
+# X-Start-Before:    checkroot
+# Default-Stop:      0 6
+### END INIT INFO
+
+# These defaults are user-overridable in /etc/default/hwclock
+BADYEAR=no
+HWCLOCKACCESS=yes
+HWCLOCKPARS=
+HCTOSYS_DEVICE=rtc0
+
+# We only want to use the system timezone or else we'll get
+# potential inconsistency at startup.
+unset TZ
+
+. /lib/lsb/init-functions
+
+hwclocksh()
+{
+    [ ! -x /sbin/hwclock ] && return 0
+    [ ! -r /etc/default/rcS ] || . /etc/default/rcS
+    [ ! -r /etc/default/hwclock ] || . /etc/default/hwclock
+
+    verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; }
+
+    case "$BADYEAR" in
+       no|"")	BADYEAR="" ;;
+       yes)	BADYEAR="--badyear" ;;
+       *)	log_action_msg "unknown BADYEAR setting: \"$BADYEAR\""; return 1 ;;
+    esac
+
+    case "$1" in
+	start)
+	    # If the admin deleted the hwclock config, create a blank
+	    # template with the defaults.
+	    if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then
+	        printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime
+	    fi
+
+	    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 $HWCLOCKPARS $BADYEAR; then
+		    #	Announce the local time.
+		    verbose_log_action_msg "System Clock set to: `date $UTC`"
+		else
+		    log_warning_msg "Unable to set System Clock to: `date $UTC`"
+		fi
+	    else
+		verbose_log_action_msg "Not setting System Clock"
+	    fi
+	    ;;
+	stop|restart|reload|force-reload)
+	    #
+	    # Updates the Hardware Clock with the System Clock time.
+	    # This will *override* any changes made to the Hardware Clock.
+	    #
+	    # WARNING: If you disable this, any changes to the system
+	    #          clock will not be carried across reboots.
+	    #
+
+	    if [ "$HWCLOCKACCESS" != no ]; then
+		log_action_msg "Saving the system clock"
+		if /sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --systohc $HWCLOCKPARS $BADYEAR; then
+		    verbose_log_action_msg "Hardware Clock updated to `date`"
+		fi
+	    else
+		verbose_log_action_msg "Not saving System Clock"
+	    fi
+	    ;;
+	show)
+	    if [ "$HWCLOCKACCESS" != no ]; then
+		/sbin/hwclock --rtc=/dev/$HCTOSYS_DEVICE --show $HWCLOCKPARS $BADYEAR
+	    fi
+	    ;;
+	*)
+	    log_success_msg "Usage: hwclock.sh {start|stop|reload|force-reload|show}"
+	    log_success_msg "       start sets kernel (system) clock from hardware (RTC) clock"
+	    log_success_msg "       stop and reload set hardware (RTC) clock from kernel (system) clock"
+	    return 1
+	    ;;
+    esac
+}
+
+if init_is_upstart; then
+    case $1 in
+	show)
+	    ;;
+	stop)
+	    exit 0
+	    ;;
+	*)
+	    exit 1
+	    ;;
+    esac
+fi
+
+hwclocksh "$@"
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/debian/util-linux.hwclock.upstart
+++ util-linux-2.20.1/debian/util-linux.hwclock.upstart
@@ -0,0 +1,21 @@
+# hwclock - adjust system clock and timezone
+#
+# The hwclock task adjusts the system clock when the hardware clock is
+# set to localtime (e.g. when dual-booting with Windows), and also
+# ensures that the system timezone is set so that timestamps are written
+# to FAT devices.
+
+description	"adjust system clock and timezone"
+
+start on starting mountall
+
+task
+
+script
+    . /etc/default/rcS || :
+    . /etc/default/hwclock || :
+    [ "$HWCLOCKACCESS" = "no" ] && { stop; exit 0; }
+    [ "$BADYEAR" = "yes" ] && badyear="--badyear"
+    [ -n "$HCTOSYS_DEVICE" ] && hctosys_device="--rtc=/dev/$HCTOSYS_DEVICE"
+    exec hwclock --hctosys $hctosys_device $HWCLOCKPARS $badyear
+end script
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/debian/util-linux.hwclock.sh.upstart
+++ util-linux-2.20.1/debian/util-linux.hwclock.sh.upstart
@@ -0,0 +1,10 @@
+# hwclock.sh - compatibility job for sysvinit dependencies
+#
+# This job runs once after hwclock was executed, to signal startpar
+# that other rcS jobs relying on the historic hwclock.sh interface can
+# continue.
+
+description	"Signal sysvinit that system clock is updated"
+
+start on started hwclock
+

Reply via email to