diff mbox

[4/4] busybox: Add USE flag to set whether busybox hwclock uses utc

Message ID af9320ee86fabe1a7bd2eed6967f0acd133f9682.1399459420.git.christian.braunersorensen@prevas.dk
State Changes Requested
Delegated to: Esben Haabendal
Headers show

Commit Message

christian.braunersorensen@prevas.dk May 7, 2014, 10:44 a.m. UTC
From: Christian Sørensen <christian.braunersorensen@prevas.dk>

USE_busybox_hwclock_use_utc: Default not set. If set, inserts --utc to
all hwclock commands within the busybox-hwclock initscript.

Signed-off-by: Christian Sørensen <christian.braunersorensen@prevas.dk>
---
 recipes/busybox/busybox-configure.inc | 11 +++++++++++
 recipes/busybox/files/busybox-hwclock |  8 ++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

Comments

Esben Haabendal May 13, 2014, 12:12 p.m. UTC | #1
<christian.braunersorensen@prevas.dk> writes:

> From: Christian Sørensen <christian.braunersorensen@prevas.dk>
>
> USE_busybox_hwclock_use_utc: Default not set. If set, inserts --utc to
> all hwclock commands within the busybox-hwclock initscript.
>
> Signed-off-by: Christian Sørensen <christian.braunersorensen@prevas.dk>
> ---
>  recipes/busybox/busybox-configure.inc | 11 +++++++++++
>  recipes/busybox/files/busybox-hwclock |  8 ++++----
>  2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/recipes/busybox/busybox-configure.inc b/recipes/busybox/busybox-configure.inc
> index 06588d6..e359928 100644
> --- a/recipes/busybox/busybox-configure.inc
> +++ b/recipes/busybox/busybox-configure.inc
> @@ -215,6 +215,17 @@ DEFAULT_USE_busybox_hwclock_sysvinit_stop  = "15"
>  RECIPE_FLAGS += "busybox_hwclock_splashutils_progress busybox_hwclock_splashutils_msg"
>  SPLASHUTILS_INITSCRIPTS:>USE_busybox_hwclock += " busybox_hwclock"
>  DEFAULT_USE_busybox_hwclock_splashutils_msg = "\"Starting Busybox HWclock\""
> +RECIPE_FLAGS += "busybox_hwclock_utc"
> +DO_CONFIGURE_PREFUNCS += " do_configure_busybox_hwclock_use_utc"
> +do_configure_busybox_hwclock_use_utc () {
> +	if [ -n "$USE_busybox_hwclock" ]; then
> +		if [ -z "$USE_busybox_hwclock_utc" ]; then
> +			sed -i -e 's/ HWCLOCK_UTC//' ${SRCDIR}/busybox-hwclock
> +		else
> +			sed -i -e 's/HWCLOCK_UTC/\-\-utc/' ${SRCDIR}/busybox-hwclock
> +		fi
> +	fi
> +}
>  
>  RECIPE_FLAGS += "busybox_hwclock_crontab"
>  # USE flag: synchronize to rtc every hour using crond
> diff --git a/recipes/busybox/files/busybox-hwclock b/recipes/busybox/files/busybox-hwclock
> index 84619ff..d7446e6 100755
> --- a/recipes/busybox/files/busybox-hwclock
> +++ b/recipes/busybox/files/busybox-hwclock
> @@ -35,9 +35,9 @@ case "$1" in
>  		then
>  			if [ -z "$TZ" ]
>  			then
> -	                   hwclock --hctosys
> +	                   hwclock HWCLOCK_UTC --hctosys
>  			else
> -			   TZ="$TZ" hwclock --hctosys
> +			   TZ="$TZ" hwclock HWCLOCK_UTC --hctosys
>  			fi
>  		fi
>  
> @@ -60,7 +60,7 @@ case "$1" in
>  		fi
>  		if [ "$HWCLOCKACCESS" != no ]
>  		then
> -			hwclock --systohc
> +			hwclock HWCLOCK_UTC --systohc
>  		fi
>  		if [ "$VERBOSE" != no ]
>  		then
> @@ -71,7 +71,7 @@ case "$1" in
>  	show)
>  		if [ "$HWCLOCKACCESS" != no ]
>  		then
> -			hwclock --show
> +			hwclock HWCLOCK_UTC --show
>  		fi
>  		;;
>          *)

For easier (re)configuration, on target, it would be better if you
configure a single variable in the busybox-hwclock script, and then use
that on all calls to hwclock.

/Esben
diff mbox

Patch

diff --git a/recipes/busybox/busybox-configure.inc b/recipes/busybox/busybox-configure.inc
index 06588d6..e359928 100644
--- a/recipes/busybox/busybox-configure.inc
+++ b/recipes/busybox/busybox-configure.inc
@@ -215,6 +215,17 @@  DEFAULT_USE_busybox_hwclock_sysvinit_stop  = "15"
 RECIPE_FLAGS += "busybox_hwclock_splashutils_progress busybox_hwclock_splashutils_msg"
 SPLASHUTILS_INITSCRIPTS:>USE_busybox_hwclock += " busybox_hwclock"
 DEFAULT_USE_busybox_hwclock_splashutils_msg = "\"Starting Busybox HWclock\""
+RECIPE_FLAGS += "busybox_hwclock_utc"
+DO_CONFIGURE_PREFUNCS += " do_configure_busybox_hwclock_use_utc"
+do_configure_busybox_hwclock_use_utc () {
+	if [ -n "$USE_busybox_hwclock" ]; then
+		if [ -z "$USE_busybox_hwclock_utc" ]; then
+			sed -i -e 's/ HWCLOCK_UTC//' ${SRCDIR}/busybox-hwclock
+		else
+			sed -i -e 's/HWCLOCK_UTC/\-\-utc/' ${SRCDIR}/busybox-hwclock
+		fi
+	fi
+}
 
 RECIPE_FLAGS += "busybox_hwclock_crontab"
 # USE flag: synchronize to rtc every hour using crond
diff --git a/recipes/busybox/files/busybox-hwclock b/recipes/busybox/files/busybox-hwclock
index 84619ff..d7446e6 100755
--- a/recipes/busybox/files/busybox-hwclock
+++ b/recipes/busybox/files/busybox-hwclock
@@ -35,9 +35,9 @@  case "$1" in
 		then
 			if [ -z "$TZ" ]
 			then
-	                   hwclock --hctosys
+	                   hwclock HWCLOCK_UTC --hctosys
 			else
-			   TZ="$TZ" hwclock --hctosys
+			   TZ="$TZ" hwclock HWCLOCK_UTC --hctosys
 			fi
 		fi
 
@@ -60,7 +60,7 @@  case "$1" in
 		fi
 		if [ "$HWCLOCKACCESS" != no ]
 		then
-			hwclock --systohc
+			hwclock HWCLOCK_UTC --systohc
 		fi
 		if [ "$VERBOSE" != no ]
 		then
@@ -71,7 +71,7 @@  case "$1" in
 	show)
 		if [ "$HWCLOCKACCESS" != no ]
 		then
-			hwclock --show
+			hwclock HWCLOCK_UTC --show
 		fi
 		;;
         *)