* [PATCH] initscripts: fix timestamp check at bootmisc.sh
@ 2011-12-08 7:07 Lauri Hintsala
2011-12-13 6:58 ` [PATCH v2] " Lauri Hintsala
2011-12-14 6:27 ` [PATCH v3] initscripts: fix timestamp checking " Lauri Hintsala
0 siblings, 2 replies; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-08 7:07 UTC (permalink / raw)
To: openembedded-core
cc: sgw@linux.intel.com
cc: gary@mlbassoc.com
Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
---
Hello guys,
It seems that timestamp checking has been broken by the commit
2078af333d704fd894a2dedbc19cef5775cdadbb. Some notes about following
lines.
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh:
/etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
SYSTEMDATE=`date -u +%2m%2d%2H%2M`
read TIMESTAMP < /etc/timestamp
# Remove year from timestamp.
TMP=`echo $TIMESTAMP | cut -c -8`
NEEDUPDATE=`expr \( $TMP \> $SYSTEMDATE + 10000 \)`
if [ $NEEDUPDATE -eq 1 ]; then
date -u $TIMESTAMP
/etc/init.d/hwclock.sh stop
fi
fi
1. Overflow happens in expr command of busybox if the length of number
is over 10 digits (now the length is 12 digits). This could be fixed
enabling flag CONFIG_EXPR_MATH_SUPPORT_64 from busybox config.
$ expr 120808302011 + 10000
-2147473649
2. Expression is adding +1 to minutes, not to days as supposed.
If that form is used "100000000" should be added instead of "10000".
3. The year is at the end of timestamp (last 4 least significant digits)
so it doesn't matter if it is there or not. So I decided to remove
year from the timestamp we are comparing. Then it is not needed to
attend to my note number 1.
BR,
Lauri Hintsala
---
.../initscripts/initscripts-1.0/bootmisc.sh | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 03fd67c..e97b5f8 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -67,10 +67,12 @@ fi
/etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
- SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
+ SYSTEMDATE=`date -u +%2m%2d%2H%2M`
read TIMESTAMP < /etc/timestamp
- NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
- if [ $NEEDUPDATE -eq 1 ]; then
+ # Remove year from timestamp.
+ TMP=`echo $TIMESTAMP | cut -c -8`
+ NEEDUPDATE=`expr \( $TMP \> $SYSTEMDATE + 10000 \)`
+ if [ $NEEDUPDATE -eq 1 ]; then
date -u $TIMESTAMP
/etc/init.d/hwclock.sh stop
fi
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-08 7:07 [PATCH] initscripts: fix timestamp check at bootmisc.sh Lauri Hintsala
@ 2011-12-13 6:58 ` Lauri Hintsala
2011-12-13 7:45 ` Koen Kooi
2011-12-13 12:26 ` Richard Purdie
2011-12-14 6:27 ` [PATCH v3] initscripts: fix timestamp checking " Lauri Hintsala
1 sibling, 2 replies; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-13 6:58 UTC (permalink / raw)
To: openembedded-core
Timestamp checking has been broken by the commit
2078af333d704fd894a2dedbc19cef5775cdadbb. Fix timestamp checking
and clean the code.
cc: sgw@linux.intel.com
cc: gary@mlbassoc.com
Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
---
.../initscripts/initscripts-1.0/bootmisc.sh | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 03fd67c..6d68b35 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -62,16 +62,16 @@ then
fi
# Set the system clock from hardware clock
-# If the timestamp is 1 day or more recent than the current time,
+# If the timestamp is more recent than the current time,
# use the timestamp instead.
/etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
- SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
- read TIMESTAMP < /etc/timestamp
- NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
- if [ $NEEDUPDATE -eq 1 ]; then
- date -u $TIMESTAMP
+ SYSTEMDATE=`date -u +%4Y%2m%2d`
+ TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4); }'`
+ NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)`
+ if [ $NEEDUPDATE -eq 1 ]; then
+ date -u `cat /etc/timestamp`
/etc/init.d/hwclock.sh stop
fi
fi
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 6:58 ` [PATCH v2] " Lauri Hintsala
@ 2011-12-13 7:45 ` Koen Kooi
2011-12-13 8:26 ` Lauri Hintsala
2011-12-13 12:26 ` Richard Purdie
1 sibling, 1 reply; 14+ messages in thread
From: Koen Kooi @ 2011-12-13 7:45 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
Cc: openembedded-core@lists.openembedded.org
Op 13 dec. 2011 om 07:58 heeft Lauri Hintsala <lauri.hintsala@bluegiga.com> het volgende geschreven:
> Timestamp checking has been broken by the commit
> 2078af333d704fd894a2dedbc19cef5775cdadbb. Fix timestamp checking
> and clean the code.
>
> cc: sgw@linux.intel.com
> cc: gary@mlbassoc.com
>
> Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
> ---
> .../initscripts/initscripts-1.0/bootmisc.sh | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 03fd67c..6d68b35 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -62,16 +62,16 @@ then
> fi
>
> # Set the system clock from hardware clock
> -# If the timestamp is 1 day or more recent than the current time,
> +# If the timestamp is more recent than the current time,
> # use the timestamp instead.
> /etc/init.d/hwclock.sh start
> if test -e /etc/timestamp
> then
> - SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
> - read TIMESTAMP < /etc/timestamp
> - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
> - if [ $NEEDUPDATE -eq 1 ]; then
> - date -u $TIMESTAMP
> + SYSTEMDATE=`date -u +%4Y%2m%2d`
> + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4); }'`
> + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)`
> + if [ $NEEDUPDATE -eq 1 ]; then
> + date -u `cat /etc/timestamp`
> /etc/init.d/hwclock.sh stop
> fi
> fi
This changes the format of timestamp, which breaks the code in image.bbclass.
Have a look at http://git.angstrom-distribution.org/cgi-bin/cgit.cgi/meta-angstrom/commit/?id=e003be8cba3d387f44a502fdbebf58e774afd677 for backwards compatible Logic
> --
> 1.7.4.1
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 7:45 ` Koen Kooi
@ 2011-12-13 8:26 ` Lauri Hintsala
0 siblings, 0 replies; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-13 8:26 UTC (permalink / raw)
To: openembedded-core
On 12/13/2011 09:45 AM, Koen Kooi wrote:
>
>
> Op 13 dec. 2011 om 07:58 heeft Lauri
> Hintsala<lauri.hintsala@bluegiga.com> het volgende geschreven:
>
>> Timestamp checking has been broken by the commit
>> 2078af333d704fd894a2dedbc19cef5775cdadbb. Fix timestamp checking
>> and clean the code.
>>
>> cc: sgw@linux.intel.com cc: gary@mlbassoc.com
>>
>> Signed-off-by: Lauri Hintsala<lauri.hintsala@bluegiga.com> ---
>> .../initscripts/initscripts-1.0/bootmisc.sh | 12
>> ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git
>> a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
>> b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh index
>> 03fd67c..6d68b35 100755 ---
>> a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh +++
>> b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh @@
>> -62,16 +62,16 @@ then fi
>>
>> # Set the system clock from hardware clock -# If the timestamp is 1
>> day or more recent than the current time, +# If the timestamp is
>> more recent than the current time, # use the timestamp instead.
>> /etc/init.d/hwclock.sh start if test -e /etc/timestamp then -
>> SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y` - read TIMESTAMP<
>> /etc/timestamp - NEEDUPDATE=`expr \( $TIMESTAMP \>
>> $SYSTEMDATE + 10000 \)` - if [ $NEEDUPDATE -eq 1 ]; then -
>> date -u $TIMESTAMP + SYSTEMDATE=`date -u +%4Y%2m%2d` +
>> TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4)
>> substr($0,1,4); }'` + NEEDUPDATE=`expr \( $TIMESTAMP \>
>> $SYSTEMDATE \)` + if [ $NEEDUPDATE -eq 1 ]; then + date
>> -u `cat /etc/timestamp` /etc/init.d/hwclock.sh stop fi fi
>
> This changes the format of timestamp, which breaks the code in
> image.bbclass.
No. Patch doesn't change the format of timestamp file. Format
"+%4Y%2m%2d" is used only for comparing system date and timestamp file.
> Have a look at
> http://git.angstrom-distribution.org/cgi-bin/cgit.cgi/meta-angstrom/commit/?id=e003be8cba3d387f44a502fdbebf58e774afd677
> for backwards compatible Logic
Timestamp file is still saved by save-rtc.sh script and it is untouched.
Lauri Hintsala
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 6:58 ` [PATCH v2] " Lauri Hintsala
2011-12-13 7:45 ` Koen Kooi
@ 2011-12-13 12:26 ` Richard Purdie
2011-12-13 12:36 ` Phil Blundell
1 sibling, 1 reply; 14+ messages in thread
From: Richard Purdie @ 2011-12-13 12:26 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Tue, 2011-12-13 at 08:58 +0200, Lauri Hintsala wrote:
> Timestamp checking has been broken by the commit
> 2078af333d704fd894a2dedbc19cef5775cdadbb. Fix timestamp checking
> and clean the code.
>
> cc: sgw@linux.intel.com
> cc: gary@mlbassoc.com
>
> Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
> ---
> .../initscripts/initscripts-1.0/bootmisc.sh | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 03fd67c..6d68b35 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -62,16 +62,16 @@ then
> fi
>
> # Set the system clock from hardware clock
> -# If the timestamp is 1 day or more recent than the current time,
> +# If the timestamp is more recent than the current time,
> # use the timestamp instead.
> /etc/init.d/hwclock.sh start
> if test -e /etc/timestamp
> then
> - SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
> - read TIMESTAMP < /etc/timestamp
> - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
> - if [ $NEEDUPDATE -eq 1 ]; then
> - date -u $TIMESTAMP
> + SYSTEMDATE=`date -u +%4Y%2m%2d`
> + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4); }'`
> + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)`
> + if [ $NEEDUPDATE -eq 1 ]; then
> + date -u `cat /etc/timestamp`
> /etc/init.d/hwclock.sh stop
> fi
> fi
For reference, the code in the boot process is trying not to cause
fork/exec calls. This is why it does:
read TIMESTAMP < /etc/timestamp
since this is faster than forking to run cat. Could we fix this in a
different way to avoid the fork/execs?
I appreciate this is a small detail but over the whole boot process it
mounts up!
Cheers,
Richard
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 12:26 ` Richard Purdie
@ 2011-12-13 12:36 ` Phil Blundell
2011-12-13 12:58 ` Lauri Hintsala
0 siblings, 1 reply; 14+ messages in thread
From: Phil Blundell @ 2011-12-13 12:36 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Tue, 2011-12-13 at 12:26 +0000, Richard Purdie wrote:
> On Tue, 2011-12-13 at 08:58 +0200, Lauri Hintsala wrote:
> > # Set the system clock from hardware clock
> > -# If the timestamp is 1 day or more recent than the current time,
> > +# If the timestamp is more recent than the current time,
> > # use the timestamp instead.
> > /etc/init.d/hwclock.sh start
> > if test -e /etc/timestamp
> > then
> > - SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
> > - read TIMESTAMP < /etc/timestamp
> > - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
> > - if [ $NEEDUPDATE -eq 1 ]; then
> > - date -u $TIMESTAMP
> > + SYSTEMDATE=`date -u +%4Y%2m%2d`
> > + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4); }'`
> > + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)`
> > + if [ $NEEDUPDATE -eq 1 ]; then
> > + date -u `cat /etc/timestamp`
> > /etc/init.d/hwclock.sh stop
> > fi
> > fi
>
>
> For reference, the code in the boot process is trying not to cause
> fork/exec calls. This is why it does:
>
> read TIMESTAMP < /etc/timestamp
>
> since this is faster than forking to run cat. Could we fix this in a
> different way to avoid the fork/execs?
For the same reason it would probably be nice to replace that call to
"expr" (which was in the old version too) with a shell expansion.
p.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 12:36 ` Phil Blundell
@ 2011-12-13 12:58 ` Lauri Hintsala
2011-12-13 13:07 ` Phil Blundell
0 siblings, 1 reply; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-13 12:58 UTC (permalink / raw)
To: openembedded-core
On 12/13/2011 02:36 PM, Phil Blundell wrote:
> On Tue, 2011-12-13 at 12:26 +0000, Richard Purdie wrote:
>> On Tue, 2011-12-13 at 08:58 +0200, Lauri Hintsala wrote:
>>> # Set the system clock from hardware clock
>>> -# If the timestamp is 1 day or more recent than the current time,
>>> +# If the timestamp is more recent than the current time,
>>> # use the timestamp instead.
>>> /etc/init.d/hwclock.sh start
>>> if test -e /etc/timestamp
>>> then
>>> - SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
>>> - read TIMESTAMP< /etc/timestamp
>>> - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
>>> - if [ $NEEDUPDATE -eq 1 ]; then
>>> - date -u $TIMESTAMP
>>> + SYSTEMDATE=`date -u +%4Y%2m%2d`
>>> + TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4); }'`
>>> + NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE \)`
>>> + if [ $NEEDUPDATE -eq 1 ]; then
>>> + date -u `cat /etc/timestamp`
>>> /etc/init.d/hwclock.sh stop
>>> fi
>>> fi
>>
>>
>> For reference, the code in the boot process is trying not to cause
>> fork/exec calls. This is why it does:
>>
>> read TIMESTAMP< /etc/timestamp
>>
>> since this is faster than forking to run cat. Could we fix this in a
>> different way to avoid the fork/execs?
>
> For the same reason it would probably be nice to replace that call to
> "expr" (which was in the old version too) with a shell expansion.
SYSTEMDATE=`date -u +%4Y%2m%2d`
TIMESTAMP=`awk '{ print substr($0,9,4) substr($0,1,4); }' < /etc/timestamp`
if [ $TIMESTAMP -gt $SYSTEMDATE ]; then
read TIMESTAMP < /etc/timestamp
date -u $TIMESTAMP
/etc/init.d/hwclock.sh stop
fi
How about this?
Lauri
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 12:58 ` Lauri Hintsala
@ 2011-12-13 13:07 ` Phil Blundell
2011-12-13 13:18 ` Lauri Hintsala
0 siblings, 1 reply; 14+ messages in thread
From: Phil Blundell @ 2011-12-13 13:07 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Tue, 2011-12-13 at 14:58 +0200, Lauri Hintsala wrote:
> SYSTEMDATE=`date -u +%4Y%2m%2d`
> TIMESTAMP=`awk '{ print substr($0,9,4) substr($0,1,4); }' < /etc/timestamp`
> if [ $TIMESTAMP -gt $SYSTEMDATE ]; then
> read TIMESTAMP < /etc/timestamp
> date -u $TIMESTAMP
> /etc/init.d/hwclock.sh stop
> fi
>
> How about this?
You could lose the call to "awk" as well:
read RAWTIMESTAMP < /etc/timestamp
TIMESTAMP=${RAWTIMESTAMP#????????}${RAWTIMESTAMP%????????}
Or, er, something like that. You might need to tweak the patterns a bit
depending on what exactly the format of /etc/timestamp actually is, but
I guess you get the idea.
p.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 13:07 ` Phil Blundell
@ 2011-12-13 13:18 ` Lauri Hintsala
2011-12-13 13:24 ` Phil Blundell
0 siblings, 1 reply; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-13 13:18 UTC (permalink / raw)
To: openembedded-core
On 12/13/2011 03:07 PM, Phil Blundell wrote:
> On Tue, 2011-12-13 at 14:58 +0200, Lauri Hintsala wrote:
>> SYSTEMDATE=`date -u +%4Y%2m%2d`
>> TIMESTAMP=`awk '{ print substr($0,9,4) substr($0,1,4); }'< /etc/timestamp`
>> if [ $TIMESTAMP -gt $SYSTEMDATE ]; then
>> read TIMESTAMP< /etc/timestamp
>> date -u $TIMESTAMP
>> /etc/init.d/hwclock.sh stop
>> fi
>>
>> How about this?
>
> You could lose the call to "awk" as well:
>
> read RAWTIMESTAMP< /etc/timestamp
> TIMESTAMP=${RAWTIMESTAMP#????????}${RAWTIMESTAMP%????????}
>
> Or, er, something like that. You might need to tweak the patterns a bit
> depending on what exactly the format of /etc/timestamp actually is, but
> I guess you get the idea.
Yes I got your idea and it seems to work. Thanks for your tips!
Second try:
SYSTEMDATE=`date -u +%4Y%2m%2d`
read TIMESTAMP < /etc/timestamp
if [ ${TIMESTAMP:8:4}${TIMESTAMP:0:4} -gt $SYSTEMDATE ]; then
date -u $TIMESTAMP
/etc/init.d/hwclock.sh stop
fi
Is this okay? Should I generate patch?
Lauri
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 13:18 ` Lauri Hintsala
@ 2011-12-13 13:24 ` Phil Blundell
2011-12-13 13:31 ` Henning Heinold
2011-12-13 13:40 ` Lauri Hintsala
0 siblings, 2 replies; 14+ messages in thread
From: Phil Blundell @ 2011-12-13 13:24 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Tue, 2011-12-13 at 15:18 +0200, Lauri Hintsala wrote:
> On 12/13/2011 03:07 PM, Phil Blundell wrote:
> > read RAWTIMESTAMP< /etc/timestamp
> > TIMESTAMP=${RAWTIMESTAMP#????????}${RAWTIMESTAMP%????????}
>
> Yes I got your idea and it seems to work. Thanks for your tips!
>
> Second try:
>
> SYSTEMDATE=`date -u +%4Y%2m%2d`
> read TIMESTAMP < /etc/timestamp
> if [ ${TIMESTAMP:8:4}${TIMESTAMP:0:4} -gt $SYSTEMDATE ]; then
> date -u $TIMESTAMP
> /etc/init.d/hwclock.sh stop
> fi
>
> Is this okay? Should I generate patch?
Is the "${var:X:Y}" substring notation part of POSIX? I have a feeling
that it might be a GNU extension, and it didn't seem to work in dash
when I tried it just now.
p.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 13:24 ` Phil Blundell
@ 2011-12-13 13:31 ` Henning Heinold
2011-12-13 13:40 ` Lauri Hintsala
1 sibling, 0 replies; 14+ messages in thread
From: Henning Heinold @ 2011-12-13 13:31 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Tue, Dec 13, 2011 at 01:24:47PM +0000, Phil Blundell wrote:
> On Tue, 2011-12-13 at 15:18 +0200, Lauri Hintsala wrote:
> > On 12/13/2011 03:07 PM, Phil Blundell wrote:
> > > read RAWTIMESTAMP< /etc/timestamp
> > > TIMESTAMP=${RAWTIMESTAMP#????????}${RAWTIMESTAMP%????????}
> >
> > Yes I got your idea and it seems to work. Thanks for your tips!
> >
> > Second try:
> >
> > SYSTEMDATE=`date -u +%4Y%2m%2d`
> > read TIMESTAMP < /etc/timestamp
> > if [ ${TIMESTAMP:8:4}${TIMESTAMP:0:4} -gt $SYSTEMDATE ]; then
> > date -u $TIMESTAMP
> > /etc/init.d/hwclock.sh stop
> > fi
> >
> > Is this okay? Should I generate patch?
>
> Is the "${var:X:Y}" substring notation part of POSIX? I have a feeling
> that it might be a GNU extension, and it didn't seem to work in dash
> when I tried it just now.
>
> p.
Substring using ${var:X:Y} is bash syntax as far as I know.
Bye Henning
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] initscripts: fix timestamp check at bootmisc.sh
2011-12-13 13:24 ` Phil Blundell
2011-12-13 13:31 ` Henning Heinold
@ 2011-12-13 13:40 ` Lauri Hintsala
1 sibling, 0 replies; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-13 13:40 UTC (permalink / raw)
To: openembedded-core
On 12/13/2011 03:24 PM, Phil Blundell wrote:
> Is the "${var:X:Y}" substring notation part of POSIX? I have a feeling
> that it might be a GNU extension, and it didn't seem to work in dash
> when I tried it just now.
I tested it in ash of busybox. I see it doesn't work in dash. So your
suggestion is the best I know.
Hopefully final version :)
SYSTEMDATE=`date -u +%4Y%2m%2d`
read TIMESTAMP < /etc/timestamp
if [ ${TIMESTAMP#????????}${TIMESTAMP%????????} -gt $SYSTEMDATE ]; then
date -u $TIMESTAMP
/etc/init.d/hwclock.sh stop
fi
Lauri
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3] initscripts: fix timestamp checking at bootmisc.sh
2011-12-08 7:07 [PATCH] initscripts: fix timestamp check at bootmisc.sh Lauri Hintsala
2011-12-13 6:58 ` [PATCH v2] " Lauri Hintsala
@ 2011-12-14 6:27 ` Lauri Hintsala
2011-12-15 19:17 ` Saul Wold
1 sibling, 1 reply; 14+ messages in thread
From: Lauri Hintsala @ 2011-12-14 6:27 UTC (permalink / raw)
To: openembedded-core
Timestamp checking has been broken by the commit
2078af333d704fd894a2dedbc19cef5775cdadbb. Currently the RTC time
is always overwritten with the time from /etc/timestmap. Fix timestamp
checking and clean the code.
Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
---
changes since V2
* reduce number of forks/execs
---
.../initscripts/initscripts-1.0/bootmisc.sh | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 03fd67c..ab18ad9 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -62,15 +62,14 @@ then
fi
# Set the system clock from hardware clock
-# If the timestamp is 1 day or more recent than the current time,
+# If the timestamp is more recent than the current time,
# use the timestamp instead.
/etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
- SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
+ SYSTEMDATE=`date -u +%4Y%2m%2d`
read TIMESTAMP < /etc/timestamp
- NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
- if [ $NEEDUPDATE -eq 1 ]; then
+ if [ ${TIMESTAMP#????????}${TIMESTAMP%????????} -gt $SYSTEMDATE ]; then
date -u $TIMESTAMP
/etc/init.d/hwclock.sh stop
fi
--
1.7.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v3] initscripts: fix timestamp checking at bootmisc.sh
2011-12-14 6:27 ` [PATCH v3] initscripts: fix timestamp checking " Lauri Hintsala
@ 2011-12-15 19:17 ` Saul Wold
0 siblings, 0 replies; 14+ messages in thread
From: Saul Wold @ 2011-12-15 19:17 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On 12/13/2011 10:27 PM, Lauri Hintsala wrote:
> Timestamp checking has been broken by the commit
> 2078af333d704fd894a2dedbc19cef5775cdadbb. Currently the RTC time
> is always overwritten with the time from /etc/timestmap. Fix timestamp
> checking and clean the code.
>
> Signed-off-by: Lauri Hintsala<lauri.hintsala@bluegiga.com>
>
> ---
> changes since V2
> * reduce number of forks/execs
> ---
> .../initscripts/initscripts-1.0/bootmisc.sh | 7 +++----
> 1 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 03fd67c..ab18ad9 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -62,15 +62,14 @@ then
> fi
>
> # Set the system clock from hardware clock
> -# If the timestamp is 1 day or more recent than the current time,
> +# If the timestamp is more recent than the current time,
> # use the timestamp instead.
> /etc/init.d/hwclock.sh start
> if test -e /etc/timestamp
> then
> - SYSTEMDATE=`date -u +%2m%2d%2H%2M%4Y`
> + SYSTEMDATE=`date -u +%4Y%2m%2d`
> read TIMESTAMP< /etc/timestamp
> - NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
> - if [ $NEEDUPDATE -eq 1 ]; then
> + if [ ${TIMESTAMP#????????}${TIMESTAMP%????????} -gt $SYSTEMDATE ]; then
> date -u $TIMESTAMP
> /etc/init.d/hwclock.sh stop
> fi
Merged into OE-Core
Thanks
Sau!
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-12-15 19:24 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-08 7:07 [PATCH] initscripts: fix timestamp check at bootmisc.sh Lauri Hintsala
2011-12-13 6:58 ` [PATCH v2] " Lauri Hintsala
2011-12-13 7:45 ` Koen Kooi
2011-12-13 8:26 ` Lauri Hintsala
2011-12-13 12:26 ` Richard Purdie
2011-12-13 12:36 ` Phil Blundell
2011-12-13 12:58 ` Lauri Hintsala
2011-12-13 13:07 ` Phil Blundell
2011-12-13 13:18 ` Lauri Hintsala
2011-12-13 13:24 ` Phil Blundell
2011-12-13 13:31 ` Henning Heinold
2011-12-13 13:40 ` Lauri Hintsala
2011-12-14 6:27 ` [PATCH v3] initscripts: fix timestamp checking " Lauri Hintsala
2011-12-15 19:17 ` Saul Wold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox