diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2018-09-03 15:32:12 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-09-04 10:12:29 +0200 |
commit | 3e89818c3e637b9a6b88d2dbb79378b3b4bceac5 (patch) | |
tree | a8ad82d260c2cd69a6b90714ed273b424cca5c28 | |
parent | 413de4f2a59f62ad6b8a25c678ac4f2c62b63ab7 (diff) | |
download | barebox-3e89818c3e637b9a6b88d2dbb79378b3b4bceac5.tar.gz barebox-3e89818c3e637b9a6b88d2dbb79378b3b4bceac5.tar.xz |
scripts imx-image: add support for newer versions of "cst"
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | scripts/imx/imx-image.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index 452a544bc3..f7ca87bba2 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -558,7 +558,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; |