init-scripts: introduce DONTUSETIMESTAMP variable in bootmisc.sh
PATCH 1/1 init-scripts: introduce DONTUSETIMESTAMP variable in bootmisc.sh
This variable is useful on systems with battery backed RTC. Imagine, that the board is shut down and then switched on after, for example three days. Althought the value in RTC is correct, this scripts sets system time with the wrong values.
--- recipes/initscripts/initscripts-1.0/bootmisc.sh | 15 +++++++++------ recipes/initscripts/initscripts_1.0.bb | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-)
recipes/initscripts/initscripts-1.0/bootmisc.sh +9 -6
@@ -69,12 +69,15 @@ fi test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start if test -e /etc/timestamp then - SYSTEMDATE=`date "+%Y%m%d"` - TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'` - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)` - if [ $NEEDUPDATE -eq 1 ]; then - date `cat /etc/timestamp` - /etc/init.d/hwclock.sh stop + if test "$DONTUSETIMESTAMP" != no + then + SYSTEMDATE=`date "+%Y%m%d"` + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'` + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)` + if [ $NEEDUPDATE -eq 1 ]; then + date `cat /etc/timestamp` + /etc/init.d/hwclock.sh stop + fi fi fi : exit 0
recipes/initscripts/initscripts_1.0.bb +1 -1
@@ -4,7 +4,7 @@ PRIORITY = "required" DEPENDS = "makedevs" RDEPENDS_${PN} = "makedevs" LICENSE = "GPL" -PR = "r124" +PR = "r125" SRC_URI = "file://functions \ file://halt \
Signature · 1 line
1.7.0.4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 4 lines · Petr Štetiar
This variable is useful on systems with battery backed RTC. Imagine, that the board is shut down and then switched on after, for example three days. Althought the value in RTC is correct, this scripts sets system time with the wrong values.
So you shut it down at 20101003 and boot it at 20101006, that should give you roughly:
SYSTEMDATE=date "+%Y%m%d" -> 20101006 TIMESTAMP=cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}' -> 20101003
NEEDUPDATE=expr \( $TIMESTAMP \> $SYSTEMDATE \) -> 0
So why is your rtc having a date older than the shutdown date?
regards,
Koen
Quoted 38 lines
Signed-off-by Petr Štetiar <[email protected]>--- recipes/initscripts/initscripts-1.0/bootmisc.sh | 15 +++++++++------ recipes/initscripts/initscripts_1.0.bb | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-)recipes/initscripts/initscripts-1.0/bootmisc.sh +9
-6@@ -69,12 +69,15 @@ fi test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start if test -e /etc/timestamp then - SYSTEMDATE=`date "+%Y%m%d"` - TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'` - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)` - if [ $NEEDUPDATE -eq 1 ]; then - date `cat /etc/timestamp` - /etc/init.d/hwclock.sh stop + if test "$DONTUSETIMESTAMP" != no + then + SYSTEMDATE=`date "+%Y%m%d"` + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'` + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)` + if [ $NEEDUPDATE -eq 1 ]; then + date `cat /etc/timestamp` + /etc/init.d/hwclock.sh stop + fi fi fi : exit 0recipes/initscripts/initscripts_1.0.bb +0
-0
recipes/initscripts/initscripts_1.0.bb PRIORITY = "required" · line 10
Quoted 8 lines
recipes/initscripts/initscripts_1.0.bb +1
-1@@ -4,7 +4,7 @@ PRIORITY = "required" DEPENDS = "makedevs" RDEPENDS_${PN} = "makedevs" LICENSE = "GPL" -PR = "r124" +PR = "r125" SRC_URI = "file://functions \ file://halt \
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFMrLJOMkyGM64RGpERAr5QAJ45x3QEvOpxYGWwO2xpqqcqhLE4SQCfWySh rKzUepwOYIYCXcK3PPiOuzQ=
=V/Ap
-----END PGP SIGNATURE-----
Koen Kooi <[email protected]> [2010-10-06 19:30:55]:
Quoted 12 lines
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 4 lines · Petr Štetiar
This variable is useful on systems with battery backed RTC. Imagine, that the board is shut down and then switched on after, for example three days. Althought the value in RTC is correct, this scripts sets system time with the wrong values.
So you shut it down at 20101003 and boot it at 20101006, that should give you roughly:
Quoted 7 lines
SYSTEMDATE=
date "+%Y%m%d"-> 20101006 TIMESTAMP=cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'-> 20101003NEEDUPDATE=
expr \( $TIMESTAMP \> $SYSTEMDATE \)-> 0So why is your rtc having a date older than the shutdown date?
Well, who knows, now it works and I see now, that the patch is wrong completly. Maybe it was connected to bbappend and following patches[1,2], sometimes it happens, that the package isn't rebuild even if I -c clean it. Thanks for the review, anyway. Removed the patch from the patchwork.
1. http://patchwork.openembedded.org/patch/3156
2. http://patchwork.openembedded.org/patch/3152
-- ynezz