root/build-tools/update-pxe-network-installer
Dean Troyer cfe45dadae StarlingX open source release updates
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2018-06-01 07:45:23 -07:00

397 lines
13 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
kernel_mode=0
for arg in "$@"; do
case "$1" in
--std) kernel_mode=0 ;;
--rt) kernel_mode=1 ;;
--help) echo "Update pxe-network-installer images";
echo "$(basename $0) --std for standard kernel mode, or"
echo "$(basename $0) --rt for realtime kernel mode";
exit 0;;
*) echo "unknown argument";
exit 1;;
esac
done
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, squashfs.img"
CENTOS_REPO="cgcs-centos-repo"
orig_img_dir="orig"
if [ ! -d $orig_img_dir ];then
mkdir -p $orig_img_dir
fi
orig_kernel_img="$MY_REPO/$CENTOS_REPO/Binary/images/pxeboot/vmlinuz"
if [ -f $orig_kernel_img ]; then
cp -f $orig_kernel_img $pxe_network_installer_dir/$orig_img_dir/.
else
echo "$orig_kernel_img does not exit"
exit -1
fi
orig_initrd_img="$MY_REPO/$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="$MY_REPO/$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 --------"
echo " --> find standard kernel rpm"
std_kernel=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages/ -type f -name "kernel-[0-9]*.x86_64.rpm")
if [ -n $std_kernel ] && [ -f $std_kernel ];then
cp -f $std_kernel $kernel_rpms_std/.
else
echo "ERROR: failed to find kernel RPM!"
exit -1
fi
echo "--> find e1000e kernel module"
e1000e_module=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "kmod-e1000e-[0-9]*.x86_64.rpm")
if [ -n $e1000e_module ] && [ -f $e1000e_module ];then
cp -f $e1000e_module $kernel_rpms_std/.
else
echo "ERROR: failed to find e1000e kernel module RPM!"
exit -1
fi
echo "--> find i40e kernel module"
i40e_module=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "kmod-i40e-[0-9]*.x86_64.rpm")
if [ -n $i40e_module ] && [ -f $i40e_module ];then
cp -f $i40e_module $kernel_rpms_std/.
else
echo "ERROR: failed to find i40e kernel module RPM!"
exit -1
fi
echo "--> find ixgbe kernel module"
ixgbe_module=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "kmod-ixgbe-[0-9]*.x86_64.rpm")
if [ -n $ixgbe_module ] && [ -f $ixgbe_module ];then
cp -f $ixgbe_module $kernel_rpms_std/.
else
echo "ERROR: failed to find ixgbe kernel module RPM!"
exit -1
fi
echo "--> find tpm kernel module"
tpm_module=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "kmod-tpm-[0-9]*.x86_64.rpm")
if [ -n $tpm_module ] && [ -f $tpm_module ];then
cp -f $tpm_module $kernel_rpms_std/.
else
echo "ERROR: failed to find tpm kernel module RPM!"
exit -1
fi
echo "--> find mlnx-ofa_kernel"
mlnx_ofa_kernel=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "mlnx-ofa_kernel-[0-9]*.x86_64.rpm")
if [ -n $mlnx_ofa_kernel ] && [ -f $mlnx_ofa_kernel ];then
cp -f $mlnx_ofa_kernel $kernel_rpms_std/.
else
echo "ERROR: failed to find mlnx-ofa_kernel module RPM!"
exit -1
fi
echo "--> find mlnx-ofa_kernel-devel"
mlnx_ofa_kernel_devel=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "mlnx-ofa_kernel-devel-[0-9]*.x86_64.rpm")
if [ -n $mlnx_ofa_kernel_devel ] && [ -f $mlnx_ofa_kernel_devel ];then
cp -f $mlnx_ofa_kernel_devel $kernel_rpms_std/.
else
echo "ERROR: failed to find mlnx-ofa_kernel-devel module RPM!"
exit -1
fi
echo "--> find mlnx-ofa_kernel_modules"
mlnx_ofa_kernel_modules=$(find $MY_BUILD_DIR/std/rpmbuild/RPMS -type f -name "mlnx-ofa_kernel-modules-[0-9]*.x86_64.rpm")
if [ -n $mlnx_ofa_kernel_modules ] && [ -f $mlnx_ofa_kernel_modules ];then
cp -f $mlnx_ofa_kernel_modules $kernel_rpms_std/.
else
echo "ERROR: failed to find mlnx-ofa_kernel-modules RPM!"
exit -1
fi
echo " -------- successfully found standard kernel rpm and related kernel modules --------"
echo ""
echo ""
echo " -------- start to search realtime kernel rpm and related kernel modules --------"
echo "--> find realtime kernel rpm"
rt_kernel=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages/ -type f -name "kernel-rt-[0-9]*.rpm")
if [ -n $rt_kernel ] && [ -f $rt_kernel ];then
cp -f $rt_kernel $kernel_rpms_rt/.
else
echo "ERROR: failed to find realtime kernel RPM!"
exit -1
fi
echo "--> find realtime e1000e kernel module"
rt_e1000e_module=$(find $MY_BUILD_DIR/rt/rpmbuild/RPMS -type f -name "kmod-e1000e-rt-[0-9]*.x86_64.rpm")
if [ -n $rt_e1000e_module ] && [ -f $rt_e1000e_module ];then
cp -f $rt_e1000e_module $kernel_rpms_rt/.
else
echo "ERROR: failed to find realtime e1000e kernel module RPM!"
exit -1
fi
echo "--> find realtime i40e kernel module"
rt_i40e_module=$(find $MY_BUILD_DIR/rt/rpmbuild/RPMS -type f -name "kmod-i40e-rt-[0-9]*.x86_64.rpm")
if [ -n $rt_i40e_module ] && [ -f $rt_i40e_module ];then
cp -f $rt_i40e_module $kernel_rpms_rt/.
else
echo "ERROR: failed to find realtime i40e kernel module RPM!"
exit -1
fi
echo "--> find realtime ixgbe kernel module"
rt_ixgbe_module=$(find $MY_BUILD_DIR/rt/rpmbuild/RPMS -type f -name "kmod-ixgbe-rt-[0-9]*.x86_64.rpm")
if [ -n $rt_ixgbe_module ] && [ -f $rt_ixgbe_module ];then
cp -f $rt_ixgbe_module $kernel_rpms_rt/.
else
echo "ERROR: failed to find realtime ixgbe kernel module RPM!"
exit -1
fi
echo "--> find realtime tpm kernel module"
rt_tpm_module=$(find $MY_BUILD_DIR/rt/rpmbuild/RPMS -type f -name "kmod-tpm-rt-[0-9]*.x86_64.rpm")
if [ -n $rt_tpm_module ] && [ -f $rt_tpm_module ];then
cp -f $rt_tpm_module $kernel_rpms_rt/.
else
echo "ERROR: failed to find realtime tpm kernel module RPM!"
exit -1
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 " -------- successfully found realtime kernel rpm and related kernel modules --------"
echo ""
echo " step 3: start to search rpms for rootfs"
echo "--> find anaconda rpm"
anaconda=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-[0-9]*.x86_64.rpm")
if [ -n $anaconda ] && [ -f $anaconda ];then
cp -f $anaconda $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda RPM!"
exit -1
fi
echo "--> find anaconda-core rpm"
anaconda_core=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-core-[0-9]*.x86_64.rpm")
if [ -n $anaconda_core ] && [ -f $anaconda_core ];then
cp -f $anaconda_core $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-core RPM!"
exit -1
fi
echo "--> find anaconda-debuginfo rpm"
anaconda_debuginfo=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-debuginfo-[0-9]*.x86_64.rpm")
if [ -n $anaconda_debuginfo ] && [ -f $anaconda_debuginfo ];then
cp -f $anaconda_debuginfo $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-debuginfo RPM!"
exit -1
fi
echo "--> find anaconda-dracut rpm"
anaconda_dracut=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-dracut-[0-9]*.x86_64.rpm")
if [ -n $anaconda_dracut ] && [ -f $anaconda_dracut ];then
cp -f $anaconda_dracut $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-dracut RPM!"
exit -1
fi
echo "--> find anaconda-gui rpm"
anaconda_gui=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-gui-[0-9]*.x86_64.rpm")
if [ -n $anaconda_gui ] && [ -f $anaconda_gui ];then
cp -f $anaconda_gui $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-gui RPM!"
exit -1
fi
echo "--> find anaconda-tui rpm"
anaconda_tui=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-tui-[0-9]*.x86_64.rpm")
if [ -n $anaconda_tui ] && [ -f $anaconda_tui ];then
cp -f $anaconda_tui $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-tui RPM!"
exit -1
fi
echo "--> find anaconda-widgets rpm"
anaconda_widgets=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-widgets-[0-9]*.x86_64.rpm")
if [ -n $anaconda_widgets ] && [ -f $anaconda_widgets ];then
cp -f $anaconda_widgets $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-widgets RPM!"
exit -1
fi
echo "--> find anaconda-widgets-devel rpm"
anaconda_widgets_devel=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "anaconda-widgets-devel-[0-9]*.x86_64.rpm")
if [ -n $anaconda_widgets_devel ] && [ -f $anaconda_widgets_devel ];then
cp -f $anaconda_widgets_devel $rootfs_rpms/.
else
echo "ERROR: failed to find anaconda-widgets-devel RPM!"
exit -1
fi
echo "--> find rpm-xx.x86_64 rpm"
rpm_rpm=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "rpm-[0-9]*.x86_64.rpm")
if [ -n $rpm_rpm ] && [ -f $rpm_rpm ];then
cp -f $rpm_rpm $rootfs_rpms/.
else
echo "ERROR: failed to find rpm-xx.x86_64 RPM!"
exit -1
fi
echo "--> find rpm-build rpm"
rpm_build=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "rpm-build-[0-9]*.x86_64.rpm")
if [ -n $rpm_build ] && [ -f $rpm_build ];then
cp -f $rpm_build $rootfs_rpms/.
else
echo "ERROR: failed to find rpm-build RPM!"
exit -1
fi
echo "--> find rpm-build-libs rpm"
rpm_build_libs=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "rpm-build-libs-[0-9]*.x86_64.rpm")
if [ -n $rpm_build_libs ] && [ -f $rpm_build_libs ];then
cp -f $rpm_build_libs $rootfs_rpms/.
else
echo "ERROR: failed to find rpm-build-libs RPM!"
exit -1
fi
echo "--> find rpm-libs rpm"
rpm_libs=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "rpm-libs-[0-9]*.x86_64.rpm")
if [ -n $rpm_libs ] && [ -f $rpm_libs ];then
cp -f $rpm_libs $rootfs_rpms/.
else
echo "ERROR: failed to find rpm-libs RPM!"
exit -1
fi
echo "--> find rpm-plugin-systemd-inhibit rpm"
rpm_plugin_systemd_inhibit=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "rpm-plugin-systemd-inhibit-[0-9]*.x86_64.rpm")
if [ -n $rpm_plugin_systemd_inhibit ] && [ -f $rpm_plugin_systemd_inhibit ];then
cp -f $rpm_plugin_systemd_inhibit $rootfs_rpms/.
else
echo "ERROR: failed to find rpm-plugin-systemd-inhibit RPM!"
exit -1
fi
echo "--> find rpm-python rpm"
rpm_python=$(find $MY_BUILD_DIR/installer/rpmbuild/RPMS -type f -name "rpm-python-[0-9]*.x86_64.rpm")
if [ -n $rpm_python ] && [ -f $rpm_python ];then
cp -f $rpm_python $rootfs_rpms/.
else
echo "ERROR: failed to find rpm-python RPM!"
exit -1
fi
echo "--> find systemd rpm"
systemd=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages -type f -name "systemd-[0-9]*.x86_64.rpm")
if [ -n $systemd ] && [ -f $systemd ];then
cp -f $systemd $rootfs_rpms/.
else
echo "ERROR: failed to find systemd RPM!"
exit -1
fi
echo "--> find systemd-libs rpm"
systemd_libs=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages -type f -name "systemd-libs-[0-9]*.x86_64.rpm")
if [ -n $systemd_libs ] && [ -f $systemd_libs ];then
cp -f $systemd_libs $rootfs_rpms/.
else
echo "ERROR: failed to find systemd-libs RPM!"
exit -1
fi
echo "--> find systemd-sysv rpm"
systemd_sysv=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages -type f -name "systemd-sysv-[0-9]*.x86_64.rpm")
if [ -n $systemd_sysv ] && [ -f $systemd_sysv ];then
cp -f $systemd_sysv $rootfs_rpms/.
else
echo "ERROR: failed to find systemd-sysv RPM!"
exit -1
fi
echo "--> find bind-utils rpm"
bind_utils=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages -type f -name "bind-utils-[0-9]*.x86_64.rpm")
if [ -n $bind_utils ] && [ -f $bind_utils ];then
cp -f $bind_utils $rootfs_rpms/.
else
echo "ERROR: failed to find bind-utils RPM!"
exit -1
fi
echo "--> find ima-evm-utils rpm"
ima_evm_utils=$(find $MY_BUILD_DIR/export/dist/isolinux/Packages -type f -name "ima-evm-utils-[0-9]*.x86_64.rpm")
if [ -n $ima_evm_utils ] && [ -f $ima_evm_utils ];then
cp -f $ima_evm_utils $rootfs_rpms/.
else
echo "ERROR: failed to find ima-evm-utils RPM!"
exit -1
fi
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"
if [ $kernel_mode -eq 0 ];then
sudo $mk_images_tool $pxe_network_installer_dir "std"
else
sudo $mk_images_tool $pxe_network_installer_dir "rt"
fi
cd $cur_dir
echo "updating pxe-network-installer images -- done!"