我的目标是,
- 为所有需要的文件创建
sha256
(进入.swu
) - 用算法签署
sw-description
文件。RSA
我的.swu
组成:
- 内核图像 -
bzImage
- 根文件系统 -
panther2-usb-panther2.ext4
- 软件描述文件 -
sw-description
- 安装后脚本 -
postinstall_swu.sh
我创建了一个生成sha256
和签名的脚本sw-description
。这是脚本:
#!/bin/bash
IMAGES="bzImage panther2-usb-panther2.ext4"
FILES="sw-description sw-description.sig postinstall_swu.sh $IMAGES"
echo "Executing swu signing script..."
cp ../sw-description .
cp ../postinstall_swu.sh .
cp ../../../../../deploy/images/panther2/bzImage .
cp ../../../../../deploy/images/panther2/panther2-usb-panther2.ext4 .
read -d ' ' SHA_ROOTFS < <(sha256sum panther2-usb-panther2.ext4)
read -d ' ' SHA_BZIMAGE < <(sha256sum bzImage)
read -d ' ' SHA_POSTINSTALL < <(sha256sum postinstall_swu.sh)
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_ROOTFS}"\"'/1' sw-description
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_BZIMAGE}"\"'/2' sw-description
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_POSTINSTALL}"\"'/3' sw-description
openssl dgst -sha256 -sign ../priv.pem -passin file:../passphrase sw-description > sw-description.sig
for i in $FILES;do
echo $i;done | cpio -ov -H crc > panther2-swu-$USER-devbuild.swu
cp panther2-swu-$USER-devbuild.swu ../../../../../deploy/images/panther2
上述方法更好吗?
有没有办法让 yocto/swupdate 层sha256
为所有上述文件(除了sw-description
)生成并将这些生成的文件添加sha256
到 sw-description 文件中?
sw-description
我可以通过在我的配方文件中定义SWUPDATE_SIGNING
和SWUPDATE_PRIVATE_KEY
变量来签名,但是
如何生成
sha256
?