* [PATCH v2] scripts imx-image: add support for newer versions of "cst"
@ 2018-09-03 13:32 Marc Kleine-Budde
2018-09-04 8:12 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2018-09-03 13:32 UTC (permalink / raw)
To: barebox; +Cc: sha
Older versions of "cst" want to read the CSF from 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 | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index b241e8c4b68e..ffde8149650f 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -546,7 +546,28 @@ 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 from 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,
+ "%s | grep 'Input CSF text filename'",
+ cst);
+ if (ret < 0)
+ return -ENOMEM;
+
+ ret = system(command);
+ free(command);
+ if (ret == -1)
+ return -EINVAL;
+ else if (ret == 0)
+ ret = asprintf(&command, "%s -o %s -i /dev/stdin",
+ cst, csffile);
+ else
+ ret = asprintf(&command, "%s -o %s;",
+ cst, csffile);
if (ret < 0)
return -ENOMEM;
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] scripts imx-image: add support for newer versions of "cst"
2018-09-03 13:32 [PATCH v2] scripts imx-image: add support for newer versions of "cst" Marc Kleine-Budde
@ 2018-09-04 8:12 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-09-04 8:12 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: barebox
On Mon, Sep 03, 2018 at 03:32:12PM +0200, Marc Kleine-Budde wrote:
> Older versions of "cst" want to read the CSF from 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 | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
> index b241e8c4b68e..ffde8149650f 100644
> --- a/scripts/imx/imx-image.c
> +++ b/scripts/imx/imx-image.c
> @@ -546,7 +546,28 @@ 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 from 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,
> + "%s | grep 'Input CSF text filename'",
> + cst);
> + if (ret < 0)
> + return -ENOMEM;
> +
> + ret = system(command);
> + free(command);
> + if (ret == -1)
> + return -EINVAL;
> + else if (ret == 0)
> + ret = asprintf(&command, "%s -o %s -i /dev/stdin",
> + cst, csffile);
> + else
> + ret = asprintf(&command, "%s -o %s;",
> + cst, csffile);
> if (ret < 0)
> return -ENOMEM;
>
> --
> 2.18.0
>
>
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-04 8:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-03 13:32 [PATCH v2] scripts imx-image: add support for newer versions of "cst" Marc Kleine-Budde
2018-09-04 8:12 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox