From ef964301357a1afde8a4a7bdb224f6d00521fbab Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Tue, 27 Apr 2010 13:21:08 -0700 Subject: [PATCH] Changes to image_to_live to copy stateful partition over Review URL: http://codereview.chromium.org/1784006 --- image_to_live.sh | 25 +++++++++++++++++++++++++ remote_access.sh | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/image_to_live.sh b/image_to_live.sh index 13cbff8b37..77e361fa9a 100755 --- a/image_to_live.sh +++ b/image_to_live.sh @@ -31,6 +31,7 @@ function cleanup { echo "Killing dev server." kill_all_devservers cleanup_remote_access + . "$(dirname $0)/mount_gpt_image.sh" -mu rm -rf "${TMP}" } @@ -54,6 +55,25 @@ function start_dev_server { echo "" } +function copy_stateful_tarball { + echo "Starting stateful update." + # Mounts most recent image stateful dir to /tmp/s + . "$(dirname $0)/mount_gpt_image.sh" -m + # Create tar files for the stateful partition. + cd /tmp/s/var && sudo tar -cf /tmp/var.tar . && cd - + cd /tmp/s/dev_image && sudo tar -cf /tmp/developer.tar . && cd - + # Copy over tar files. + remote_cp /tmp/var.tar /tmp + remote_cp /tmp/developer.tar /tmp + remote_sh "mkdir /mnt/stateful_partition/var_new |\ + mkdir /mnt/stateful_partition/dev_image_new |\ + tar -xf /tmp/var.tar -C /mnt/stateful_partition/var_new |\ + tar -xf /tmp/developer.tar \ + -C /mnt/stateful_partition/dev_image_new" + # unmounts stateful partition + . "$(dirname $0)/mount_gpt_image.sh" -mu +} + function prepare_update_metadata { remote_sh "mount -norw,remount /" @@ -179,6 +199,11 @@ function main() { exit 1 fi + if ! copy_stateful_tarball; then + echo "Stateful update was not successful." + exit 1 + fi + remote_reboot if [[ ${FLAGS_update_hostkey} -eq ${FLAGS_TRUE} ]]; then diff --git a/remote_access.sh b/remote_access.sh index 43a64ad187..fe4383c27c 100644 --- a/remote_access.sh +++ b/remote_access.sh @@ -11,6 +11,13 @@ DEFINE_string remote "" "remote hostname/IP of running Chromium OS instance" DEFINE_string private_key "$DEFAULT_PRIVATE_KEY" \ "Private key of root account on remote host" +# Copies $1 to $2 on remote host +function remote_cp() { + REMOTE_OUT=$(scp -o StrictHostKeyChecking=no -o \ + UserKnownHostsFile=$TMP_KNOWN_HOSTS $1 root@$FLAGS_remote:$2) + return ${PIPESTATUS[0]} +} + function remote_sh() { REMOTE_OUT=$(ssh -o StrictHostKeyChecking=no -o \ UserKnownHostsFile=$TMP_KNOWN_HOSTS root@$FLAGS_remote "$@")