From 27800f2100e56655f8363a8237fd7d8c89c7eef8 Mon Sep 17 00:00:00 2001 From: Kenneth Johansson Date: Wed, 16 Jan 2019 18:35:16 +0100 Subject: [PATCH] iop upgrade: add -r option to jump into a chroot of other system. useful for developing testing upgrade configuration migration. --- iopupgrade/files/sbin/iopu | 44 ++++++++++++++++++++------- iopupgrade/files/sbin/iopu_chroot_env | 18 +++++++++++ 2 files changed, 51 insertions(+), 11 deletions(-) create mode 100755 iopupgrade/files/sbin/iopu_chroot_env diff --git a/iopupgrade/files/sbin/iopu b/iopupgrade/files/sbin/iopu index d389dbdb4..85d91e180 100755 --- a/iopupgrade/files/sbin/iopu +++ b/iopupgrade/files/sbin/iopu @@ -109,6 +109,19 @@ function umount_newroot { umount /tmp/newroot run_mount_cleanup=0 } + +function usage { + echo "usage: $0 iopu [opts] " + echo "" + echo "opts:" + echo "" + echo " -n Do not do the final reboot of the target board" + echo " -c Keep configuration" + echo " -x Force install even if firmware is not for this board" + echo " -b Force install of bootloader regardless of version installed" + echo " -r Jump into chroot env of other system" +} + ############################################################################### # just one instance @@ -124,6 +137,26 @@ trap finish EXIT trap timeout SIGALRM trap sig_pipe SIGPIPE +while getopts "nr" opt; do + case $opt in + n) + upd_noreboot=1 + ;; + r) + upd_vol=$(get_flashbank_next) + mount_newroot + (ENV=/sbin/iopu_chroot_env chroot /tmp/newroot_overlay /bin/sh) + echo "" + umount_newroot + exit 0 + ;; + h) + upd_usage + exit 1 + ;; + esac +done + # put a timeout on this if it takes longer than 120 seconds we should abort and clean up ( sleep 120 # if 2 minutes pass @@ -131,17 +164,6 @@ kill -ALRM $$ 2>/dev/null # send it a SIGALRM signal )& TIMEOUT_PID=$! - -while getopts "n" opt; do - case $opt in - n) - upd_noreboot=1 - ;; - esac -done - - - log "Firmware upgrade started" #find out board name diff --git a/iopupgrade/files/sbin/iopu_chroot_env b/iopupgrade/files/sbin/iopu_chroot_env new file mode 100755 index 000000000..8532d315d --- /dev/null +++ b/iopupgrade/files/sbin/iopu_chroot_env @@ -0,0 +1,18 @@ +#!/bin/sh +# this is run when "iopr -r" is executed. +# intended to just show what environment is actually started. + +cat /etc/banner + +echo "/tmp/oldroot:" +echo " Contains the running root filesystem. It is live so files are in use" +echo " Anything copying/reading files from there needs to make sure it is done safely." +echo "" + +Color_Off='\033[0m' # Text Reset +Red='\033[0;31m' # Red + +PS1="${Red}chroot_new${Color_Off}:\w\#" +export PS1 +export Red +export Color_Off