From: Sascha Hauer <sha@pengutronix.de>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/5] scripts imx-image: add support for newer versions of "cst"
Date: Wed, 29 Aug 2018 09:59:56 +0200 [thread overview]
Message-ID: <20180829075956.dhvqllkjn7sb2krr@pengutronix.de> (raw)
In-Reply-To: <00108338-e1f4-f25a-79fa-070342c2cb3e@pengutronix.de>
On Wed, Aug 29, 2018 at 09:29:25AM +0200, Marc Kleine-Budde wrote:
> On 08/29/2018 09:15 AM, Sascha Hauer wrote:
> > On Mon, Aug 27, 2018 at 05:14:28PM +0200, Marc Kleine-Budde wrote:
> >> Older versions of "cst" want to read the CSF frm STDIN, while newer versions
> >> want to read the CSF from a file. Sadly, the "-i" option doesn't understand
> >> "-i -" to read from STDIN, so we give it "/dev/stdin" instead.
> >>
> >> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> >> ---
> >> scripts/imx/imx-image.c | 16 +++++++++++++++-
> >> 1 file changed, 15 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
> >> index 452a544bc3eb..17d504586967 100644
> >> --- a/scripts/imx/imx-image.c
> >> +++ b/scripts/imx/imx-image.c
> >> @@ -558,7 +558,21 @@ static int hab_sign(struct config_data *data)
> >> }
> >> }
> >>
> >> - ret = asprintf(&command, "%s -o %s", cst, csffile);
> >> + /*
> >> + * Older versions of "cst" want to read the CSF frm STDIN,
> >> + * while newer versions want to read the CSF from a
> >> + * file. Sadly, the "-i" option doesn't understand "-i -" to
> >> + * read from STDIN, so we give it "/dev/stdin" instead.
> >> + */
> >> + ret = asprintf(&command,
> >> + "if %s | grep 'Input CSF text filename'; then"
> >> + " %s -o %s -i /dev/stdin;"
> >> + "else"
> >> + " %s -o %s;"
> >> + "fi",
> >> + cst,
> >> + cst, csffile,
> >> + cst, csffile);
> >
> > Could you separate the cst calling convention detection from the actual
> > call, so effectively do the if/else in C rather than shell? That would
> > give us a place to add a debug printf and say which way we actually call
> > the cst tool and it will be slightly less magical when something goes
> > wrong.
>
> Makes sense. Do the "cst | grep" in one shell and evaluate the return
> value, do the if else in C and then do the proper shell call?
Yes.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-29 8:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-27 15:14 [PATCH 0/5] i.MX habv4: decode error/warning events and support new CST version Marc Kleine-Budde
2018-08-27 15:14 ` [PATCH 1/5] i.MX habv4: properly indent defines and enums Marc Kleine-Budde
2018-08-27 15:14 ` [PATCH 2/5] i.MX habv4: convert habv4_get_status() and habv4_display_event() from printf to pr_err() Marc Kleine-Budde
2018-08-27 15:14 ` [PATCH 3/5] i.MX habv4: habv4_get_status(): display warning events, too Marc Kleine-Budde
2018-08-27 15:14 ` [PATCH 4/5] i.MX habv4: habv4_display_event_record(): Add function to decode event record Marc Kleine-Budde
2018-08-27 15:14 ` [PATCH 5/5] scripts imx-image: add support for newer versions of "cst" Marc Kleine-Budde
2018-08-29 7:15 ` Sascha Hauer
2018-08-29 7:29 ` Marc Kleine-Budde
2018-08-29 7:59 ` Sascha Hauer [this message]
2018-08-29 7:17 ` [PATCH 0/5] i.MX habv4: decode error/warning events and support new CST version Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180829075956.dhvqllkjn7sb2krr@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=mkl@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox