From 06626151de926f335e62ee719be74820c8cbfb00 Mon Sep 17 00:00:00 2001 From: Shrikumar Sharma Date: Sun, 8 May 2022 22:52:24 -0400 Subject: [PATCH] Install package_checksums in /usr/local/share/pkg-list In order to prepare shared software packages on the system controller for subcloud prestaging, the file "package-checksums" containing a list of packages and their checksums, must be copied to /usr/local/share/pkg-list and renamed as packages_list. The prestaging process needs the package-and-checksum list for the version of the load on the controller and the version of the load on the subcloud. This file needs to be copied over to /var/www/pages/feed/rel- on the controller so that the subclouds can download it. This file can be obtained by downloading from the system controller. If the system is being installed directly from a boot iso, the appropriate kickstart is called to install the file from the mounted bootimage.iso. There are a few cases which determine how to get the file. Cases: 1. Install load directly from bootimage.iso (both controller and subcloud) - copy from mounted iso to location. The iso may be present on a peripheral device like a CD/DVD. 2. Install load over lan - download the file from server and copy to locations (all controllers) 3. Version upgrade by importing a new load - copy the file to the appropriate location on the system controller. The subcloud will download the package_checksums belonging to the imported load as part of the upgrade process. Test Plan: PASS: Verify that the file is copied over to /usr/local/share/ pkg-list and /var/www/feed/rel-/ when installing System Controller or subcloud from bootimage.iso PASS: Verify that the file is copied to the locations when installing controller-1 via pxeboot PASS: Verify that the file is copied to the locations when upgrading the System Controller (using load-import) PASS: Verify that the file is copied when adding a subcloud with dcmanager subcloud add Depends On: https://review.opendev.org/c/starlingx/distcloud/+/841828 Story: 2009799 Task: 45376 Change-Id: If14b197999f2ae03e15fdc08ec27511ca1d41767 Signed-off-by: Shrikumar Sharma --- .../kickstarts/post_miniboot_controller.cfg | 52 ++++++++++++++++++- bsp-files/kickstarts/post_net_controller.cfg | 20 +++++++ .../kickstarts/post_pxeboot_controller.cfg | 34 ++++++++++-- bsp-files/kickstarts/post_usb_controller.cfg | 21 ++++++++ bsp-files/upgrades/import.sh | 15 ++++++ 5 files changed, 136 insertions(+), 6 deletions(-) diff --git a/bsp-files/kickstarts/post_miniboot_controller.cfg b/bsp-files/kickstarts/post_miniboot_controller.cfg index b33aa2b2..c33e8128 100644 --- a/bsp-files/kickstarts/post_miniboot_controller.cfg +++ b/bsp-files/kickstarts/post_miniboot_controller.cfg @@ -47,6 +47,10 @@ # prestaged container images ... /opt/platform-backup/rel-xx.xx/image# # prestaged image checks ... /opt/platform-backup/rel-xx.xx/image#.md5 # +# Miniboot also downloads the file "package_checksums" from the system +# controller and copies it to two locations: /usr/local/share/pkg-list and +# to /var/www/pages/feed/rel-. This file is required for prestaging +# operations. The file is renamed to packages_list at the target location. ############################################################################ # Source common functions @@ -474,6 +478,8 @@ true KS="Miniboot post:" +FEED_DIR=/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx + # Create a uuid specific to this installation INSTALL_UUID=`uuidgen` echo $INSTALL_UUID > /var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/install_uuid @@ -491,6 +497,50 @@ else NOVERIFYSSL_WGET_OPT="" fi +# package_checksums +# copy the package_checksums file to /usr/local/share/pkg-list +INSTALL_MOUNT=/mnt/install/repo +PKG_FILE=package_checksums +# at the target directory, this file is called "packages_list" +DEST_PKG_FILE=packages_list +PKG_FILE_LOC=/usr/local/share/pkg-list +pkg_url=xxxHTTP_URLxxx + +# create ${PKG_FILE_LOC} if it does not exist already. +if [ ! -d ${PKG_FILE_LOC} ]; then + wlog "${KS} Creating ${PKG_FILE_LOC}" + mkdir -p ${PKG_FILE_LOC} +fi + +# There are two paths to obtain the desired file. The file is +# named package_checksums in the bootimage.iso, and it must be +# stored in two locations here as packages_list. +# +# If this server is being installed from the iso file (through +# CD/DVD etc, for example), then, if the file exists at +# ${INSTALL_MOUNT}, just copy it over. Otherwise, it is possible +# that this install is happening on a subcloud. In this case, +# download the file from the server (system controller). +# +# If the file does not exist, it is an issue as future upgrades +# may not work, so we need to exit with error. + +if [ -f ${INSTALL_MOUNT}/${PKG_FILE} ]; then + wlog "${KS} copying package_checksums to ${PKG_FILE_LOC}" + cp ${INSTALL_MOUNT}/${PKG_FILE} ${PKG_FILE_LOC}/${DEST_PKG_FILE} +else + # the file does not exist because the install is not happening + # from a bootimage.iso. + # so get it from the system controller. + wlog "${KS} downloading packages_list from the system controller" + wget ${NOVERIFYSSL_WGET_OPT} ${pkg_url}/${DEST_PKG_FILE} \ + -O ${PKG_FILE_LOC} \ + -o $anaconda_logdir/${PKG_FILE}.log \ + || report_post_failure_with_logfile $anaconda_logdir/${PKG_FILE}.log +fi + +# cp the package_checksum files to the feed directory +cp ${PKG_FILE_LOC}/${DEST_PKG_FILE} ${FEED_DIR} # 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: @@ -498,9 +548,7 @@ fi # - Packages # - Repodata # -FEED_DIR=/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx declare -i cut_dirs=NUM_DIRS - declare need_patches= if [ -f /tmp/needpatches ]; then diff --git a/bsp-files/kickstarts/post_net_controller.cfg b/bsp-files/kickstarts/post_net_controller.cfg index fb42e439..a9a220c2 100644 --- a/bsp-files/kickstarts/post_net_controller.cfg +++ b/bsp-files/kickstarts/post_net_controller.cfg @@ -22,6 +22,26 @@ feed_url=http://pxecontroller:${http_port:-8080}/feed/ anaconda_logdir=/var/log/anaconda mkdir -p $anaconda_logdir +pkg_file_loc=/usr/local/share/pkg-list +pkg_file=packages_list +FEED_DIR=/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx + +if [ ! -f ${pkg_file_loc} ]; then + mkdir -p ${pkg_file_loc} +fi + +echo "Retrieving package_checksums and writing to packages_list" >/dev/console +curl ${feed_url}/rel-xxxPLATFORM_RELEASExxx/${pkg_file} \ + -o ${pkg_file_loc}/${pkg_file} + +# If the feed directory does not exist, create it now. +# The package checksums must be copied to it. +if [ ! -d ${FEED_DIR} ]; then + mkdir -p ${FEED_DIR} +fi +cp ${pkg_file_loc}/${pkg_file} ${FEED_DIR} + + echo "Mirroring software repository (may take several minutes)..." >/dev/console wget --recursive --no-parent --no-host-directories --no-clobber --reject 'index.html*' --reject '*.log' $feed_url/ -o $anaconda_logdir/wget-feed-mirror.log \ || report_post_failure_with_logfile $anaconda_logdir/wget-feed-mirror.log diff --git a/bsp-files/kickstarts/post_pxeboot_controller.cfg b/bsp-files/kickstarts/post_pxeboot_controller.cfg index da74b86a..d9c4b6fe 100644 --- a/bsp-files/kickstarts/post_pxeboot_controller.cfg +++ b/bsp-files/kickstarts/post_pxeboot_controller.cfg @@ -72,6 +72,8 @@ EOF # Source common functions . /tmp/ks-functions.sh +KS="pxeboot post:" + anaconda_logdir=/var/log/anaconda mkdir -p $anaconda_logdir @@ -82,12 +84,36 @@ else NOVERIFYSSL_WGET_OPT="" fi -cd /var/www/pages -mkdir -p feed/rel-xxxPLATFORM_RELEASExxx/Packages -mkdir -p feed/rel-xxxPLATFORM_RELEASExxx/repodata -cd feed/rel-xxxPLATFORM_RELEASExxx +FEED_DIR=/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx + +mkdir -p ${FEED_DIR}/Packages +mkdir -p ${FEED_DIR}/repodata +cd ${FEED_DIR} + feed_url=xxxHTTP_URLxxx declare -i cut_dirs=NUM_DIRS + +# download the package_checksums file if /mnt/sysimage is mounted + +if [ mountpoint -q /mnt/sysimage ]; then + wlog "${KS} Downloading package_checksums from controller" + + pkg_file=packages_list + pkg_file_loc=/mnt/sysimage/usr/local/share/pkg-list + + if [ ! -d ${pkg_file_loc} ]; then + mkdir -p ${pkg_file_loc} + fi + + wlog "${KS} Downloading from ${feed_url} to ${pkg_file_loc}/${pkg_file}" + wget ${NOVERIFYSSL_WGET_OPT} -O ${pkg_file_loc} ${feed_url}/${pkg_file} \ + -o $anaconda_logdir/${pkg_file}.log \ + || wlog "${KS} Failed to download packages_list from controller" + + wlog "${KS} Copying ${pkg_file_loc}/${pkg_file} to ${FEED_DIR}" + cp ${pkg_file_loc}/${pkg_file} ${FEED_DIR} +fi + echo "Mirroring software repository (may take several minutes)..." >/dev/console 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 \ diff --git a/bsp-files/kickstarts/post_usb_controller.cfg b/bsp-files/kickstarts/post_usb_controller.cfg index 822cd323..9274e22b 100644 --- a/bsp-files/kickstarts/post_usb_controller.cfg +++ b/bsp-files/kickstarts/post_usb_controller.cfg @@ -53,12 +53,33 @@ EOF # Note, this section is different and replaced with a wget # if doing the initial install off the network %post --nochroot + +. /tmp/ks-functions.sh + +KS="usb post:" + if [ -d /mnt/install/source ]; then srcdir=/mnt/install/source else srcdir=/run/install/repo fi +pkg_dir=/mnt/sysimage/usr/local/share/pkg-list + +if [ ! mountpoint -q /mnt/sysimage ]; then + wlog "${KS} /mnt/sysimage not mounted. The installation will fail." + exit -1 +fi + +if [ ! -d ${pkg_dir} ]; then + mkdir -p ${pkg_dir} +fi + +if [ -f ${srcdir}/package_checksums ]; then + cp ${srcdir}/package_checksums ${pkg_dir}/packages_list + cp ${srcdir}/package_checksums /mnt/sysimage/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/packages_list +fi + if [ -d $srcdir/Packages ] ; then mkdir -p /mnt/sysimage/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx cp -r $srcdir/Packages /mnt/sysimage/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/Packages diff --git a/bsp-files/upgrades/import.sh b/bsp-files/upgrades/import.sh index 28d7396f..53e2eb30 100644 --- a/bsp-files/upgrades/import.sh +++ b/bsp-files/upgrades/import.sh @@ -62,3 +62,18 @@ if [ -d $ISO_DIR/patches ]; then | xargs --no-run-if-empty -I files cp --preserve=all files /opt/patching/packages/${VERSION}/ fi +# copy package checksum if it exists + +PKG_FILE=package_checksums +PKG_FILE_LOC=/usr/local/share/pkg-list + +if [ -f ${ISO_DIR}/${PKG_FILE} ]; then + + DEST_PKG_FILE=packages_list + if [ ! -d ${PKG_FILE_LOC} ]; then + mkdir -p ${PKG_FILE_LOC} + fi + + cp ${ISO_DIR}/${PKG_FILE} ${PKG_FILE_LOC}/${DEST_PKG_FILE} + cp ${ISO_DIR}/${PKG_FILE} ${FEED_DIR}/${DEST_PKG_FILE} +fi