876f172b8b
The script build-tools/update-pxe-network-installer allows one to add additional firmware files to the installer by specifying an environment variable, UPDATE_FW_LIST. This is inconvenient, because it requires the user to know the exact path to the firmware file to be included. Solution: search for files names "centos_firmware.inc" in the source tree and take firmware files from there. Story: 2010067 Task: 45529 Change-Id: I7673bd2c1bab4061936d8558a64f016a3661feec Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
198 lines
8.3 KiB
Bash
Executable File
198 lines
8.3 KiB
Bash
Executable File
#!/bin/bash -e
|
|
## this script is to update pxeboot images (vmlinuz, initrd.img and squashfs.img).
|
|
## based on RPMs generated by "build-pkgs" and "build-iso"
|
|
## created by Yong Hu (yong.hu@intel.com), 05/24/2018
|
|
|
|
# For backward compatibility. Old repo location or new?
|
|
CENTOS_REPO=${MY_REPO}/centos-repo
|
|
if [ ! -d ${CENTOS_REPO} ]; then
|
|
CENTOS_REPO=${MY_REPO}/cgcs-centos-repo
|
|
if [ ! -d ${CENTOS_REPO} ]; then
|
|
echo "ERROR: directory ${MY_REPO}/centos-repo not found."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
find_and_copy_rpm () {
|
|
local name="${1}"
|
|
local pattern="${2}"
|
|
local build_type="${3}"
|
|
local dest_dir="${4}"
|
|
local optional="${5}"
|
|
|
|
echo " --> find ${name} rpm"
|
|
found=$(find $MY_BUILD_DIR/${build_type}/rpmbuild/RPMS -type f -name "${pattern}" | head -n 1)
|
|
if [ ! -n "${found}" ];then
|
|
if [ "${build_type}" != "rt" ]; then
|
|
found=$(find ${CENTOS_REPO}/Binary -type l -name "${pattern}" | head -n 1)
|
|
else
|
|
found=$(find ${CENTOS_REPO}/${build_type}/Binary -type l -name "${pattern}" | head -n 1)
|
|
fi
|
|
fi
|
|
|
|
if [ -n "${found}" ] && [ -f "${found}" ];then
|
|
\cp -f "${found}" "${dest_dir}/"
|
|
elif [ -z "${optional}" ]; then
|
|
echo "ERROR: failed to find ${name} RPM!"
|
|
exit -1
|
|
fi
|
|
}
|
|
|
|
find_firmware() {
|
|
(
|
|
set -e
|
|
pattern="centos_firmware.inc"
|
|
cd $MY_REPO_ROOT_DIR
|
|
repo forall -c 'echo $REPO_PATH' \
|
|
| xargs -r -i find '{}' -mindepth 1 -maxdepth 1 -xtype f -name "$pattern" \
|
|
| xargs -r grep -E -v '^\s*(#.*)?$' \
|
|
| sort -u
|
|
)
|
|
}
|
|
|
|
echo "Start to update pxe-network-installer images .... "
|
|
timestamp=$(date +%F_%H%M)
|
|
cur_dir=$PWD
|
|
|
|
pxe_network_installer_dir=$MY_BUILD_DIR/pxe-network-installer
|
|
if [ ! -d $pxe_network_installer_dir ];then
|
|
mkdir -p $pxe_network_installer_dir
|
|
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
|
|
find_firmware >"${firmware_list_file}.tmp"
|
|
if [[ -s "${firmware_list_file}.tmp" ]] ; then
|
|
cat "${firmware_list_file}.tmp" >>"${firmware_list_file}"
|
|
fi
|
|
\rm -f "${firmware_list_file}.tmp"
|
|
if [[ -f "${firmware_list_file}" ]] ; then
|
|
echo "Including firmware files in installer:" >&2
|
|
cat "${firmware_list_file}" | sed -r 's/^/\t/' >&2
|
|
fi
|
|
|
|
cd $pxe_network_installer_dir
|
|
|
|
echo "step 1: copy original images: vmlinuz, initrd.img, squashfs.img"
|
|
orig_img_dir="orig"
|
|
if [ ! -d $orig_img_dir ];then
|
|
mkdir -p $orig_img_dir
|
|
fi
|
|
|
|
orig_initrd_img="${CENTOS_REPO}/Binary/images/pxeboot/initrd.img"
|
|
if [ -f $orig_initrd_img ]; then
|
|
cp -f $orig_initrd_img $pxe_network_installer_dir/$orig_img_dir/.
|
|
else
|
|
echo "$orig_initrd_img does not exit"
|
|
exit -1
|
|
fi
|
|
|
|
orig_squashfs_img="${CENTOS_REPO}/Binary/LiveOS/squashfs.img"
|
|
if [ -f $orig_squashfs_img ]; then
|
|
cp -f $orig_squashfs_img $pxe_network_installer_dir/$orig_img_dir/.
|
|
else
|
|
echo "$orig_squashfs_img does not exit"
|
|
exit -1
|
|
fi
|
|
|
|
echo ""
|
|
echo "step 2: prepare necessary kernel RPMs"
|
|
echo ""
|
|
kernel_rpms_std="$pxe_network_installer_dir/kernel-rpms/std"
|
|
kernel_rpms_rt="$pxe_network_installer_dir/kernel-rpms/rt"
|
|
|
|
echo "--> get $kernel_rpms_std ready"
|
|
echo "--> get $kernel_rpms_rt ready"
|
|
|
|
if [ -d $kernel_rpms_std ];then
|
|
mv $kernel_rpms_std $kernel_rpms_std-bak-$timestamp
|
|
fi
|
|
mkdir -p $kernel_rpms_std
|
|
|
|
if [ -d $kernel_rpms_rt ];then
|
|
mv $kernel_rpms_rt $kernel_rpms_rt-bak-$timestamp
|
|
fi
|
|
mkdir -p $kernel_rpms_rt
|
|
|
|
echo " -------- start to search standard kernel rpm and related kernel modules --------"
|
|
find_and_copy_rpm 'standard kernel' 'kernel-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'standard kernel core' 'kernel-core-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'standard kernel modules' 'kernel-modules-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'standard kernel modules extra' 'kernel-modules-extra-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'standard kernel modules internal' 'kernel-modules-internal-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'e1000e kernel module' 'kmod-e1000e-[0-9]*.x86_64.rpm' std "$kernel_rpms_std" optional
|
|
find_and_copy_rpm 'i40e kernel module' 'kmod-i40e-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'ixgbe kernel module' 'kmod-ixgbe-[0-9]*.x86_64.rpm' std "$kernel_rpms_std" optional
|
|
find_and_copy_rpm 'mlnx-ofa kernel module' 'mlnx-ofa_kernel-modules-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'ice kernel module' 'kmod-ice-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
find_and_copy_rpm 'bnxt_en kernel module' 'kmod-bnxt_en-[0-9]*.x86_64.rpm' std "$kernel_rpms_std"
|
|
echo " -------- successfully found standard kernel rpm and related kernel modules --------"
|
|
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"
|
|
if [ -d $rootfs_rpms ];then
|
|
mv $rootfs_rpms $rootfs_rpms-bak-$timestamp
|
|
fi
|
|
mkdir -p $rootfs_rpms
|
|
|
|
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-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-widgets' 'anaconda-widgets-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
find_and_copy_rpm 'rpm' 'rpm-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
find_and_copy_rpm 'rpm-build' 'rpm-build-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
find_and_copy_rpm 'rpm-build-libs' 'rpm-build-libs-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
find_and_copy_rpm 'rpm-libs' 'rpm-libs-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
find_and_copy_rpm 'rpm-plugin-systemd-inhibit' 'rpm-plugin-systemd-inhibit-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
find_and_copy_rpm 'rpm-python' 'rpm-python-[0-9]*.x86_64.rpm' installer "$rootfs_rpms/."
|
|
|
|
find_and_copy_rpm 'systemd' 'systemd-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
|
|
find_and_copy_rpm 'systemd-libs' 'systemd-libs-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
|
|
find_and_copy_rpm 'systemd-sysv' 'systemd-sysv-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
|
|
find_and_copy_rpm 'lz4' 'lz4-[0-9]*.x86_64.rpm' std "$rootfs_rpms/."
|
|
find_and_copy_rpm 'bind-utils' 'bind-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 "step 5: make installer images in this work dir"
|
|
same_folder="$(dirname ${BASH_SOURCE[0]})"
|
|
mk_images_tool="$same_folder/make-installer-images.sh"
|
|
sudo $mk_images_tool $pxe_network_installer_dir
|
|
|
|
cd $cur_dir
|
|
echo "updating pxe-network-installer images -- done!"
|