initscripts: save /etc/timestamp with seconds accuracy
authorBlair Elliott <blair.elliott@ni.com>
Thu, 17 Jul 2014 21:56:53 +0000 (16:56 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 18 Jul 2014 23:08:59 +0000 (00:08 +0100)
Currently, /etc/timestamp is saved with minutes accuracy.  To increase
the accuracy, modify the save-rtc.sh and bootmisc.sh scripts to save and
read /etc/timestamp respectively with seconds accuracy.

(From OE-Core rev: 8fed53e4e72230c61f23cb36eda36c228aede1e0)

Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/image.bbclass
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh

index a03b880..772c3ed 100644 (file)
@@ -359,7 +359,7 @@ set_image_autologin () {
 # Can be use to create /etc/timestamp during image construction to give a reasonably 
 # sane default time setting
 rootfs_update_timestamp () {
-       date -u +%4Y%2m%2d%2H%2M >${IMAGE_ROOTFS}/etc/timestamp
+       date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
 }
 
 # Prevent X from being started
index 5211824..ccc7f9f 100755 (executable)
@@ -66,10 +66,11 @@ fi
 test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
 if test -e /etc/timestamp
 then
-       SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M`
+       SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
        read TIMESTAMP < /etc/timestamp
        if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
-               date -u ${TIMESTAMP#????}${TIMESTAMP%????????}
+               # format the timestamp as date expects it (2m2d2H2M4Y.2S)
+               date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
                test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
        fi
 fi
index 1f804e2..b038fc5 100644 (file)
@@ -10,4 +10,4 @@
 ### END INIT INFO
 
 # Update the timestamp
-date -u +%4Y%2m%2d%2H%2M > /etc/timestamp
+date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp