Re: [PATCH 5/5] scripts imx-image: add support for newer versions of "cst"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
>> ---
>>  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?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox

[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux