#!/bin/bash -e ## this script is to update pxeboot images (vmlinuz, initrd.img and install.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}" 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}/" else echo "ERROR: failed to find ${name} RPM!" exit -1 fi } 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 cd $pxe_network_installer_dir echo "step 1: copy original images: vmlinuz, initrd.img, install.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/images/install.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" 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" find_and_copy_rpm 'mlnx-ofa kernel module' 'mlnx-ofa_kernel-modules-[0-9]*.x86_64.rpm' std "$kernel_rpms_std" echo " -------- successfully found standard kernel rpm and related kernel modules --------" echo "" 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 3: 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 'python3-rpm' 'python3-rpm-[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 4: 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!"