Create new pxeboot feed refresh script and service

This update introduces a new script that can be called
by patching to refresh the kernel, initrd and other
system node install feed staged files in support of
kernel patching.

This update also introduces and enables new service file
that triggers the creation of the pxeboot feeds or refreshes
the pxeboot feeds if what they contain does not match the
content in /boot.

Both new script and service files are added to the
pxe-network-installer package so they get installed
into the filesystem properly.

Lastly, there are 2 kickstart changes implemented.
 1. The kickstart code that copied the kickstart files from
      /var/www/pages/feed/rel-xx.xx/
      to
      /var/www/pages/feed/rel-xx.xx/kickstart
    is removed in favor of the pxe-network-installer package
    doing that automatically.
 2. The kickstart is modified to remove the previous pxeboot
    feed fetch and creation function.
    One exception to this is the efi.img file, its fetch remains.
    Note the efi image is currenly not included in the /boot dir.

Test Plan:

PASS: Verify Debian build and AIO DX install (cd and pxe installs)
PASS: Verify Debian Standard 2+1 DX system install
PASS: In above cases verify end-to-end handling of the following
      test case staging.
PASS: Verify pxeboot feed staging on subcloud controller-0 install
PASS: Verify pxeboot feed file positioning in
      - /var/pxeboot/rel-xx.xx (kernel and initrd images)
      - /var/www/pages/feed/rel-xx.xx/pxeboot (kernel/initrd images)
      - /var/www/pages/feed/rel-xx.xx/pxeboot/EFI/BOOT (other files)
      - /var/pxeboot and /var/www/pages/feed/rel-xx.xx (efi.img)
PASS: Verify rsync bypass for the above cases when the files match
      - complete and partial cases
PASS: Verify staging when the stage dirs are missing
      - complete and partial cases
PASS: Verify staging when stage files mismatch
      - complete and partial cases
PASS: Verify service enable on controllers for AIO and STD configs
PASS: Verify kickstart file position change
PASS: Verify shellcheck static analysis
PASS: Verify pxeboot_feed.sh script error handling
PASS: Verify pxeboot_feed.sh script logging

Story: 2009968
Task: 46789
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
Change-Id: Ic98b2686c417103749cb777adb28ac73ac1d397c
This commit is contained in:
Eric MacDonald 2022-11-15 23:49:29 +00:00
parent 1132443626
commit b5d22ef3e7
6 changed files with 247 additions and 101 deletions

View File

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

View File

@ -9,10 +9,12 @@ export platform_release="$(shell grep SW_VERSION /usr/include/build_info.h | cut
override_dh_auto_configure:
sed -i "s/xxxSW_VERSIONxxx/${platform_release}/g" debian-pxe-* efi-debian-pxe-*
sed -i "s/xxxSW_VERSIONxxx/${platform_release}/g" pxeboot_feed.sh
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}
install -v -d -m 755 $(ROOT)/usr/share/licenses/pxe-network-installer-1.0.0
@ -30,6 +32,8 @@ override_dh_install:
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 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
# Legacy BIOS System Node Install grub menus
install -p -D -m 700 debian-pxe-controller-install $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxe-controller-install-${platform_release}
@ -58,3 +62,6 @@ override_dh_install:
install -p -D -m 700 pxeboot/vesamenu.c32 $(ROOT)/var/pxeboot
dh_install
override_dh_installsystemd:
dh_installsystemd -ppxe-network-installer pxeboot-feed.service

View File

@ -0,0 +1,13 @@
[Unit]
Description=StarlingX Pxeboot Feed Refresh
After=config.service
Before=pmon.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/pxeboot_feed
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,219 @@
#!/bin/bash
#############################################################################
# Copyright (c) 2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This utility is used to create or update the following directories
#
# /var/www/pages/feed/rel-xx.xx/pxeboot
# /var/pxeboot/rel-xx.xx
#
# ... with the kernel, initrd and other images and signature files from /boot
#
#############################################################################
#
# chkconfig: 2345 98 2
#
### BEGIN INIT INFO
# Provides: pxeboot_feed
# Required-Start: $null
# Required-Stop: $null
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: StarlingX Installer Pxeboot Feed Refresh
### END INIT INFO
# Script has options 'debug' argument
debug=false
[ -n "${1}" ] && [ "${1}" == "debug" ] && debug=true
LOG_TAG=${LOG_TAG:-$(basename "${0}")}
# return code
RETVAL=1
#############################################################################
# Name : ilog
# Purpose : log info message
# Parmaeter: message to log
# Returns : none
#############################################################################
function ilog {
logger -t "${LOG_TAG}" "${@}"
}
#############################################################################
# Name : dlog
# Purpose : log and echo debug messages
# Parmaeter: message to log
# Returns : none
#############################################################################
function dlog {
if [ "${debug}" == true ] ; then
logger -t "${LOG_TAG}" "${@}"
fi
}
#############################################################################
# Name : rsync_if_not_equal
# Purpose : Speed up the refresh service.
# Assumptions: Reads are faster thyan writes
# Equal case is more likely
# Parameters : $1 - src path/file
# $2 - dst path/file
# Returns : none
#############################################################################
function rsync_if_not_equal {
local src_file="${1}"
local dst_file="${2}"
local need_rsync=false
if [ -e "${src_file}" ] ; then
if [ -e "${dst_file}" ] ; then
src=( $(md5sum "${src_file}") )
dst=( $(md5sum "${dst_file}") )
if [ "${src[0]}" == "${dst[0]}" ] ; then
dlog "bypass rsync ; ${src_file}" and "${dst_file} are equal"
else
need_rsync=true
fi
else
need_rsync=true
fi
else
ilog "Warning: '${src_file}' not found"
fi
if [ "${need_rsync}" = true ] ; then
ilog "syncing ${src_file} to ${dst_file}"
rsync "${src_file}" "${dst_file}"
fi
}
#############################################################################
# Override release with what is found in platform.conf
rel=""
if [ -e "/etc/platform/platform.conf" ] ; then
rel=$(grep sw_version < /etc/platform/platform.conf | cut -d '=' -f 2)
fi
if [ -z "${rel}" ] ; then
rel="xxxSW_VERSIONxxx"
fi
# pxeboot objects path
feed="/var/www/pages/feed/rel-${rel}"
pxefeed="${feed}/pxeboot"
pxeboot="/var/pxeboot"
# ensure the deepest directories are created
if [ ! -d "${pxefeed}/EFI/BOOT" ] ; then
mkdir -p "${pxefeed}/EFI/BOOT" > /dev/null 2>&1 || exit ${RETVAL}
fi
if [ ! -d "${pxeboot}rel-${rel}" ] ; then
mkdir -p "${pxeboot}/rel-${rel}" > /dev/null 2>&1 || exit ${RETVAL}
fi
if [ ! -d "${pxeboot}/EFI/BOOT" ] ; then
mkdir -p "${pxeboot}/EFI/BOOT" > /dev/null 2>&1 || exit ${RETVAL}
fi
base_path="/boot/ostree"
declare -a file_list=()
if [ ! -d "${base_path}" ] ; then
ilog "Error: base path '${base_path}' does not exist"
exit ${RETVAL}
fi
file_list=( $(find "${base_path}" -name 'initramfs*') )
file_list+=( $(find "${base_path}" -name 'vmlinuz*') )
dlog "${file_list[*]}"
for f in "${file_list[@]}" ; do
path_file1=""
filename=$(basename "${f}")
dlog "File: ${filename} ... ${f}"
if [ "${filename}" == "initramfs.sig" ] ; then
path_file1="${pxeboot}/rel-${rel}/initrd.sig"
path_file2="${pxefeed}/initrd.sig"
elif [ "${filename}" == "initramfs" ] ; then
path_file1="${pxeboot}/rel-${rel}/initrd"
path_file2="${pxefeed}/initrd"
elif [ "${filename}" == "vmlinuz.sig" ] ; then
path_file1="${pxeboot}/rel-${rel}/bzImage.sig"
path_file2="${pxefeed}/bzImage.sig"
elif [ "${filename}" == "vmlinuz" ] ; then
path_file1="${pxeboot}/rel-${rel}/bzImage"
path_file2="${pxefeed}/bzImage"
elif [[ "${filename}" == *"rt-amd64.sig"* ]] ; then
path_file1="${pxeboot}/rel-${rel}/bzImage-rt.sig"
path_file2="${pxefeed}/bzImage-rt.sig"
elif [[ "${filename}" == *"rt-amd64"* ]] ; then
path_file1="${pxeboot}/rel-${rel}/bzImage-rt"
path_file2="${pxefeed}/bzImage-rt"
elif [[ "${filename}" == *"amd64.sig"* ]] ; then
path_file1="${pxeboot}/rel-${rel}/bzImage-std.sig"
path_file2="${pxefeed}/bzImage-std.sig"
elif [[ "${filename}" == *"amd64"* ]] ; then
path_file1="${pxeboot}/rel-${rel}/bzImage-std"
path_file2="${pxefeed}/bzImage-std"
else
ilog "ignoring unknown file: ${f}"
continue
fi
rsync_if_not_equal "${f}" "${path_file1}"
rsync_if_not_equal "${f}" "${path_file2}"
done
# Other image files
file1="LockDown.efi.sig"
file2="LockDown.efi"
file3="bootx64.efi"
file4="grub.cfg.sig"
file5="grubx64.efi"
file6="mmx64.efi"
file_list=( $(find "${base_path}" \
-name "${file1}" -o \
-name "${file2}" -o \
-name "${file3}" -o \
-name "${file4}" -o \
-name "${file5}" -o \
-name "${file6}") )
dlog "${file_list[*]}"
for f in "${file_list[@]}" ; do
filename=$(basename "${f}")
dlog "File: ${filename} ... ${f}"
path_file="EFI/BOOT/${filename}"
path_file1=""
if [[ "${filename}" == *"${file1}"* || \
"${filename}" == *"${file2}"* || \
"${filename}" == *"${file3}"* || \
"${filename}" == *"${file4}"* || \
"${filename}" == *"${file5}"* || \
"${filename}" == *"${file6}"* ]] ; then
path_file1="${pxeboot}/${path_file}"
path_file2="${pxefeed}/${path_file}"
else
ilog "ignoring unknown file: ${f}"
continue
fi
rsync_if_not_equal "${f}" "${path_file1}"
rsync_if_not_equal "${f}" "${path_file2}"
done
# rsync efi.img file
rsync_if_not_equal "${pxeboot}/efi.img" "${feed}/efi.img"
RETVAL=0
exit ${RETVAL}

View File

@ -13,7 +13,7 @@ override_dh_auto_configure:
dh_auto_configure
override_dh_install:
install -d -m 755 $(ROOT)/var/www/pages/feed/rel-${platform_release}
install -p -D -m 700 kickstart.cfg $(ROOT)/var/www/pages/feed/rel-${platform_release}
install -p -D -m 700 miniboot.cfg $(ROOT)/var/www/pages/feed/rel-${platform_release}
install -d -m 755 $(ROOT)/var/www/pages/feed/rel-${platform_release}/kickstart
install -p -D -m 700 kickstart.cfg $(ROOT)/var/www/pages/feed/rel-${platform_release}/kickstart
install -p -D -m 700 miniboot.cfg $(ROOT)/var/www/pages/feed/rel-${platform_release}/kickstart
dh_install

View File

@ -2768,7 +2768,6 @@ if [ "${controller}" = true ] ; then
pull_options="${commits} --mirror"
pxeboot="${IMAGE_ROOTFS}/var/pxeboot"
feed="${IMAGE_ROOTFS}/var/www/pages/feed/rel-${sw_release}"
subcloud_feed="${IMAGE_ROOTFS}/var/www/pages/iso/rel-${sw_release}"
repo="${feed}/ostree_repo"
mkdir -p "${repo}"
mkdir -p "${feed}"
@ -2839,26 +2838,11 @@ if [ "${controller}" = true ] ; then
####################################################################
# Setup the feed and pxeboot directories
#
# All the feed and pxeboot setup operation are off of /var which is
# common to normal and rollback filesystems.
# Therefore this only needs to be done once like the ostree repo
# pull but for a different reason.
#
# Fetch and add efi.img to /var/pxeboot
#####################################################################
mkdir -p "${pxeboot}/rel-${sw_release}"
mkdir -p "${pxeboot}/EFI/BOOT"
mkdir -p "${feed}/pxeboot"
mkdir -p "${feed}/kickstart"
mkdir -p "${feed}/pxeboot/EFI/BOOT"
mkdir -p "${subcloud_feed}/pxeboot"
mkdir -p "${subcloud_feed}/kickstart"
mkdir -p "${subcloud_feed}/pxeboot/EFI/BOOT"
# Check for noverifyssl
if grep -q noverifyssl /proc/cmdline; then
NOVERIFYSSL_WGET_OPT="--no-check-certificate"
@ -2868,52 +2852,12 @@ if [ "${controller}" = true ] ; then
# handle USB install
if is_usb_install -eq 0 ; then
# populate /var/pxeboot
ilog "Copy bzImage, initrd and respective secure boot .sig files"
ilog "... from /instboot/pxeboot to ${pxeboot}/rel-${sw_release}"
cp -a /instboot/pxeboot/bzImage* ${pxeboot}/rel-${sw_release}
cp -a /instboot/pxeboot/initrd* ${pxeboot}/rel-${sw_release}
cp -a /instboot/efi.img ${pxeboot}
cp -a /instboot/pxeboot/EFI ${pxeboot}
for f in bootx64.efi bootx64-nosig.efi grub.cfg.sig grubx64.efi LockDown.efi LockDown.efi.sig mmx64.efi ; do
cp -a /instboot/pxeboot/EFI/BOOT/${f} ${pxeboot}/EFI/BOOT
done
# populate feeds
ilog "Stage images and kickstarts from /instboot to feeds"
for this_feed in ${feed} ${subcloud_feed} ; do
cp -a /instboot/pxeboot/bzImage* ${this_feed}/pxeboot
cp -a /instboot/pxeboot/initrd* ${this_feed}/pxeboot
cp -a /instboot/efi.img ${this_feed}
cp -a /instboot/pxeboot/EFI ${this_feed}/pxeboot
cp -a /instboot/kickstart/kickstart.cfg ${this_feed}/kickstart
cp -a /instboot/kickstart/miniboot.cfg ${this_feed}/kickstart
done # feeds
# handle pxeboot install
else
pxeurl=$(echo $insturl | sed -e s/ostree_repo//)
# Fetch and stage the kernels, signature files and initrd
ilog "Fetch bzImage and initrd files from ${pxeurl}/pxeboot"
pushd ${pxeboot}/rel-${sw_release} > /dev/null
for f in bzImage bzImage-rt bzImage-rt.sig bzImage.sig bzImage-std bzImage-std.sig initrd initrd.sig ; do
ilog "... fetching ${f} to ${pxeboot}/rel-${sw_release}"
wget ${NOVERIFYSSL_WGET_OPT} ${pxeurl}/pxeboot/${f} -o /${LAT_DIR}/wget.tmp
[ $? -ne 0 ] && report_failure_with_msg "Failed to find ${pxeurl}/pxeboot/${f}"
cat /${LAT_DIR}/wget.tmp >> /${LAT_DIR}/wget_pxeboot_setup.log
# also copy to the feeds
ilog "... copying ${f} to ${feed}/pxeboot"
cp -a ${f} ${feed}/pxeboot
ilog "... copying ${f} to ${subcloud_feed}/pxeboot"
cp -a ${f} ${subcloud_feed}/pxeboot
done
popd > /dev/null
# Fetch and stage the efi.img
ilog "Fetch efi.img from ${pxeurl} to ${pxeboot}"
pushd ${pxeboot} > /dev/null
@ -2927,53 +2871,14 @@ if [ "${controller}" = true ] ; then
# also copy to the feeds
ilog "... copying ${f} to ${feed}"
cp -a ${f} ${feed}
ilog "... copying ${f} to ${subcloud_feed}"
cp -a ${f} ${subcloud_feed}
done
popd > /dev/null
# Fetch and stage the boot loaders
pushd ${pxeboot}/EFI/BOOT > /dev/null
ilog "Copy files from ${pxeurl}/pxeboot/EFI/BOOT to ${pxeboot}/EFI/BOOT"
for f in bootx64.efi bootx64-nosig.efi grub.cfg.sig grubx64.efi LockDown.efi LockDown.efi.sig mmx64.efi; do
ilog "... fetching ${f} to ${pxeboot}/EFI/BOOT"
wget ${NOVERIFYSSL_WGET_OPT} ${pxeurl}/pxeboot/EFI/BOOT/${f} -o /${LAT_DIR}/wget.tmp
[ $? -ne 0 ] && report_failure_with_msg "Failed to get ${pxeurl}/pxeboot/EFI/BOOT/${f}"
cat /${LAT_DIR}/wget.tmp >> /${LAT_DIR}/wget_pxeboot_setup.log
# also copy to the feeds
ilog "... copying ${f} to ${feed}/pxeboot/EFI/BOOT"
cp -a ${f} ${feed}/pxeboot/EFI/BOOT
ilog "... copying ${f} to ${subcloud_feed}/pxeboot/EFI/BOOT"
cp -a ${f} ${subcloud_feed}/pxeboot/EFI/BOOT
done
popd > /dev/null
# Fetch and stage the kickstarts
ilog "Fetch kickstarts from ${pxeurl} to ${feed}/kickstart"
pushd ${feed}/kickstart > /dev/null
for f in kickstart.cfg miniboot.cfg ; do
ilog "... fetching ${f} to ${feed}/kickstart"
wget ${NOVERIFYSSL_WGET_OPT} ${pxeurl}/kickstart/${f} -o /${LAT_DIR}/wget.tmp
[ $? -ne 0 ] && report_failure_with_msg "Failed to get ${pxeurl}/kickstart/${f}"
cat /${LAT_DIR}/wget.tmp >> /${LAT_DIR}/wget_pxeboot_setup.log
ilog "... copying ${f} to ${subcloud_feed}/kickstart"
cp -a ${f} ${subcloud_feed}/kickstart
done
[ -e /${LAT_DIR}/wget.tmp ] && rm -f /${LAT_DIR}/wget.tmp
popd > /dev/null
fi
# Temporary WorkAround: The current UEFI pxeboot loader does not call the
# default provisioning grub menu in /var/pxeboot/pxelinux.cfg/grub.cfg.
#
# While the above issue is investigated, to support DX and system node
# install for UEFI servers this code moves the lat grub.cfg aside and
# creates a link to the default provisioning mac based grub menu.
# Save and override the LAT grub menu by creating a link to the default
# provisioning mac based grub menu.
pushd ${pxeboot}/EFI/BOOT > /dev/null
if [ ! -L grub.cfg ] ; then
if [ -e grub.cfg ] ; then