blob: e58cf75d04bdceb8d19e93e57c4544914b213295 [file] [log] [blame]
#!/bin/bash
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#### CATEGORY=Software delivery
### perform a system OTA on a connected device
## usage: fx ota [-h|--help]
##
## Ask the target to do an OTA. The target will use any update server available
## to it to do the update. This requires the target have a update server
## available to it. The 'serve' fx command is typically used to make your
## development host available to the target as an update server.
##
## Arguments:
## -h|--help Print out this message.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/vars.sh || exit $?
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/updates.sh || exit $?
fx-config-read
function needs-update {
local system_image_merkle="${FUCHSIA_BUILD_DIR}"/obj/build/images/system_image.meta/meta.far.merkle
[[ $(fx-command-run shell 'read ver < /system/meta;echo $ver') != $(<"${system_image_merkle}") ]]
}
function main {
fx-standard-switches "$@"
set -- "${FX_ARGV[@]}"
check-for-amber-server || return 1
# Note: the following command continues to run as the system goes into
# reboot, so we lose SSH connection before it "completes". As such the
# following command completes with error, but that is not actually an error.
fx-command-run shell update check-now --monitor
fx-command-run wait
if needs-update; then
fx-error "After update, system appears still out of date."
return 1
fi
}
main "$@"