Fix failure to set instdev parameter when we use ks-setup.cfg

When we create the prestage iso with an external script,
ks-setup.cfg, we may not provide the rootfs_device or
boot_device parameter. This is a valid scenario where these
parameters are defined in ks-setup.cfg. An installation failure
is observed in this case.

The cause of the failure is that the prestage code is handled in
a pre-part hook. This commit moves it to a ks-early hook.

In this commit, a provision for the execution of a custom script
named ks-addon.cfg is also made. This script is a bash script
that must execute in the last post hook.

Test Plan:
PASS: Verify that the installation succeeds when the rootfs
      and boot device parameters are only specified via
      the ks-setup.cfg.

PASS: Verify that the external script, ks-addon.cfg, is executed
      after the install and configurations are done.

PASS: Verify that the logs from the execution of ks-addon.cfg
      are present in kickstart.log.

Closes-bug: 1997305

Signed-off-by: Shrikumar Sharma <shrikumar.sharma@windriver.com>
Change-Id: Ica1735aef3ab457cf0609ebee6aac45671e97987
This commit is contained in:
Shrikumar Sharma 2022-11-21 23:13:41 +00:00 committed by ssharma3
parent d24c008374
commit 15e971b59e

View File

@ -971,8 +971,8 @@ true
# This code is only executed if "prestage" is set in the command line
# to the kernel.
%pre-part --interpreter=/bin/bash
HOOK_LABEL="pre-part"
%ks-early --interpreter=/bin/bash
HOOK_LABEL="ks-early"
. /tmp/lat/ks_functions.sh
# First, parse /proc/cmdline to find the boot args
@ -989,8 +989,6 @@ if check_prestage -eq 0 ; then
mkdir -p ${ISODIR}
rootfs_device=${INSTDEV}
# Mount the isofile
mount "${ISO_DEV}" "${ISODIR}"
rc=$?
@ -1006,6 +1004,7 @@ if check_prestage -eq 0 ; then
# override the INSTDEV based on the information from ks-setup.cfg
export INSTDEV="${rootfs_device}"
export instdev="${rootfs_device}"
ilog "rootfs device is ${INSTDEV}"
@ -3090,5 +3089,14 @@ if [ "${storage}" = true ] ; then
ln -s /usr/share/starlingx/pmon.d/syslog-ng.conf ${IMAGE_ROOTFS}/etc/pmon.d/syslog-ng.conf
fi
if [ -e "/instboot/ks-addon.cfg" ]; then
ilog "Running kickstart addon script"
source /instboot/ks-addon.cfg
rc=$?
if [ "${rc}" -ne 0 ]; then
ilog "Addon script ks-addon.cfg exited with [rc=${rc}]"
fi
fi
true
%end