Refactor from-load pxe setup in to-load kickstart

Details: Since this is the first Debian to Debian upgrade,
we need to refactor some existing code that is used for
centOS upgrade.

This commit is

	1. clean up CentOS related code
	2. copy to-load pxeboot-update.sh to /etc/ during the import
	   instead of /usr/sbin/
	3. install to-load pxeboot-update.sh in /etc/ instead of
	   /usr/sbin/ during iso installation
	4. update kickstart Upgrade Support accordingly to set up
    	   from-load feed

Test Plan:

PASS: built the iso for upgrade
PASS: upgraded from 22.12 to 23.09 in DX
PASS: downgrade from 23.09 to 22.12 in DX

Depends-on: https://review.opendev.org/c/starlingx/tools/+/881882

Task: 47805
Story: 2010651
Signed-off-by: Junfeng (Shawn) Li <junfeng.li@windriver.com>
Change-Id: Ia67f5f3e66f5b33c3d7fb8d93a15547d59eaa71e
This commit is contained in:
junfeng-li 2023-04-28 15:21:36 +00:00
parent 1455771c9c
commit d9d7111cd8
4 changed files with 46 additions and 122 deletions

View File

@ -50,75 +50,37 @@ fi
rm -rf ${FEED_DIR}
mkdir -p ${FEED_DIR}
# Centos will be temporarily supported for testing. The import code
# for Centos 22.12 will be removed soon. No need for any fancy way
# to detect if it is a Debian iso, just check existance of ostree_repo
# TODO: remove the "else" clause
if [ -d ${ISO_DIR}/ostree_repo ]; then
# it is a Debian iso.
# copy pxeboot, kickstart, ostree_repo to feed directory
echo "Copy kickstart to ${FEED_DIR}"
cp -rp ${ISO_DIR}/kickstart ${FEED_DIR}/
echo "Copy pxeboot to ${FEED_DIR}"
cp -rp ${ISO_DIR}/pxeboot ${FEED_DIR}/
echo "Copy ostree_repo to ${FEED_DIR}"
cp -rp ${ISO_DIR}/ostree_repo ${FEED_DIR}/
# copy pxeboot, kickstart, ostree_repo to feed directory
echo "Copy kickstart to ${FEED_DIR}"
cp -rp ${ISO_DIR}/kickstart ${FEED_DIR}/
echo "Copy pxeboot to ${FEED_DIR}"
cp -rp ${ISO_DIR}/pxeboot ${FEED_DIR}/
echo "Copy ostree_repo to ${FEED_DIR}"
cp -rp ${ISO_DIR}/ostree_repo ${FEED_DIR}/
echo "Copy install_uuid to ${FEED_DIR}"
cp ${CURRENT_FEED_DIR}/install_uuid ${FEED_DIR}/
echo "Copy install_uuid to ${FEED_DIR}"
cp ${CURRENT_FEED_DIR}/install_uuid ${FEED_DIR}/
mkdir ${FEED_DIR}/upgrades
echo "Copy pxeboot-update-${VERSION}.sh to ${FEED_DIR}/upgrades"
cp ${ISO_DIR}/upgrades/pxeboot-update-${VERSION}.sh ${FEED_DIR}/upgrades/
mkdir ${FEED_DIR}/upgrades
echo "Copy pxeboot-update-${VERSION}.sh to ${FEED_DIR}/upgrades"
cp ${ISO_DIR}/upgrades/pxeboot-update-${VERSION}.sh ${FEED_DIR}/upgrades/
echo "Copy efi.img to ${FEED_DIR}"
cp ${ISO_DIR}/efi.img ${FEED_DIR}/
# for upgrade from 22.06 to Debian 22.12, patch during upgrade is not supported
echo "Copy efi.img to ${FEED_DIR}"
cp ${ISO_DIR}/efi.img ${FEED_DIR}/
# for upgrade from 22.06 to Debian 22.12, patch during upgrade is not supported
# only copy the patch meta is enough
if [ -d ${ISO_DIR}/patches ]; then
rsync -ac ${ISO_DIR}/patches/ /opt/patching/metadata/committed/
# copy patch metadata to feed, so to be picked up by kickstart to copy to release N+1
mkdir ${FEED_DIR}/patches -p
cp -a ${ISO_DIR}/patches/* ${FEED_DIR}/patches/
fi
else
# this is a Centos iso
trap cleanup 0
echo "Copy pxeboot-update-${SW_VERSION}.sh to ${CURRENT_FEED_DIR}/upgrades"
mkdir -p ${CURRENT_FEED_DIR}/upgrades/
# In stx 8.0, the pxeboot-update-22.12.sh is in /usr/sbin
# In stx 9.0, the pxeboot-update-23.09.sh is in /etc due to the ostree managed
# /usr directory.
cp -rp /usr/sbin/pxeboot-update-22.12.sh ${CURRENT_FEED_DIR}/upgrades/ 2>/dev/null || \
cp -rp /etc/pxeboot-update-${SW_VERSION}.sh ${CURRENT_FEED_DIR}/upgrades/
TMP_RPM=/tmp/cpio
rm -rf ${TMP_RPM}
cp -rp ${ISO_DIR}/Packages ${ISO_DIR}/repodata ${ISO_DIR}/LiveOS ${FEED_DIR}/
cp -p ${CURRENT_FEED_DIR}/install_uuid ${FEED_DIR}/
if [ -d ${ISO_DIR}/patches ]; then
mkdir -p /var/www/pages/updates/rel-${VERSION}
cp -r ${ISO_DIR}/patches/Packages ${ISO_DIR}/patches/repodata /var/www/pages/updates/rel-${VERSION}/
rsync -ac ${ISO_DIR}/patches/metadata/ /opt/patching/metadata/
mkdir -p /opt/patching/packages/${VERSION}
find /var/www/pages/updates/rel-${VERSION}/Packages -name '*.rpm' \
| 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="${VERSION}_packages_list.txt"
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}/${PKG_FILE}
fi
fi
# The pxelinux.cfg.files directory is from the current release feed in Debian.
echo "Copy pxelinux.cfg.files directory to ${CURRENT_FEED_DIR}"
mkdir -p ${CURRENT_FEED_DIR}/pxeboot/pxelinux.cfg.files/
find /var/pxeboot/pxelinux.cfg.files -type f ! -name "*${VERSION}" \
-exec cp -p {} ${CURRENT_FEED_DIR}/pxeboot/pxelinux.cfg.files/ \;
echo 'import has completed'

View File

@ -2,3 +2,4 @@ var/pxeboot
usr/sbin
etc/init.d/pxeboot_feed
lib/systemd/system/pxeboot-feed.service
etc/pxeboot-update*

View File

@ -13,7 +13,6 @@ override_dh_auto_configure:
dh_auto_configure
override_dh_install:
install -v -d -m 755 $(ROOT)/usr/bin
install -v -d -m 755 $(ROOT)/lib/systemd/system
install -v -d -m 755 $(ROOT)/var/pxeboot/pxelinux.cfg.files
install -v -d -m 755 $(ROOT)/var/pxeboot/rel-${platform_release}
@ -25,13 +24,12 @@ override_dh_install:
install -v -m 644 pxe-grub.cfg $(ROOT)/var/pxeboot/pxelinux.cfg.files/grub.cfg
install -v -m 644 pxe-grub.cfg.static $(ROOT)/var/pxeboot/pxelinux.cfg.files/grub.cfg.static
install -v -m 644 grub.cfg.stx $(ROOT)/var/pxeboot/pxelinux.cfg.files/grub.cfg.stx
install -p -D -m 700 pxeboot-update.sh $(ROOT)/usr/sbin/pxeboot-update-${platform_release}.sh
# Add controller-0 pxeboot install grub menus and setup utility
install -p -D -m 644 pxeboot.cfg.debian $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxeboot.cfg.debian
install -p -D -m 644 efi-pxeboot.cfg.debian $(ROOT)/var/pxeboot/pxelinux.cfg.files/efi-pxeboot.cfg.debian
install -p -D -m 755 pxeboot_setup.sh $(ROOT)/usr/sbin/pxeboot_setup.sh
install -p -D -m 755 pxeboot-update.sh ${ROOT}/usr/sbin/pxeboot-update-${platform_release}.sh
install -p -D -m 755 pxeboot-update.sh ${ROOT}/etc/pxeboot-update-${platform_release}.sh
install -p -D -m 644 pxeboot-feed.service $(ROOT)/lib/systemd/system/pxeboot-feed.service
install -p -D -m 755 pxeboot_feed.sh $(ROOT)/etc/init.d/pxeboot_feed

View File

@ -2770,65 +2770,28 @@ if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/${hostname}/upgrade_in_pro
-o /${LAT_DIR}/wget_sw_repo.log --exclude-directories=/feed/rel-${sw_release} ${feed_url} \
|| report_failure_with_msg "Mirroring software repository failed"
# Sync patching repository
updates_url=http://pxecontroller:${http_port}/updates/
wget --mirror --no-parent --no-host-directories --reject 'index.html*' --reject '*.log' \
-o /${LAT_DIR}/wget_sw_patch_repo.log --exclude-directories=/updates/rel-${sw_release} ${updates_url} \
|| report_failure_with_msg "Mirroring software updates failed"
# The /v1/upgrade/${hostname}/upgrade_in_progress endpoint accepts any textual data
# as hostname and returns system-wide upgrade state
# This is a placeholder as on Debian the hostname is unknown during kickstart.
# In contrast, the hostname is available on CentOS
# Check whether a second release is installed
CURRENT_REL_DIR=rel-${sw_release}
OTHER_REL_DIR=
for REL_DIR in ${IMAGE_ROOTFS}/var/www/pages/feed/*; do
if [[ ! ${REL_DIR} =~ "${sw_release}" ]]; then
OTHER_REL_DIR=`basename ${REL_DIR}`
OTHER_REL_VERSION=${OTHER_REL_DIR:4}
break
fi
done
OTHER_REL_DIR=$(find ${IMAGE_ROOTFS}/var/www/pages/feed/* -maxdepth 0 -type d ! -name *${sw_release}*)
OTHER_REL_VERSION=$(basename "${OTHER_REL_DIR}")
# If second release is installed, find the latest version of the installer
if [ ! -z "${OTHER_REL_DIR}" ]; then
PATCH_RPM=`find ${IMAGE_ROOTFS}/var/www/pages/updates/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1`
BASE_RPM=`find ${IMAGE_ROOTFS}/var/www/pages/feed/${OTHER_REL_DIR}/Packages -name 'pxe-network-installer*' | sort -V | tail -1`
fi
if [ ! -z "${PATCH_RPM}" ]; then
INSTALL_RPM=${PATCH_RPM}
elif [ ! -z "${BASE_RPM}" ]; then
INSTALL_RPM=${BASE_RPM}
else
report_failure_with_msg "Unable to find pxe-network-installer RPM for ${OTHER_REL_DIR}. Aborting installation."
fi
ilog "Installing pxeboot files for release ${OTHER_REL_DIR} from ${INSTALL_RPM}"
TMP_RPM=${IMAGE_ROOTFS}/tmp/pxe-network-installer
mkdir ${TMP_RPM}
pushd ${TMP_RPM}
${IMAGE_ROOTFS}/usr/bin/rpm2cpio ${INSTALL_RPM} | cpio -idm \
|| report_failure_with_msg "Failed to extract pxe-network-installer"
PXEBOOT_DIR="/var/pxeboot/"
if [[ "${OTHER_REL_VERSION}" == "21.12" ]]; then
PXEBOOT_DIR="/pxeboot/"
fi
cp -r ${TMP_RPM}/usr ${IMAGE_ROOTFS}/ \
|| report_failure_with_msg "Failed to copy pxe-network-installer /usr"
cp -r ${TMP_RPM}${PXEBOOT_DIR}$OTHER_REL_DIR ${IMAGE_ROOTFS}/var/pxeboot/ \
|| report_failure_with_msg "Failed to copy pxe-network-installer /var/pxeboot/$OTHER_REL_DIR"
cp ${TMP_RPM}${PXEBOOT_DIR}pxelinux.cfg.files/*-${OTHER_REL_VERSION} ${IMAGE_ROOTFS}/var/pxeboot/pxelinux.cfg.files/ \
|| report_failure_with_msg "Failed to copy pxe-network-installer pxelinux.cfg files"
rm -rf ${TMP_RPM}
ilog "Installing pxeboot files for release ${OTHER_REL_DIR}"
mkdir -p ${IMAGE_ROOTFS}/var/pxeboot/${OTHER_REL_VERSION} \
|| report_failure_with_msg "Failed to create /var/pxeboot/${OTHER_REL_VERSION}"
cp -rp ${OTHER_REL_DIR}/kickstart/kickstart.cfg ${OTHER_REL_DIR}/ \
|| report_failure_with_msg "Failed to copy kickstart.cfg for to ${OTHER_REL_DIR}"
cp -rp ${OTHER_REL_DIR}/pxeboot/bzImage* ${IMAGE_ROOTFS}/var/pxeboot/${OTHER_REL_VERSION} \
|| report_failure_with_msg "Failed to copy pxeboot bzImage files for to /var/pxeboot/${OTHER_REL_VERSION}"
cp -rp ${OTHER_REL_DIR}/pxeboot/initrd* ${IMAGE_ROOTFS}/var/pxeboot/${OTHER_REL_VERSION} \
|| report_failure_with_msg "Failed to copy pxeboot initrd files for to /var/pxeboot/${OTHER_REL_VERSION}"
cp -rp ${OTHER_REL_DIR}/pxeboot/pxelinux.cfg.files/* ${IMAGE_ROOTFS}/var/pxeboot/pxelinux.cfg.files/ \
|| report_failure_with_msg "Failed to copy pxeboot pxelinux.cfg files for to /var/pxeboot/${OTHER_REL_VERSION}"
cp -rp ${OTHER_REL_DIR}/upgrades/pxeboot-update-${OTHER_REL_VERSION:4}.sh ${IMAGE_ROOTFS}/etc/ \
|| report_failure_with_msg "Failed to copy pxeboot-update-${OTHER_REL_VERSION:4}.sh to /etc/"
chmod 755 ${IMAGE_ROOTFS}/etc/pxeboot-update-${OTHER_REL_VERSION:4}.sh \
|| report_failure_with_msg "Failed to chmod 755 /etc/pxeboot-update-${OTHER_REL_VERSION:4}.sh"
fi