Use alternative location if prestage iso does not exist

If the prestage iso does not exist, the kickstart looks for
for packages, repodata and patches under
/opt/platform-backup/<release-version>. If these or a subset
of, are not available, then download them from the system
controller.

Test Plan:
PASS: Verify that packages and repodata are retrieved
      from platform-backup when prestaging iso does not exist

PASS: Verify that patches are downloaded if not available in
      platform-backup and the prestaging iso does not exist

PASS: Verify all prestaged patches are used locally rather
      than downloaded

PASS: Verify that packages get downloaded if either prestage
      Packages or repodata directory is empty or does not
      exist

PASS: Verify that packages, repodata and patches are downloaded
      if neither platform-backup content nor prestaging iso is
      available.

Story: 2009799
Task: 44622

Change-Id: If2c63d2f3207b80073390d169e229945470f44eb
Signed-off-by: Shrikumar Sharma <shrikumar.sharma@windriver.com>
This commit is contained in:
Shrikumar Sharma 2022-02-08 11:33:18 -05:00
parent d48f5cc3fb
commit 793ce1e7d2
1 changed files with 90 additions and 17 deletions

View File

@ -121,12 +121,17 @@ if [ "${iso_check}" = true -a "${iso_mount}" = true ] ; then
wlog "${KS} Local Install ready"
fi
if [ "${iso_mount}" = false ] ; then
wlog "${KS} Prestage ISO is not available"
fi
#
# This controls where the packages come from.
# Lower cost has higher priority ; making local install preferred.
#
# If ${BOOTIMAGE_MOUNT} exists then install from local iso - Local Install
# Otherwise, they are fetched from the System Controller - Remote Install
# Otherwise, they are fetched from platform backup.
# If this fails, they are fetched from the System Controller - Remote Install
#
cat << EOF > /tmp/repo-include
repo --name=local-base --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/
@ -191,7 +196,6 @@ PACKAGES_DIR=${PATCHING_DIR}/packages/xxxPLATFORM_RELEASExxx/
KS="Miniboot post:"
if [ -d ${SYSIMAGE_MOUNT} ] ; then
files="$(ls -lrt ${SYSIMAGE_MOUNT})"
wlog "${KS} ${SYSIMAGE_MOUNT} files : $files[@]"
if [ -d ${FEED_DIR} ] ; then
@ -244,30 +248,58 @@ if [ -d ${SYSIMAGE_MOUNT} ] ; then
else
wlog "${KS} $PACKAGES_DIR does not exist"
fi
wlog "${KS} end of sysimage_mount ${SYSIMAGE_MOUNT}"
else
wlog "${KS} Error : $SYSIMAGE_MOUNT does not exists or is not a directory"
fi
# Decide on install mode ; local or remote
# # Handle 3 prestaging conditions
#
# 1. Full local install ; iso present in platform-backup/rel
# 2. Prioritized install ; use prestaged content and fetch what's missing remotely
# 3. Full remote install ; no prestaging content in platform-backup/rel
if [ -d /mnt/bootimage ]; then
wlog "${KS} /mnt/bootimage"
srcdir=/mnt/bootimage
elif [ -d /mnt/platform-backup/xxxPLATFORM_RELEASExxx ] ; then
wlog "${KS} looking for packages in /mnt/platform_backup"
srcdir=/mnt/platform-backup/xxxPLATFORM_RELEASExxx
else
# Remote System Controller
wlog "${KS} /mnt/install/source"
srcdir=/mnt/install/source
fi
need_packages=false
need_patches=false
# prepare to boot other hosts by mirroring sw repository
if [ -d $srcdir/Packages ] ; then
wlog "${KS} copying software repository $srcdir/Packages"
mkdir -p ${FEED_DIR}
cp -r $srcdir/Packages ${FEED_DIR}/Packages
if [ -d $srcdir/repodata ] ; then
cp -r $srcdir/repodata ${FEED_DIR}/repodata
packagefilecount=$(ls ${srcdir}/Packages | wc -l)
if [ ${packagefilecount} = 0 ]; then
wlog "${KS} ${srcdir}/Packages is empty. Fetching remotely"
need_packages=true
else
wlog "${KS} $srcdir/repodata dir does not exist"
cp -r $srcdir/Packages ${FEED_DIR}/Packages
if [ -d $srcdir/repodata ] ; then
repodatafilecount=$(ls ${srcdir}/repodata | wc -l)
if [ ${repodatafilecount} = 0 ]; then
wlog "${KS} ${srcdir}/repodata is empty.Fetching remotely"
need_packages=true
else
cp -r $srcdir/repodata ${FEED_DIR}/repodata
fi
else
wlog "${KS} $srcdir/repodata dir does not exist. Fetching remotely"
need_packages=true
fi
fi
else
wlog "${KS} $srcdir/Packages not found. Fetching remotely"
need_packages=true
fi
if [ -d $srcdir/patches ]; then
@ -276,7 +308,8 @@ if [ -d $srcdir/patches ]; then
mkdir -p ${UPDATES_DIR}
cp -r $srcdir/patches/Packages ${UPDATES_DIR}/Packages
else
wlog "${KS} $srcdir/patches/Packages does not exist"
wlog "${KS} $srcdir/patches/Packages does not exist. Fetching remotely"
need_patches=true
fi
if [ -d $srcdir/patches/repodata ] ; then
@ -284,21 +317,39 @@ if [ -d $srcdir/patches ]; then
mkdir -p ${UPDATES_DIR}
cp -r $srcdir/patches/repodata ${UPDATES_DIR}/repodata
else
wlog "${KS} $srcdir/patches/repodata does not exist"
wlog "${KS} $srcdir/patches/repodata does not exist. Fetching remotely"
need_patches=true
fi
else
wlog "${KS} $srcdir/patches does not exist. Fetching remotely"
need_patches=true
fi
if [ -d $srcdir/patches/metadata ] ; then
if [ -d $srcdir/patches/metadata -a "${need_patches}" = false ] ; then
mkdir -p ${PATCHING_DIR}
wlog "${KS} copying $srcdir/patches/metadata to ${PATCHING_DIR}"
cp -r $srcdir/patches/metadata ${PATCHING_DIR}/metadata
else
wlog "${KS} $srcdir/patches/metadata doesn't exist. Fetching remotely"
need_patches=true
fi
if [ -d $srcdir/patches ]; then
if [ -d $srcdir/patches -a "${need_patches}" = false ]; then
mkdir -p ${PACKAGES_DIR}
wlog "${KS} copying packages"
find ${UPDATES_DIR}/Packages -name '*.rpm' \
| xargs --no-run-if-empty -I files cp --preserve=all files ${PACKAGES_DIR}
else
wlog "${KS} $srcdir/patches doesn't exist: fetching remotely"
need_patches=true
fi
if [ "${need_packages}" = true ]; then
echo > ${SYSIMAGE_MOUNT}/tmp/needpackages
fi
if [ "${need_patches}" = true ]; then
echo > ${SYSIMAGE_MOUNT}/tmp/needpatches
fi
%end
@ -329,7 +380,7 @@ else
fi
# If the patch to $FEED_DIR does not exist then proceed to create it and
# If the path to $FEED_DIR does not exist then proceed to create it and
# fetch the ISO content in pieces from the system controller:
#
# - Packages
@ -337,7 +388,28 @@ fi
#
FEED_DIR=/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx
declare -i cut_dirs=NUM_DIRS
if [ ! -d "${FEED_DIR}/Packages" ]; then
declare need_packages=
declare need_patches=
if [ -f /tmp/needpackages ]; then
wlog "${KS} Packages need to be downloaded"
need_packages=true
rm /tmp/needpackages
else
need_packages=false
fi
if [ -f /tmp/needpatches ]; then
wlog "${KS} patches need to be downloaded"
need_patches=true
rm /tmp/needpatches
else
need_patches=false
fi
if ( [ ! -d "${FEED_DIR}/Packages" ] || [ ! -d "${FEED_DIR}/repodata" ] ) && [ "${need_packages}" = true ]; then
mkdir -p "${FEED_DIR}/Packages"
mkdir -p "${FEED_DIR}/repodata"
cd "${FEED_DIR}"
@ -354,7 +426,8 @@ if [ ! -d "${FEED_DIR}/Packages" ]; then
wlog "${KS} download of $feed_url/Packages/ complete"
# Fetch Repodata
# Fetch Repodata. In the case of "${need_packages} = yes", it is better to fetch
# both the Packages as well as the repodata (since repodata is correlated with the Packages)
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$cut_dirs $feed_url/repodata/ -o $anaconda_logdir/rpmget_repo.log \
|| report_post_failure_with_logfile $anaconda_logdir/rpmget_repo.log
@ -371,7 +444,7 @@ fi
# - Save all patch packages to /opt/patching/packages/xxxPLATFORM_RELEASExxx
patches_url=xxxHTTP_URLxxx/patches
wget ${NOVERIFYSSL_WGET_OPT} -q --spider ${patches_url}/
if [ $? -eq 0 ]; then
if [ $? -eq 0 ] && [ "${need_patches}" = true ]; then
wlog "${KS} downloading patch repository $patches_url"
cd /var/www/pages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/Packages
@ -402,7 +475,7 @@ if [ $? -eq 0 ]; then
find /var/www/pages/updates/rel-xxxPLATFORM_RELEASExxx/Packages -name '*.rpm' \
| xargs --no-run-if-empty -I files cp --preserve=all files /opt/patching/packages/xxxPLATFORM_RELEASExxx/
else
wlog "${KS} get from patches url '$patches_url' failed"
wlog "${KS} Patches are not required to be downloaded"
fi
%end