diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/boot b/packages/base/all/initrds/loader-initrd-files/src/bin/boot index f377bc0d..a532d5a3 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/boot +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/boot @@ -88,6 +88,7 @@ shift unset swipath host bhost port dir file dev user password scope case "${SWI}" in nfs://*/|dir:*) + echo "Mounting ${SWI}" swipath=$(swimount $SWI) if [ "$rootfs" ]; then [ -d "${swipath}/${rootfs}" ] || { echo "${SWI}${rootfs} must be an unpacked rootfs"; exit 1; } @@ -98,9 +99,18 @@ case "${SWI}" in swipath=$(swiget $SWI) ;; *) + echo "Locating ${SWI}" swipath=$(swiget $SWI) ;; esac +case "$SWI" in + *::latest) + swistamp=${SWI%:latest}${swipath##*/} + ;; + *) + swistamp=$SWI + ;; +esac echo "SWI=${SWI}" >/etc/onl/boot-config echo "CONSOLESPEED=$(stty speed)" >>/etc/onl/boot-config @@ -124,7 +134,27 @@ if [ "$testonly" ]; then exit 0 fi -. /lib/boot1 +if [ -d "${swipath}" ]; then + # rootfs is a directory + mkdir -p /newroot + umount -l /newroot 2>/dev/null || : + mount --bind "${swipath}/${rootfs}" /newroot +else + echo "$swistamp" > /etc/onl/SWI + swiprep --overlay "${swipath}${rootfs}" --unmount --swiref "$swistamp" /newroot +fi + +# +# The file /lib/boot-custom can be provided by customized builds to +# add functionality before the root is switched. +# +if [ -f /lib/boot-custom ]; then + . /lib/boot-custom +fi + +echo "Switching rootfs" # limit 16 chars since serial buffer is not flushed +kill -QUIT 1 # exec /bin/switchroot as PID 1 +sleep 30 echo "Boot failed" exit 1 diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed index 543a1e0d..00fe97d7 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed +++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed @@ -59,62 +59,26 @@ case "$SWI" in ;; esac +case "$SWI" in + *::latest) + swistamp=${SWI%:latest}${swipath##*/} + ;; + *) + swistamp=$SWI + ;; +esac + +echo "$swistamp" > /etc/onl/SWI +sed -i -e '/^SWI=/d' /etc/onl/BOOTPARAMS +echo "SWI=dir:data:/" >> /etc/onl/BOOTPARAMS + if [ "$do_unpack" ]; then - - rm -fr /mnt/onl/data/* /mnt/onl/data/.??* - mkdir /mnt/onl/data/lost+found - - swi_workdir=$(mktemp -d /mnt/onl/data/tmp-XXXXXX) - - msg_info "extracting SWI $swipath --> $swi_workdir" - unzip $swipath -d $swi_workdir - set dummy $swi_workdir/*.sqsh - if [ ! -f "$2" ]; then - msg_error "*** missing squashfs file" - exit 1 - fi - if [ $# -gt 2 ]; then - msg_error "*** too many squashfs files" - exit 1 - fi - - msg_info "extracting rootfs $2 --> /mnt/onl/data" - unsquashfs -f -d /mnt/onl/data "$2" - echo "unsquashfs status $?" - - if [ ! -f /mnt/onl/data/lib/vendor-config/onl/install/lib.sh ]; then - msg_error "*** invalid squashfs contents" - exit 1 - fi - - # Install any SWI data packages. - if [ -s $swi_workdir/swi-data.tar.gz ]; then - msg_info "installing SWI data into /boot..." - tar -C /mnt/onl/data/boot -xzf $swi_workdir/swi-data.tar.gz - fi - - # If there is a SWI version file put it in /etc/onl/swi_version - if [ -f $swi_workdir/version ]; then - cp $swi_workdir/version /mnt/onl/data/etc/onl/swi_version - fi - - msg_info "stamping filesystem with SWI" - case "$SWI" in - *::latest) - swistamp=${SWI%:latest}${swipath##*/} - ;; - *) - swistamp=$SWI - ;; - esac - echo "$swistamp" > /mnt/onl/data/.swi + swiprep --install "$swipath" --swiref "$swistamp" /mnt/onl/data fi trap - 0 1 do_cleanup -sed -i -e '/^SWI=/d' /etc/onl/BOOTPARAMS -echo "SWI=dir:data:/" >> /etc/onl/BOOTPARAMS . /bootmodes/swi # Local variables: diff --git a/packages/base/all/initrds/loader-initrd-files/src/lib/boot1 b/packages/base/all/initrds/loader-initrd-files/src/lib/boot1 deleted file mode 100644 index 908a48b6..00000000 --- a/packages/base/all/initrds/loader-initrd-files/src/lib/boot1 +++ /dev/null @@ -1,123 +0,0 @@ -# -*- sh -*- -############################################################ -# -# -# Copyright 2013, 2014 BigSwitch Networks, Inc. -# -# Licensed under the Eclipse Public License, Version 1.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.eclipse.org/legal/epl-v10.html -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -# either express or implied. See the License for the specific -# language governing permissions and limitations under the -# License. -# -# -############################################################ -# -# boot1 -# -# Copies/mounts rootfs from swi and switches root -# -###################################################################### - -mkdir -p /newroot -umount -l /newroot 2>/dev/null || : - -if [ -d "${swipath}" ]; then - # rootfs is a directory - mount --bind "${swipath}/${rootfs}" /newroot -else - # rootfs is a squashfs - echo "Booting: ${swipath}" - mkdir -p /newroot.lower /newroot.upper - umount -l /newroot.lower 2>/dev/null || : - umount -l /newroot.upper 2>/dev/null || : - rm -f /tmp/rootfs - uarch=`uname -m` - - ARCH_LIST= - case $uarch in - ppc) - ARCH_LIST="ppc powerpc" - ;; - x86_64) - ARCH_LIST="x86_64 amd64" - ;; - armv7l) - ARCH_LIST="armel" - ;; - *) - ;; - esac - - for arch in $ARCH_LIST; do - unzip -pq "${swipath}" "rootfs-$arch.sqsh" >/tmp/rootfs - [ ! -s /tmp/rootfs ] || break - done - - if [ ! -s /tmp/rootfs ]; then - echo "${swipath} does not contain a rootfs image for the current architecture ($uarch). Booting cannot continue." - exit 1 - fi - - if grep -q overlayfs /proc/filesystems; then - mount -t squashfs -o loop /tmp/rootfs /newroot.lower - mount -t tmpfs -o size=15%,mode=0755 none /newroot.upper - mount -t overlayfs -o lowerdir=/newroot.lower,upperdir=/newroot.upper none /newroot - elif grep -q overlay /proc/filesystems; then - mount -t squashfs -o loop /tmp/rootfs /newroot.lower - mount -t tmpfs -o size=15%,mode=0755 none /newroot.upper - mkdir /newroot.upper/upper - mkdir /newroot.upper/work - mount -t overlay -olowerdir=/newroot.lower,upperdir=/newroot.upper/upper,workdir=/newroot.upper/work overlay /newroot - else - echo "OverlayFS not found in kernel" - fi -fi - -mkdir -p /newroot/etc/onl -cp -R /etc/onl/* /newroot/etc/onl - -if [ -f /etc/fw_env.config ]; then - cat /etc/fw_env.config >/newroot/etc/fw_env.config -fi - -if [ -f "$swipath" ]; then - - # Install any SWI data packages. - unzip -oq "${swipath}" swi-data.tar.gz -d /tmp - if [ -s /tmp/swi-data.tar.gz ]; then - echo "Installing SWI data into /boot..." - tar -C /newroot/boot -xzf /tmp/swi-data.tar.gz - fi - - # If there is a SWI version file put it in /etc/onl/swi_version - unzip -oq "${swipath}" version -d /tmp - if [ -f /tmp/version ]; then - cp /tmp/version /newroot/etc/onl/swi_version - fi - -fi - -# -# The file /lib/boot-custom can be provided by customized builds to -# add functionality before the root is switched. -# -if [ -f /lib/boot-custom ]; then - . /lib/boot-custom -fi - -echo "Switching rootfs" # limit 16 chars since serial buffer is not flushed -kill -QUIT 1 # exec /bin/switchroot as PID 1 -sleep 30 - -# Local variables: -# mode: sh -# sh-basic-offset: 4 -# End: diff --git a/packages/base/all/vendor-config-onl/PKG.yml b/packages/base/all/vendor-config-onl/PKG.yml index 32109df3..a1fecbf9 100644 --- a/packages/base/all/vendor-config-onl/PKG.yml +++ b/packages/base/all/vendor-config-onl/PKG.yml @@ -10,7 +10,16 @@ packages: files: src/python/onl : $PY_INSTALL/onl src/boot.d : /etc/boot.d - src/bin : /usr/bin + src/bin/initubootenv: /sbin/initubootenv + src/bin/initmounts: /sbin/initmounts + src/bin/initnetdev: /sbin/initnetdev + src/bin/pki : /sbin/pki + src/bin/loader-shell: /usr/bin/loader-shell + src/bin/onie-shell: /usr/bin/onie-shell + src/bin/onl-platform-show: /usr/bin/onl-platform-show + src/bin/onl-install: /usr/bin/onl-install + src/bin/onl-recover: /usr/bin/onl-recover + src/bin/pyfit: /usr/bin/pyfit src/lib : /lib/vendor-config/onl changelog: Changes