From f43e37b4ea5ed58a55a660cab0b76a3ce0b6532e Mon Sep 17 00:00:00 2001 From: Don Penney Date: Wed, 2 Sep 2020 22:42:41 -0400 Subject: [PATCH] Fix gen-bootloader-iso.sh error on unpatched controller On a system that has never been patched, the updates repository may not yet have a Packages directory. This update fixes the patch setup in gen-bootloader-iso.sh to check for this case and handle it without failing. This update also improves the platform-kickstarts-pxeboot check to look for a pxeboot kickstart, to ensure there isn't a false-positive match against an extracted pxe-network-installer patch, which would also have a /pxeboot directory. Change-Id: I8e24a3ff123f4c2649be52b1a0ce77d830e342f3 Closes-Bug: 1893990 Signed-off-by: Don Penney --- .../scripts/gen-bootloader-iso.sh | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/utilities/platform-util/scripts/gen-bootloader-iso.sh b/utilities/platform-util/scripts/gen-bootloader-iso.sh index 8ac281a8..0b68fbc3 100755 --- a/utilities/platform-util/scripts/gen-bootloader-iso.sh +++ b/utilities/platform-util/scripts/gen-bootloader-iso.sh @@ -361,7 +361,7 @@ function handle_delete { fi # If there are no more nodes, cleanup everything else - if [ $(ls -A ${NODE_DIR_BASE} | wc -l) = 0 ]; then + if [ $(ls -A ${NODE_DIR_BASE} 2>/dev/null | wc -l) = 0 ]; then if [ -d ${NODE_DIR_BASE} ]; then rmdir ${NODE_DIR_BASE} fi @@ -391,12 +391,27 @@ function get_patches_from_host { exit 1 fi - rsync -a ${host_patch_repo}/repodata ${host_patch_repo}/Packages ${SHARED_DIR}/patches/ + rsync -a ${host_patch_repo}/repodata ${SHARED_DIR}/patches/ if [ $? -ne 0 ]; then - log_error "Failed to copy patches repo from ${host_patch_repo}" + log_error "Failed to copy ${host_patch_repo}/repodata" exit 1 fi + if [ -d ${host_patch_repo}/Packages ]; then + rsync -a ${host_patch_repo}/Packages ${SHARED_DIR}/patches/ + if [ $? -ne 0 ]; then + log_error "Failed to copy ${host_patch_repo}/Packages" + exit 1 + fi + elif [ ! -d ${SHARED_DIR}/patches/Packages ]; then + # Create an empty Packages dir + mkdir ${SHARED_DIR}/patches/Packages + if [ $? -ne 0 ]; then + log_error "Failed to create ${SHARED_DIR}/patches/Packages" + exit 1 + fi + fi + mkdir -p \ ${SHARED_DIR}/patches/metadata/available \ ${SHARED_DIR}/patches/metadata/applied \ @@ -516,7 +531,7 @@ function extract_shared_files { extract_pkg_to_workdir 'platform-kickstarts-pxeboot' local patched_pxeboot_files_dir=${WORKDIR}/pxeboot - if [ -d ${patched_pxeboot_files_dir} ]; then + if [ -f ${patched_pxeboot_files_dir}/pxeboot_controller.cfg ]; then # Use the patched pxeboot files pxeboot_files_dir=${patched_pxeboot_files_dir} fi