mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 07:31:01 +02:00
Add verify option to image_to_live.
Change-Id: I63f7ce38179b713bb26bed70d6fd392425595a81 BUG= TEST=Ran with update vm script. Review URL: http://codereview.chromium.org/3393019
This commit is contained in:
parent
e7f1a2b6bb
commit
3b65e8dd6f
@ -31,5 +31,6 @@ $(dirname $0)/../image_to_live.sh \
|
|||||||
--remote=${HOSTNAME} \
|
--remote=${HOSTNAME} \
|
||||||
--ssh_port=${FLAGS_ssh_port} \
|
--ssh_port=${FLAGS_ssh_port} \
|
||||||
--stateful_update_flag=${stateful_flags} \
|
--stateful_update_flag=${stateful_flags} \
|
||||||
|
--verify \
|
||||||
--image=$(readlink -f ${FLAGS_update_image_path})
|
--image=$(readlink -f ${FLAGS_update_image_path})
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ DEFINE_boolean update_known_hosts ${FLAGS_FALSE} \
|
|||||||
"Update your known_hosts with the new remote instance's key."
|
"Update your known_hosts with the new remote instance's key."
|
||||||
DEFINE_string update_log "update_engine.log" \
|
DEFINE_string update_log "update_engine.log" \
|
||||||
"Path to log for the update_engine."
|
"Path to log for the update_engine."
|
||||||
|
DEFINE_boolean verify ${FLAGS_TRUE} "Verify image on device after update."
|
||||||
|
|
||||||
# Flags for devserver.
|
# Flags for devserver.
|
||||||
DEFINE_string archive_dir "" \
|
DEFINE_string archive_dir "" \
|
||||||
@ -33,17 +34,21 @@ DEFINE_integer devserver_port 8080 \
|
|||||||
"Port to use for devserver."
|
"Port to use for devserver."
|
||||||
DEFINE_string image "" \
|
DEFINE_string image "" \
|
||||||
"Update with this image path that is in this source checkout." i
|
"Update with this image path that is in this source checkout." i
|
||||||
|
DEFINE_boolean update_stateful ${FLAGS_TRUE} \
|
||||||
|
"Perform update of stateful partition e.g. /var /usr/local."
|
||||||
DEFINE_string update_url "" "Full url of an update image."
|
DEFINE_string update_url "" "Full url of an update image."
|
||||||
|
|
||||||
# Flags for stateful update.
|
# Flags for stateful update.
|
||||||
DEFINE_string stateful_update_flag "" \
|
DEFINE_string stateful_update_flag "" \
|
||||||
"Flag to pass to stateful update e.g. old, clean, etc." s
|
"Flag to pass to stateful update e.g. old, clean, etc." s
|
||||||
|
|
||||||
UPDATER_BIN='/usr/bin/update_engine_client'
|
UPDATER_BIN="/usr/bin/update_engine_client"
|
||||||
UPDATER_IDLE='UPDATE_STATUS_IDLE'
|
UPDATER_IDLE="UPDATE_STATUS_IDLE"
|
||||||
UPDATER_NEED_REBOOT='UPDATE_STATUS_UPDATED_NEED_REBOOT'
|
UPDATER_NEED_REBOOT="UPDATE_STATUS_UPDATED_NEED_REBOOT"
|
||||||
UPDATER_UPDATE_CHECK='UPDATE_STATUS_CHECKING_FOR_UPDATE'
|
UPDATER_UPDATE_CHECK="UPDATE_STATUS_CHECKING_FOR_UPDATE"
|
||||||
UPDATER_DOWNLOADING='UPDATE_STATUS_DOWNLOADING'
|
UPDATER_DOWNLOADING="UPDATE_STATUS_DOWNLOADING"
|
||||||
|
|
||||||
|
IMAGE_PATH=""
|
||||||
|
|
||||||
function kill_all_devservers {
|
function kill_all_devservers {
|
||||||
# Using ! here to avoid exiting with set -e is insufficient, so use
|
# Using ! here to avoid exiting with set -e is insufficient, so use
|
||||||
@ -89,9 +94,12 @@ function start_dev_server {
|
|||||||
if [ -n "${FLAGS_image}" ]; then
|
if [ -n "${FLAGS_image}" ]; then
|
||||||
devserver_flags="${devserver_flags} \
|
devserver_flags="${devserver_flags} \
|
||||||
--image $(reinterpret_path_for_chroot ${FLAGS_image})"
|
--image $(reinterpret_path_for_chroot ${FLAGS_image})"
|
||||||
|
IMAGE_PATH="${FLAGS_image}"
|
||||||
|
|
||||||
elif [ -n "${FLAGS_archive_dir}" ]; then
|
elif [ -n "${FLAGS_archive_dir}" ]; then
|
||||||
devserver_flags="${devserver_flags} \
|
devserver_flags="${devserver_flags} \
|
||||||
--archive_dir $(reinterpret_path_for_chroot ${FLAGS_archive_dir}) -t"
|
--archive_dir $(reinterpret_path_for_chroot ${FLAGS_archive_dir}) -t"
|
||||||
|
IMAGE_PATH="${FLAGS_archive_dir}/chromiumos_test_image.bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Starting devserver with flags ${devserver_flags}"
|
info "Starting devserver with flags ${devserver_flags}"
|
||||||
@ -258,6 +266,31 @@ function remote_reboot {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verify_image {
|
||||||
|
info "Verifying image."
|
||||||
|
"${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname ${IMAGE_PATH})" \
|
||||||
|
--image "$(basename ${IMAGE_PATH})" \
|
||||||
|
--read_only
|
||||||
|
|
||||||
|
local lsb_release=$(cat /tmp/m/etc/lsb-release)
|
||||||
|
info "Verifying image with release:"
|
||||||
|
echo ${lsb_release}
|
||||||
|
|
||||||
|
"${SCRIPTS_DIR}/mount_gpt_image.sh" --unmount
|
||||||
|
|
||||||
|
remote_sh "cat /etc/lsb-release"
|
||||||
|
info "Remote image reports:"
|
||||||
|
echo ${REMOTE_OUT}
|
||||||
|
|
||||||
|
if [ "${lsb_release}" = "${REMOTE_OUT}" ]; then
|
||||||
|
info "Update was successful and image verified as ${lsb_release}."
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
warn "Image verification failed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
assert_outside_chroot
|
assert_outside_chroot
|
||||||
|
|
||||||
@ -268,6 +301,12 @@ function main() {
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ] && \
|
||||||
|
[ -n "${FLAGS_update_url}" ]; then
|
||||||
|
warn "Verify is not compatible with setting an update url."
|
||||||
|
FLAGS_verify=${FLAGS_FALSE}
|
||||||
|
fi
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
TMP=$(mktemp -d /tmp/image_to_live.XXXX)
|
TMP=$(mktemp -d /tmp/image_to_live.XXXX)
|
||||||
@ -284,11 +323,12 @@ function main() {
|
|||||||
start_dev_server
|
start_dev_server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${FLAGS_update}" -eq "${FLAGS_TRUE}" ] && ! run_auto_update; then
|
if [ ${FLAGS_update} -eq ${FLAGS_TRUE} ] && ! run_auto_update; then
|
||||||
die "Update was not successful."
|
die "Update was not successful."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! run_stateful_update; then
|
if [ ${FLAGS_update_stateful} -eq ${FLAGS_TRUE} ] && \
|
||||||
|
! run_stateful_update; then
|
||||||
warn "Stateful update was not successful."
|
warn "Stateful update was not successful."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -304,10 +344,14 @@ function main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release"
|
remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release"
|
||||||
local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2)
|
if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ]; then
|
||||||
info "Update was successful and rebooted to $release_description"
|
verify_image
|
||||||
|
else
|
||||||
|
local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2)
|
||||||
|
info "Update was successful and rebooted to $release_description"
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main $@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user