diff --git a/kickstart/files/miniboot.cfg b/kickstart/files/miniboot.cfg index b521019d..e8edf6f7 100644 --- a/kickstart/files/miniboot.cfg +++ b/kickstart/files/miniboot.cfg @@ -1476,6 +1476,59 @@ udevadm settle --timeout=300 || report_failure_with_msg "udevadm settle failed" # Rescan LVM cache to avoid warnings for VGs that were recreated. pvscan --cache 2>/dev/null +# Stage the ostree_repo in /sysroot. +# Doing so avoids a double ostree pull of the ostree_repo over the network. +if [ "${controller}" = true ] ; then + ilog "****************************************************" + ilog "** OSTree Initialization **" + ilog "****************************************************" + ############################################################## + # + # Controller node network installs pull the ostree_repo from + # the pxeboot server's feed directory in 'archive' mode into + # /sysroot as a local staging location. In this case LAT's + # INSTL (install) variable is updated to install from that + # local stage. + # + # This is done to avoid a second (double) ostree_repo pull + # over the network that would otherwise be needed to populate + # the controller's feed directory. + # + # This staged ostree_repo archive is later moved to the + # controller's feed directory to be used for future installs + # of other system nodes from this controller. + # + ############################################################## + + PHYS_SYSROOT="/sysroot" + ilog "Initial pull of ostree into $PHYS_SYSROOT, insturl=$insturl, instbr=$instbr" + + OSTREE_ROOT_DEVICE="LABEL=otaroot" + mkdir -p ${PHYS_SYSROOT} + mount -o rw,noatime "${OSTREE_ROOT_DEVICE}" "${PHYS_SYSROOT}" || elog "Error mounting ${OSTREE_ROOT_DEVICE}" + + repo="${PHYS_SYSROOT}/var/www/pages/feed/rel-xxxPLATFORM_RELEASExxx/ostree_repo" + mkdir -p "${repo}" + + # Tell LAT to install friom this local stage + # i.e. override where LAT installs from. + export instl=${repo} + export INSTL=${instl} + + ostree --repo=${repo} init --mode=archive + if [ "${insturl}" = "file://NOT_SET" ] ; then + ilog "Using ostree remote: ${instbr} file:///instboot/ostree_repo" + ostree --repo=${repo} remote add ${instbr} file:///instboot/ostree_repo + else + ilog "Using ostree remote: ${instbr} ${insturl}" + ostree --repo=${repo} remote add ${instbr} ${insturl} + fi + + ilog "ostree --repo=${repo} pull --depth=-1 --mirror ${instbr}:${instbr}" + ostree --repo=${repo} pull --depth=-1 --mirror ${instbr}:${instbr} + umount ${PHYS_SYSROOT} +fi + true %end @@ -1884,37 +1937,33 @@ true HOOK_LABEL="post_nochroot" . /tmp/lat/ks_functions.sh -########################################################### -# From post_miniboot_controller.cfg -########################################################### +ilog "****************************************************" +ilog "*** Post Nochroot - Restage OSTree repo **" +ilog "****************************************************" +ilog "IMAGE_ROOTFS=${IMAGE_ROOTFS}" -ilog "Local Install Check" +get_variable "ostree_repo_fetched" +OSTREE_REPO_FETCHED=$? -# TODO: this is a second pull, which should be avoided. -# Remove this second pull and look at a single solution -# where the archive is stored first and then installed. -# if [ "${controller}" = true ] ; then - # Note: this is updated by the build: - sw_release="xxxPLATFORM_RELEASExxx" + sw_release="xxxPLATFORM_RELEASExxx" # updated by the build + feed="${IMAGE_ROOTFS}/var/www/pages/feed/rel-${sw_release}" repo="${feed}/ostree_repo" - if [ ! -d "$repo" ]; then - mkdir -p "${repo}" - ilog "Initializing ostree repo at: $repo" - # get the remote installation details - ostree --repo=${repo} init --mode=archive - - if [ "${insturl}" = "file://NOT_SET" ] ; then - ostree --repo=${repo} remote add ${instbr} file:///instboot/ostree_repo - else - ostree --repo=${repo} remote add ${instbr} ${insturl} - fi - - ilog "Populating: ostree --repo=${repo} pull --mirror ${instbr}:${instbr}" - ostree --repo=${repo} pull --mirror ${instbr}:${instbr} + if [ ${OSTREE_REPO_FETCHED} -eq 0 ] ; then + ilog "Stage ostree_repo from previous /sysroot pull to ${repo}" + mv -f /sysroot/var/www/pages/feed/rel-${sw_release}/ostree_repo ${IMAGE_ROOTFS}/var/www/pages/feed/rel-${sw_release}/ fi + # Set ostree remote to the local install feed + file_feed="file:///var/www/pages/feed/rel-${sw_release}/ostree_repo/" + feed_branch="starlingx" + ilog "Replacing ostree sysroot remote ${instname} with: ${file_feed} ${feed_branch}" + ostree --repo=/sysroot/ostree/repo remote delete ${instname} + ostree --repo=/sysroot/ostree/repo remote add ${instname} ${file_feed} ${feed_branch} + + # This fetch is only needed once because the repo is stored in /var + set_variable "ostree_repo_fetched" fi true