blob: fcd17d64f050d8f834c7c95f8c7b764f9411b0b9 [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.
### do a system OTA
## 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
if needs-update; then
fx-command-run shell "$@" amberctl system_update || return $?
fx-command-run shell log_listener --since_now yes --clock Local
fi
fx-command-run wait
if needs-update; then
fx-error "After update, system appears still out of date."
return 1
fi
}
main "$@"