update-pxe-network-installer: add updated firmwares

* Add a step to add updated firmwares from firmware rpms
  into the initrd

* The selected firmware file list will be provided through
  env variable UPDATE_FW_LIST.

* example usage:

echo "./usr/lib/firmware/fw1" > firmware-list
echo "./usr/lib/firmware/fw2" >> firmware-list
export UPDATE_FW_LIST="./firmware-list"
update-pxe-network-installer

Test Plan:

PASS: Add the firmware file location with the command:
echo "./usr/lib/firmware/qed/qed_init_values_zipped-8.42.2.0.bin" >> firmware-list
export UPDATE_FW_LIST="./firmware-list"
update-pxe-network-installer

Story: 2010046
Task: 45420

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
Signed-off-by: Thiago Miranda <ThiagoOliveira.Miranda@windriver.com>
Change-Id: Ifbe18d1aedc6ece4891c35627448c21fdf3306f3
This commit is contained in:
Jackie Huang 2022-03-01 21:05:14 -05:00 committed by Daian Cardoso Sganderlla
parent a54eff308e
commit c8c31ba805
2 changed files with 53 additions and 2 deletions

View File

@ -68,6 +68,14 @@ if [ ! -d $kernel_rpms_dir ];then
exit -1 exit -1
fi fi
firmware_rpms_dir=${work_dir}/firmware-rpms
if [ ! -d ${firmware_rpms_dir} ];then
echo "ERROR: ${firmware_rpms_dir} does NOT exist!"
exit -1
fi
firmware_list_file=${work_dir}/firmware-list
initrd_root=$work_dir/initrd.work initrd_root=$work_dir/initrd.work
if [ -d $initrd_root ];then if [ -d $initrd_root ];then
rm -rf $initrd_root rm -rf $initrd_root
@ -85,6 +93,13 @@ clean_rootfs $initrd_root
echo "--> extract files from new kernel and its modular rpms to initrd root" echo "--> extract files from new kernel and its modular rpms to initrd root"
for kf in ${kernel_rpms_dir}/std/*.rpm ; do rpm2cpio $kf | cpio -idu; done for kf in ${kernel_rpms_dir}/std/*.rpm ; do rpm2cpio $kf | cpio -idu; done
echo "--> extract files from new firmware rpms to initrd root"
if [ -f ${firmware_list_file} ]; then
echo "--> extract files from new firmware rpm to initrd root"
firmware_list=`cat ${firmware_list_file}`
for fw in ${firmware_rpms_dir}/std/*.rpm ; do rpm2cpio ${fw} | cpio -iduv ${firmware_list}; done
fi
# by now new kernel and its modules exist! # by now new kernel and its modules exist!
# find new kernel in /boot/vmlinuz-* or /lib/modules/*/vmlinuz # find new kernel in /boot/vmlinuz-* or /lib/modules/*/vmlinuz
echo "--> get new kernel image: vmlinuz" echo "--> get new kernel image: vmlinuz"

View File

@ -48,6 +48,14 @@ if [ ! -d $pxe_network_installer_dir ];then
mkdir -p $pxe_network_installer_dir mkdir -p $pxe_network_installer_dir
fi fi
firmware_list_file=${pxe_network_installer_dir}/firmware-list
if [ -f ${firmware_list_file} ]; then
mv ${firmware_list_file} ${firmware_list_file}-bak-${timestamp}
fi
if [ -n "${UPDATE_FW_LIST}" ] && [ -f "${UPDATE_FW_LIST}" ]; then
cp -f ${UPDATE_FW_LIST} ${firmware_list_file}
fi
cd $pxe_network_installer_dir cd $pxe_network_installer_dir
echo "step 1: copy original images: vmlinuz, initrd.img, squashfs.img" echo "step 1: copy original images: vmlinuz, initrd.img, squashfs.img"
@ -106,13 +114,41 @@ find_and_copy_rpm 'bnxt_en kernel module' 'kmod-bnxt_en-[0-9]*.x86_64
echo " -------- successfully found standard kernel rpm and related kernel modules --------" echo " -------- successfully found standard kernel rpm and related kernel modules --------"
echo "" echo ""
echo "step 3: prepare necessary firmware RPMs"
mkdir -p ${pxe_network_installer_dir}/firmware-rpms
if [ -f "${firmware_list_file}" ]; then
firmware_rpms_std="${pxe_network_installer_dir}/firmware-rpms/std"
firmware_rpms_rt="${pxe_network_installer_dir}/firmware-rpms/rt"
echo "--> get ${firmware_rpms_std} ready"
echo "--> get ${firmware_rpms_rt} ready"
if [ -d ${firmware_rpms_std} ];then
mv ${firmware_rpms_std} ${firmware_rpms_std}-bak-${timestamp}
fi
mkdir -p ${firmware_rpms_std}
if [ -d ${firmware_rpms_rt} ];then
mv ${firmware_rpms_rt} ${firmware_rpms_rt}-bak-${timestamp}
fi
mkdir -p ${firmware_rpms_rt}
echo " -------- start to search standard firmware rpm -------"
find_and_copy_rpm 'standard firmware' 'linux-firmware-[0-9]*.noarch.rpm' std "${firmware_rpms_std}"
echo " -------- successfully found standard firmware rpm --------"
echo ""
fi
rootfs_rpms="$pxe_network_installer_dir/rootfs-rpms" rootfs_rpms="$pxe_network_installer_dir/rootfs-rpms"
if [ -d $rootfs_rpms ];then if [ -d $rootfs_rpms ];then
mv $rootfs_rpms $rootfs_rpms-bak-$timestamp mv $rootfs_rpms $rootfs_rpms-bak-$timestamp
fi fi
mkdir -p $rootfs_rpms mkdir -p $rootfs_rpms
echo " step 3: start to search rpms for rootfs" echo "step 4: start to search rpms for rootfs"
find_and_copy_rpm 'anaconda' 'anaconda-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/." find_and_copy_rpm 'anaconda' 'anaconda-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'anaconda-core' 'anaconda-core-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/." find_and_copy_rpm 'anaconda-core' 'anaconda-core-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
find_and_copy_rpm 'anaconda-tui' 'anaconda-tui-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/." find_and_copy_rpm 'anaconda-tui' 'anaconda-tui-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
@ -132,7 +168,7 @@ find_and_copy_rpm 'bind-utils' 'bind-utils-[0-9]*.x86_64.rpm' std "$rootfs
find_and_copy_rpm 'ima-evm-utils' 'ima-evm-utils-[0-9]*.x86_64.rpm' std "$rootfs_rpms/." find_and_copy_rpm 'ima-evm-utils' 'ima-evm-utils-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
echo " ---------------- successfully found rpms for rootfs --------------------------------" echo " ---------------- successfully found rpms for rootfs --------------------------------"
echo "step 4: make installer images in this work dir" echo "step 5: make installer images in this work dir"
same_folder="$(dirname ${BASH_SOURCE[0]})" same_folder="$(dirname ${BASH_SOURCE[0]})"
mk_images_tool="$same_folder/make-installer-images.sh" mk_images_tool="$same_folder/make-installer-images.sh"
sudo $mk_images_tool $pxe_network_installer_dir sudo $mk_images_tool $pxe_network_installer_dir