From b877e97696e801e47136dcf226c019db1ee68a4a Mon Sep 17 00:00:00 2001 From: Shrikumar Sharma Date: Thu, 31 Mar 2022 11:57:35 -0400 Subject: [PATCH] Enable overwrite existing installation with prestage iso content When an existing installation exists on the subcloud, we may not want to overwrite the installation. The current behaviour is to avoid overwrites. However, if the user so desires, the existing installation can be overwritten by the usage of an argument to gen-prestaged-iso.sh. A bug is also fixed in this code checkin, where copy_to_iso gets one less argument than it should, causing the script to fail when generating a prestaged iso. Test Plan: PASS: Verify that the force_install option is present on the kernel command line in the generated prestaged iso when the script is invoked with the --force-install argument. PASS: Verify that the force_install option is not present on the kernel command line in the default case PASS: Verify that the prestaged iso installs the prestaged content when generated with the --force-install argument. Story: 2009948 Task: 44902 Depends-On: https://review.opendev.org/c/starlingx/metal/+/836215 Change-Id: I9da3b8315dc04bfa8a95f4b0a020a9c7641c0e56 Signed-off-by: Shrikumar Sharma --- .../platform-util/scripts/gen-prestaged-iso.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/utilities/platform-util/scripts/gen-prestaged-iso.sh b/utilities/platform-util/scripts/gen-prestaged-iso.sh index ba5fe682..62c1c987 100755 --- a/utilities/platform-util/scripts/gen-prestaged-iso.sh +++ b/utilities/platform-util/scripts/gen-prestaged-iso.sh @@ -42,6 +42,7 @@ Usage: [ --param = ] [ --default-boot ] [ --timeout ] + [ --force-install ] --input : Specify input ISO file --output : Specify output ISO file @@ -74,6 +75,9 @@ Usage: --timeout : Specify boot menu timeout, in seconds. (default 30) A value of -1 will wait forever. + --force-install: + Force install the prestaged content even if there is already an + installation on the target. ENDUSAGE } @@ -416,7 +420,8 @@ function copy_rpm_file_to_iso { log_error "Error: copy_rpm_file_to_iso: file '${src}' not found in rpm '$(basename {rpm})'" rc=1 else - copy_to_iso "${src}" "${dest}" "${overwrite}" + # we do not need an md5 here, so leaving third argument empty + copy_to_iso "${src}" "${dest}" "" "${overwrite}" rc=$? fi popd > /dev/null @@ -478,6 +483,9 @@ function generate_boot_cfg { COMMON_ARGS="${COMMON_ARGS} biosdevname=0 usbcore.autosuspend=-1" COMMON_ARGS="${COMMON_ARGS} security_profile=standard user_namespace.enable=1" COMMON_ARGS="${COMMON_ARGS} inst.stage2=hd:LABEL=${VOLUME_LABEL} inst.ks=hd:LABEL=${VOLUME_LABEL}:/${PRESTAGED_KICKSTART}" + if [[ "${FORCE_INSTALL}" == true ]]; then + COMMON_ARGS="${COMMON_ARGS} force_install" + fi for f in ${isodir}/isolinux.cfg ${isodir}/syslinux.cfg; do cat < ${f} @@ -557,6 +565,7 @@ declare MD5_FILE="container-image.tar.gz.md5" declare VOLUME_LABEL="oe_prestaged_iso_boot" declare PRESTAGED_KICKSTART="prestaged_installer_ks.cfg" declare MENU_NAME="Prestaged Local Installer" +declare FORCE_INSTALL=false SHORTOPTS=""; LONGOPTS="" SHORTOPTS+="i:"; LONGOPTS+="input:," @@ -568,6 +577,7 @@ SHORTOPTS+="K:"; LONGOPTS+="kickstart-patch:," SHORTOPTS+="d:"; LONGOPTS+="default-boot:," SHORTOPTS+="t:"; LONGOPTS+="timeout:," SHORTOPTS+="I:"; LONGOPTS+="images:," +SHORTOPTS+="f"; LONGOPTS+="force-install," SHORTOPTS+="h"; LONGOPTS+="help" OPTS=$(getopt -o "${SHORTOPTS}" --long "${LONGOPTS}" --name "$0" -- "$@") @@ -646,6 +656,10 @@ while :; do UPDATE_TIMEOUT="yes" shift 2 ;; + -f | --force-install) + FORCE_INSTALL=true + shift + ;; --) shift break