* [PATCH] initscripts: fix bashism in bootmisc.sh
@ 2014-07-23 14:49 Ben Shelton
2014-07-23 15:41 ` Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Ben Shelton @ 2014-07-23 14:49 UTC (permalink / raw)
To: openembedded-core
In the commit 'initscripts: save /etc/timestamp with seconds accuracy',
a bashism was introduced in the bootmisc.sh script in the code to set
the current date from the stored value in /etc/timestamp. This causes
that operation to fail with the following message when /bin/sh is not
bash:
/etc/init.d/rc: /etc/rcS.d/S55bootmisc.sh: line 73: syntax error: bad substitution
Fixed by using 'cut' (standard under POSIX) rather than bash-specific
substring expansion.
[YOCTO #6566]
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
Tested-by: Maxin B. John <maxin.john@enea.com>
---
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index ccc7f9f..923fa88 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -70,7 +70,10 @@ then
read TIMESTAMP < /etc/timestamp
if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
# format the timestamp as date expects it (2m2d2H2M4Y.2S)
- date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
+ TS_YR=$(echo $TIMESTAMP | cut -c 1-4)
+ TS_SEC=$(echo $TIMESTAMP | cut -c 13-14)
+ TS_REST=$(echo $TIMESTAMP | cut -c 5-12)
+ date -u ${TS_REST}${TS_YR}.${TS_SEC}
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
fi
fi
--
2.0.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] initscripts: fix bashism in bootmisc.sh
2014-07-23 14:49 [PATCH] initscripts: fix bashism in bootmisc.sh Ben Shelton
@ 2014-07-23 15:41 ` Richard Purdie
2014-07-23 16:16 ` Christopher Larson
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2014-07-23 15:41 UTC (permalink / raw)
To: Ben Shelton; +Cc: openembedded-core
On Wed, 2014-07-23 at 09:49 -0500, Ben Shelton wrote:
> In the commit 'initscripts: save /etc/timestamp with seconds accuracy',
> a bashism was introduced in the bootmisc.sh script in the code to set
> the current date from the stored value in /etc/timestamp. This causes
> that operation to fail with the following message when /bin/sh is not
> bash:
>
> /etc/init.d/rc: /etc/rcS.d/S55bootmisc.sh: line 73: syntax error: bad substitution
>
> Fixed by using 'cut' (standard under POSIX) rather than bash-specific
> substring expansion.
>
> [YOCTO #6566]
>
> Signed-off-by: Ben Shelton <ben.shelton@ni.com>
> Tested-by: Maxin B. John <maxin.john@enea.com>
> ---
> meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index ccc7f9f..923fa88 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -70,7 +70,10 @@ then
> read TIMESTAMP < /etc/timestamp
> if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
> # format the timestamp as date expects it (2m2d2H2M4Y.2S)
> - date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
> + TS_YR=$(echo $TIMESTAMP | cut -c 1-4)
> + TS_SEC=$(echo $TIMESTAMP | cut -c 13-14)
> + TS_REST=$(echo $TIMESTAMP | cut -c 5-12)
> + date -u ${TS_REST}${TS_YR}.${TS_SEC}
> test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
> fi
> fi
We have tried hard to remove exec/fork/subshell calls from the init
processes since each one does cost quite some time. The above introduces
more than I'm comfortable with. Can we find some other way to do this
please?
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] initscripts: fix bashism in bootmisc.sh
2014-07-23 15:41 ` Richard Purdie
@ 2014-07-23 16:16 ` Christopher Larson
0 siblings, 0 replies; 3+ messages in thread
From: Christopher Larson @ 2014-07-23 16:16 UTC (permalink / raw)
To: Richard Purdie; +Cc: Patches and discussions about the oe-core layer
[-- Attachment #1: Type: text/plain, Size: 2398 bytes --]
On Wed, Jul 23, 2014 at 8:41 AM, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:
> On Wed, 2014-07-23 at 09:49 -0500, Ben Shelton wrote:
> > In the commit 'initscripts: save /etc/timestamp with seconds accuracy',
> > a bashism was introduced in the bootmisc.sh script in the code to set
> > the current date from the stored value in /etc/timestamp. This causes
> > that operation to fail with the following message when /bin/sh is not
> > bash:
> >
> > /etc/init.d/rc: /etc/rcS.d/S55bootmisc.sh: line 73: syntax error: bad
> substitution
> >
> > Fixed by using 'cut' (standard under POSIX) rather than bash-specific
> > substring expansion.
> >
> > [YOCTO #6566]
> >
> > Signed-off-by: Ben Shelton <ben.shelton@ni.com>
> > Tested-by: Maxin B. John <maxin.john@enea.com>
> > ---
> > meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> > index ccc7f9f..923fa88 100755
> > --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> > +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> > @@ -70,7 +70,10 @@ then
> > read TIMESTAMP < /etc/timestamp
> > if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
> > # format the timestamp as date expects it (2m2d2H2M4Y.2S)
> > - date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
> > + TS_YR=$(echo $TIMESTAMP | cut -c 1-4)
> > + TS_SEC=$(echo $TIMESTAMP | cut -c 13-14)
> > + TS_REST=$(echo $TIMESTAMP | cut -c 5-12)
> > + date -u ${TS_REST}${TS_YR}.${TS_SEC}
> > test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh
> stop
> > fi
> > fi
>
> We have tried hard to remove exec/fork/subshell calls from the init
> processes since each one does cost quite some time. The above introduces
> more than I'm comfortable with. Can we find some other way to do this
> please?
Hmm, worst case it looks like a single sed script would do, assuming
there's no way to get date -u to be more flexible.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
[-- Attachment #2: Type: text/html, Size: 3161 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-23 16:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 14:49 [PATCH] initscripts: fix bashism in bootmisc.sh Ben Shelton
2014-07-23 15:41 ` Richard Purdie
2014-07-23 16:16 ` Christopher Larson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.