image_type_phosphor: refactor signatures generation
There are duplicated code about generating signatures.
Combine the duplicated code into a bash function so the code is cleaner
and easier to read.
Tested: Generated tarball contains the expected files.
Change-Id: I4144633f36291329dfc4008bb73482fb5a0d43c1
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/classes/image_types_phosphor.bbclass b/classes/image_types_phosphor.bbclass
index 16e47dd..19422fc 100644
--- a/classes/image_types_phosphor.bbclass
+++ b/classes/image_types_phosphor.bbclass
@@ -222,15 +222,20 @@
u-boot:do_populate_sysroot \
"
+make_signatures() {
+ signature_files=""
+ for file in "$@"; do
+ openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file
+ signature_files="${signature_files} ${file}.sig"
+ done
+}
+
do_generate_static_alltar() {
ln -sf ${S}/MANIFEST MANIFEST
ln -sf ${S}/publickey publickey
ln -sf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.static.mtd image-bmc
- for file in image-bmc MANIFEST publickey; do
- openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file
- signature_files="${signature_files} ${file}.sig"
- done
+ make_signatures image-bmc MANIFEST publickey
tar -h -cvf ${IMGDEPLOYDIR}/${IMAGE_NAME}.static.mtd.all.tar \
image-bmc MANIFEST publickey ${signature_files}
@@ -284,10 +289,7 @@
ln -sf ${S}/MANIFEST MANIFEST
ln -sf ${S}/publickey publickey
make_image_links ${OVERLAY_BASETYPE} ${IMAGE_BASETYPE}
- for file in image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey; do
- openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file
- signature_files="${signature_files} ${file}.sig"
- done
+ make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
make_tar_of_images static MANIFEST publickey ${signature_files}
# Maintain non-standard legacy link.
@@ -309,10 +311,8 @@
ln -sf ${S}/MANIFEST MANIFEST
ln -sf ${S}/publickey publickey
make_image_links ${FLASH_UBI_OVERLAY_BASETYPE} ${FLASH_UBI_BASETYPE}
- for file in image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey; do
- openssl dgst -sha256 -sign ${SIGNING_KEY} -out "${file}.sig" $file
- done
- make_tar_of_images ubi MANIFEST publickey *.sig
+ make_signatures image-u-boot image-kernel image-rofs image-rwfs MANIFEST publickey
+ make_tar_of_images ubi MANIFEST publickey ${signature_files}
}
do_generate_ubi_tar[dirs] = " ${S}/ubi"
do_generate_ubi_tar[depends] += " \