Merge "Stop miniboot from fetching sw repo from sc on local install"

This commit is contained in:
Zuul 2021-11-17 14:15:44 +00:00 committed by Gerrit Code Review
commit b9b9b42671

View File

@ -3,17 +3,19 @@
# Source common functions # Source common functions
. /tmp/ks-functions.sh . /tmp/ks-functions.sh
SW_VERSION=xxxPLATFORM_RELEASExxx
STAGING_DIR="platform-backup"
BACKUP_PART_LABEL=Platform\\x20Backup BACKUP_PART_LABEL=Platform\\x20Backup
BACKUP_DEVICE=/dev/disk/by-partlabel/${BACKUP_PART_LABEL} BACKUP_DEVICE=/dev/disk/by-partlabel/${BACKUP_PART_LABEL}
BACKUP_MOUNT=/mnt/platform-backup BACKUP_MOUNT=/mnt/${STAGING_DIR}
BOOTIMAGE_ISO="" BOOTIMAGE_ISO=""
BOOTIMAGE_MOUNT=/mnt/bootimage BOOTIMAGE_MOUNT=/mnt/bootimage
KS="Miniboot pre:" KS="Miniboot pre:"
wlog "$KS local install check" wlog "${KS} local install check"
error=false
image=false
check=true
# Look for and validate the local iso image # Look for and validate the local iso image
if [ -e ${BACKUP_DEVICE} ]; then if [ -e ${BACKUP_DEVICE} ]; then
mkdir -p ${BACKUP_MOUNT} mkdir -p ${BACKUP_MOUNT}
@ -21,43 +23,69 @@ if [ -e ${BACKUP_DEVICE} ]; then
rc=$? rc=$?
if [ $rc -eq 0 ] ; then if [ $rc -eq 0 ] ; then
sleep 2 sleep 2
cd ${BACKUP_MOUNT}/xxxPLATFORM_RELEASExxx # does the prestaging dir for the specified sw version exist
for file in * ; do if [ -d "${BACKUP_MOUNT}/${SW_VERSION}" ] ; then
filename="${file%.*}"
extension="${file##*.}" # are there files in it ?
wlog "$KS prestaged file : ${file}" if [ "$(ls -A ${BACKUP_MOUNT}/${SW_VERSION})" ] ; then
if [ "${extension}" = "md5" ] ; then
md5sum -c "${file}" # change to prestaging dir and load the file names
if [ $? -eq 0 ] ; then cd ${BACKUP_MOUNT}/${SW_VERSION}
wlog "$KS ${filename} check passed"
else # loop over the files if there are any
wlog "$KS ${filename} check failed" for file in $(ls -A .) ; do
error=true filename="${file%.*}"
fi extension="${file##*.}"
elif [ "${extension}" = "iso" ] ; then wlog "${KS} prestaged file : ${file}"
# found the iso name for the mount operation below if [ "${extension}" = "md5" ] ; then
BOOTIMAGE_ISO=${BACKUP_MOUNT}/xxxPLATFORM_RELEASExxx/${file} md5sum -c "${file}"
fi if [ $? -eq 0 ] ; then
done wlog "${KS} ${filename} check passed"
if [ "$error" = false ] ; then else
if [ -f ${BOOTIMAGE_ISO} ]; then wlog "${KS} ${filename} check failed"
wlog "$KS local iso found : ${BOOTIMAGE_ISO}" check=false
mkdir -p ${BOOTIMAGE_MOUNT}
mount -o loop ${BOOTIMAGE_ISO} ${BOOTIMAGE_MOUNT} fi
wlog "$KS local iso mounted" elif [ "${extension}" = "iso" ] ; then
# found the iso name for the mount operation below
BOOTIMAGE_ISO=${BACKUP_MOUNT}/${SW_VERSION}/${file}
wlog "${KS} found prestaged iso image ${BOOTIMAGE_ISO}"
image=true
fi
done
else else
wlog "$KS local iso file not found : ${BOOTIMAGE_ISO}" wlog "${KS} no prestaged files"
fi fi
else else
wlog "$KS local install rejected due to validity check error" wlog "${KS} Error: ${BACKUP_MOUNT} not mounted"
fi
if [ "${check}" = true ] ; then
if [ "${image}" = true -a "${BOOTIMAGE_ISO}" != "" ]; then
wlog "${KS} local iso found : ${BOOTIMAGE_ISO}"
mkdir -p ${BOOTIMAGE_MOUNT}
mount -o loop ${BOOTIMAGE_ISO} ${BOOTIMAGE_MOUNT}
wlog "${KS} local iso mounted for local install"
else
wlog "${KS} local iso file not found"
fi
else
wlog "${KS} local install rejected due to validity check error"
fi fi
else else
wlog "$KS mount of ${BACKUP_DEVICE} to ${BACKUP_MOUNT} failed rc:$rc" wlog "${KS} mount of ${BACKUP_DEVICE} to ${BACKUP_MOUNT} failed rc:$rc"
fi fi
else else
wlog "$KS backup device ${BACKUP_DEVICE} does not exist" wlog "${KS} backup device ${BACKUP_DEVICE} does not exist"
fi 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
#
cat << EOF > /tmp/repo-include cat << EOF > /tmp/repo-include
repo --name=local-base --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/ repo --name=local-base --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/
repo --name=local-updates --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/patches/ repo --name=local-updates --cost=100 --baseurl=file://${BOOTIMAGE_MOUNT}/patches/
@ -77,15 +105,15 @@ EOF
KS="Miniboot post:" KS="Miniboot post:"
# wlog "$KS cmdLine: $(cat /proc/cmdline)" # wlog "${KS} cmdLine: $(cat /proc/cmdline)"
if [ -e /dev/disk/by-label/oe_iso_boot ]; then if [ -e /dev/disk/by-label/oe_iso_boot ]; then
# This is a hybrid ISO/network install. Mount the media to ensure Anaconda # This is a hybrid ISO/network install. Mount the media to ensure Anaconda
# ejects it on reboot. # ejects it on reboot.
mkdir /mnt/iso mkdir /mnt/iso
wlog "$KS mount for eject" wlog "${KS} mount for eject"
mount /dev/disk/by-label/oe_iso_boot /mnt/iso mount /dev/disk/by-label/oe_iso_boot /mnt/iso
else else
wlog "$KS /dev/disk/by-label/oe_iso_boot does not exist" wlog "${KS} /dev/disk/by-label/oe_iso_boot does not exist"
fi fi
# persist the default http port number to platform configuration. This # persist the default http port number to platform configuration. This
@ -123,111 +151,110 @@ KS="Miniboot post:"
if [ -d ${SYSIMAGE_MOUNT} ] ; then if [ -d ${SYSIMAGE_MOUNT} ] ; then
files="$(ls -lrt ${SYSIMAGE_MOUNT})" files="$(ls -lrt ${SYSIMAGE_MOUNT})"
wlog "$KS ${SYSIMAGE_MOUNT} files : $files[@]" wlog "${KS} ${SYSIMAGE_MOUNT} files : $files[@]"
if [ -d ${FEED_DIR} ] ; then if [ -d ${FEED_DIR} ] ; then
files=$(ls -lrt ${FEED_MOUNT}) files=$(ls -lrt ${FEED_MOUNT})
wlog "$KS $FEED_DIR files : $files[@]" wlog "${KS} $FEED_DIR files : $files[@]"
else else
wlog "$KS error : feed dir '$FEED_DIR' does not exist" wlog "${KS} error : feed dir '$FEED_DIR' does not exist"
fi fi
# Check updates Dir # Check updates Dir
if [ -d ${UPDATES_DIR} ] ; then if [ -d ${UPDATES_DIR} ] ; then
files=$(ls -lrt ${UPDATES_DIR}) files=$(ls -lrt ${UPDATES_DIR})
wlog "$KS $UPDATES_DIR files : $files[@]" wlog "${KS} $UPDATES_DIR files : $files[@]"
else else
wlog "$KS $UPDATES_DIR does not exist" wlog "${KS} $UPDATES_DIR does not exist"
fi fi
# Check Packages Dir # Check Packages Dir
if [ -d ${PATCHING_DIR} ] ; then if [ -d ${PATCHING_DIR} ] ; then
files=$(ls -lrt ${PATCHING_DIR}) files=$(ls -lrt ${PATCHING_DIR})
wlog "$KS $PATCHING_DIR files : $files[@]" wlog "${KS} $PATCHING_DIR files : $files[@]"
if [ -d ${PATCHING_DIR}/metadata ] ; then if [ -d ${PATCHING_DIR}/metadata ] ; then
files=$(ls -lrt ${PATCHING_DIR}/metadata) files=$(ls -lrt ${PATCHING_DIR}/metadata)
wlog "$KS $PATCHING_DIR/metadata files : $files[@]" wlog "${KS} $PATCHING_DIR/metadata files : $files[@]"
if [ -d ${PATCHING_DIR}/metadata/applied ] ; then if [ -d ${PATCHING_DIR}/metadata/applied ] ; then
files=$(ls -lrt ${PATCHING_DIR}/metadata/applied) files=$(ls -lrt ${PATCHING_DIR}/metadata/applied)
wlog "$KS $PATCHING_DIR/metadata/applied files : $files[@]" wlog "${KS} $PATCHING_DIR/metadata/applied files : $files[@]"
else else
wlog "$KS $PATCHING_DIR/metadata/applied does not exist" wlog "${KS} $PATCHING_DIR/metadata/applied does not exist"
fi fi
if [ -d ${PATCHING_DIR}/metadata/available ] ; then if [ -d ${PATCHING_DIR}/metadata/available ] ; then
files=$(ls -lrt ${PATCHING_DIR}/metadata/available) files=$(ls -lrt ${PATCHING_DIR}/metadata/available)
wlog "$KS $PATCHING_DIR/metadata/available files : $files[@]" wlog "${KS} $PATCHING_DIR/metadata/available files : $files[@]"
else else
wlog "$KS $PATCHING_DIR/metadata/available does not exist" wlog "${KS} $PATCHING_DIR/metadata/available does not exist"
fi fi
else else
wlog "$KS $PATCHING_DIR/metadata does not exist" wlog "${KS} $PATCHING_DIR/metadata does not exist"
fi fi
else else
wlog "$KS $PATCHING_DIR does not exist" wlog "${KS} $PATCHING_DIR does not exist"
fi fi
# Check Packages Dir # Check Packages Dir
if [ -d ${PACKAGES_DIR} ] ; then if [ -d ${PACKAGES_DIR} ] ; then
files=$(ls -lrt ${PACKAGES_DIR}) files=$(ls -lrt ${PACKAGES_DIR})
wlog "$KS $PACKAGES_DIR files : $files[@]" wlog "${KS} $PACKAGES_DIR files : $files[@]"
else else
wlog "$KS $PACKAGES_DIR does not exist" wlog "${KS} $PACKAGES_DIR does not exist"
fi fi
else else
wlog "$KS Error : $SYSIMAGE_MOUNT does not exists or is not a directory" wlog "${KS} Error : $SYSIMAGE_MOUNT does not exists or is not a directory"
fi fi
# Decide on install mode ; local or remote # Decide on install mode ; local or remote
if [ -d /mnt/bootimage ]; then if [ -d /mnt/bootimage ]; then
srcdir=/mnt/bootimage srcdir=/mnt/bootimage
wlog "$KS local install - ${srcdir}"
else else
# Remote System Controller # Remote System Controller
srcdir=/mnt/install/source srcdir=/mnt/install/source
wlog "$KS remote install - ${srcdir}"
fi fi
# prepare to boot other hosts by mirroring sw repository
if [ -d $srcdir/Packages ] ; then if [ -d $srcdir/Packages ] ; then
wlog "$KS copying software repository $srcdir/Packages" wlog "${KS} copying software repository $srcdir/Packages"
mkdir -p ${FEED_DIR} mkdir -p ${FEED_DIR}
cp -r $srcdir/Packages ${FEED_DIR}/Packages cp -r $srcdir/Packages ${FEED_DIR}/Packages
if [ -d $srcdir/repodata ] ; then if [ -d $srcdir/repodata ] ; then
cp -r $srcdir/repodata ${FEED_DIR}/repodata cp -r $srcdir/repodata ${FEED_DIR}/repodata
else else
wlog "$KS $srcdir/repodata dir does not exist" wlog "${KS} $srcdir/repodata dir does not exist"
fi fi
fi fi
if [ -d $srcdir/patches ]; then if [ -d $srcdir/patches ]; then
if [ -d $srcdir/patches/Packages ] ; then if [ -d $srcdir/patches/Packages ] ; then
wlog "$KS copying patch Packages $srcdir/patches/Packages" wlog "${KS} copying patch Packages $srcdir/patches/Packages"
mkdir -p ${UPDATES_DIR} mkdir -p ${UPDATES_DIR}
cp -r $srcdir/patches/Packages ${UPDATES_DIR}/Packages cp -r $srcdir/patches/Packages ${UPDATES_DIR}/Packages
else else
wlog "$KS $srcdir/patches/Packages does not exist" wlog "${KS} $srcdir/patches/Packages does not exist"
fi fi
if [ -d $srcdir/patches/repodata ] ; then if [ -d $srcdir/patches/repodata ] ; then
wlog "$KS copying patch repository $srcdir/patches/repodata" wlog "${KS} copying patch repository $srcdir/patches/repodata"
mkdir -p ${UPDATES_DIR} mkdir -p ${UPDATES_DIR}
cp -r $srcdir/patches/repodata ${UPDATES_DIR}/repodata cp -r $srcdir/patches/repodata ${UPDATES_DIR}/repodata
else else
wlog "$KS $srcdir/patches/repodata does not exist" wlog "${KS} $srcdir/patches/repodata does not exist"
fi fi
fi fi
if [ -d $srcdir/patches/metadata ] ; then if [ -d $srcdir/patches/metadata ] ; then
mkdir -p ${PATCHING_DIR} mkdir -p ${PATCHING_DIR}
wlog "$KS copying $srcdir/patches/metadata to ${PATCHING_DIR}" wlog "${KS} copying $srcdir/patches/metadata to ${PATCHING_DIR}"
cp -r $srcdir/patches/metadata ${PATCHING_DIR}/metadata cp -r $srcdir/patches/metadata ${PATCHING_DIR}/metadata
fi fi
if [ -d $srcdir/patches ]; then if [ -d $srcdir/patches ]; then
mkdir -p ${PACKAGES_DIR} mkdir -p ${PACKAGES_DIR}
wlog "$KS copying packages" wlog "${KS} copying packages"
find ${UPDATES_DIR}/Packages -name '*.rpm' \ find ${UPDATES_DIR}/Packages -name '*.rpm' \
| xargs --no-run-if-empty -I files cp --preserve=all files ${PACKAGES_DIR} | xargs --no-run-if-empty -I files cp --preserve=all files ${PACKAGES_DIR}
fi fi
@ -246,7 +273,7 @@ KS="Miniboot post:"
INSTALL_UUID=`uuidgen` INSTALL_UUID=`uuidgen`
echo $INSTALL_UUID > /www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid echo $INSTALL_UUID > /www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid
echo "INSTALL_UUID=$INSTALL_UUID" >> /etc/platform/platform.conf echo "INSTALL_UUID=$INSTALL_UUID" >> /etc/platform/platform.conf
wlog "$KS updating platform.conf with install uuid : ${INSTALL_UUID}" wlog "${KS} updating platform.conf with install uuid : ${INSTALL_UUID}"
# Mirror remote software repositories # Mirror remote software repositories
anaconda_logdir=/var/log/anaconda anaconda_logdir=/var/log/anaconda
@ -265,70 +292,75 @@ fi
# #
# - Packages # - Packages
# - Repodata # - Repodata
# - Patch Packages
# - Patches repodata
# - Patches metadata
# - Save all patch packages to /opt/patching/packages/xxxPLATFORM_RELEASExxx
# #
FEED_DIR=/www/pages/feed/rel-xxxPLATFORM_RELEASExxx FEED_DIR=/www/pages/feed/rel-xxxPLATFORM_RELEASExxx
wlog "$KS feed dir $FEED_DIR" declare -i cut_dirs=NUM_DIRS
if [ -d ${FEED_DIR} ]; then if [ ! -d "${FEED_DIR}/Packages" ]; then
mkdir -p ${FEED_DIR}/Packages mkdir -p "${FEED_DIR}/Packages"
mkdir -p ${FEED_DIR}/repodata mkdir -p "${FEED_DIR}/repodata"
cd ${FEED_DIR} cd "${FEED_DIR}"
feed_url=xxxHTTP_URLxxx feed_url=xxxHTTP_URLxxx
declare -i cut_dirs=NUM_DIRS
wlog "$KS downloading software repository $feed_url" wlog "${KS} Remote Install"
wlog "${KS} downloading software repository $feed_url"
# Fetch Packages # Fetch Packages
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$cut_dirs $feed_url/Packages/ -o $anaconda_logdir/rpmget.log \ --cut-dirs=$cut_dirs $feed_url/Packages/ -o $anaconda_logdir/rpmget.log \
|| report_post_failure_with_logfile $anaconda_logdir/rpmget.log || report_post_failure_with_logfile $anaconda_logdir/rpmget.log
wlog "${KS} download of $feed_url/Packages/ complete"
# Fetch Repodata # Fetch Repodata
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \ 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 \ --cut-dirs=$cut_dirs $feed_url/repodata/ -o $anaconda_logdir/rpmget_repo.log \
|| report_post_failure_with_logfile $anaconda_logdir/rpmget_repo.log || report_post_failure_with_logfile $anaconda_logdir/rpmget_repo.log
# Fetch Patch Package Data quietly wlog "${KS} download of $feed_url/repodata/ complete"
patches_url=xxxHTTP_URLxxx/patches
wget ${NOVERIFYSSL_WGET_OPT} -q --spider ${patches_url}/
if [ $? -eq 0 ]; then
wlog "$KS downloading patch repository $patches_url"
cd /www/pages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/Packages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/repodata
cd updates/rel-xxxPLATFORM_RELEASExxx
declare -i patches_cut_dirs=$((cut_dirs+1))
wlog "$KS fetch packages"
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/Packages/ -o $anaconda_logdir/patches_rpmget.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget.log
wlog "$KS fetch package repodata"
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/repodata/ -o $anaconda_logdir/patches_rpmget_repo.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_repo.log
mkdir -p /opt/patching/metadata
mkdir -p /opt/patching/packages/xxxPLATFORM_RELEASExxx
cd /opt/patching
wlog "$KS fetch patch metadata"
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/metadata/ -o $anaconda_logdir/patches_rpmget_metadata.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_metadata.log
wlog "$KS save a copy of all patch packages, preserve attributes"
find /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"
fi
else else
wlog "$KS feed dir $FEED_DIR does not exist" wlog "${KS} Local Install"
fi
# Fetch Patch Package Data quietly
# - Patch Packages
# - Patches repodata
# - Patches metadata
# - 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
wlog "${KS} downloading patch repository $patches_url"
cd /www/pages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/Packages
mkdir -p updates/rel-xxxPLATFORM_RELEASExxx/repodata
cd updates/rel-xxxPLATFORM_RELEASExxx
declare -i patches_cut_dirs=$((cut_dirs+1))
wlog "${KS} fetch packages"
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/Packages/ -o $anaconda_logdir/patches_rpmget.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget.log
wlog "${KS} fetch package repodata"
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/repodata/ -o $anaconda_logdir/patches_rpmget_repo.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_repo.log
mkdir -p /opt/patching/metadata
mkdir -p /opt/patching/packages/xxxPLATFORM_RELEASExxx
cd /opt/patching
wlog "${KS} fetch patch metadata"
wget ${NOVERIFYSSL_WGET_OPT} --mirror --no-parent --no-host-directories --reject 'index.html*' \
--cut-dirs=$patches_cut_dirs $patches_url/metadata/ -o $anaconda_logdir/patches_rpmget_metadata.log \
|| report_post_failure_with_logfile $anaconda_logdir/patches_rpmget_metadata.log
wlog "${KS} save a copy of all patch packages, preserve attributes"
find /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"
fi fi
%end %end