| #!/bin/bash |
| # |
| # Copyright 2022 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. |
| # |
| # Updates the version of ffx used by this repository to the latest |
| # version. |
| # |
| # Usage: |
| # update_fuchsia_sdk.sh |
| # |
| # Requirements: |
| # 1. $FUCHSIA_EMBEDDER_DIR is set to your flutter-embedder.git checkout. |
| |
| set -e # Fail on any error. |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/echo_helpers.sh || exit $? |
| |
| # Parse arguments. |
| cleanup=0 |
| while [[ $# -gt 0 ]]; do |
| case $1 in |
| --cleanup) |
| cleanup=1 |
| shift # past argument |
| ;; |
| *) |
| shift # past value |
| ;; |
| esac |
| done |
| |
| echo-info "Updating the Fuchsia SDK checkout..." |
| git -C $FUCHSIA_EMBEDDER_DIR/third_party/sdk-integration pull origin main |
| |
| echo-info "Building the embedder to fetch the Fuchsia SDK tools..." |
| pushd $FUCHSIA_EMBEDDER_DIR |
| bazel build --config=fuchsia_x64 //src/embedder |
| popd |
| |
| if [[ "${cleanup}" -eq 0 ]] |
| then |
| echo-info "Your Fuchsia SDK has been updated to version `$FUCHSIA_EMBEDDER_DIR/tools/ffx version`." |
| echo-warning 'You should restart any running emulators (`ffx emu stop`)' |
| echo-warning 'and update your product bundles (`ffx product-bundle get workstation_eng.qemu-x64`) as' |
| echo-warning 'old images may be incompatible with the updated SDK.' |
| echo-warning 'To do this automatically, run: $FUCHSIA_EMBEDDER_DIR/scripts/update_fuchsia_sdk.sh --cleanup' |
| exit 0 |
| fi |
| |
| echo-info "Cleaning up old things that are incompatible with the new SDK." |
| echo-info "If you don't want this, don't run the script with --cleanup." |
| echo-info "Killing any running emulators." |
| ffx emu stop |
| |
| # TODO(https://fxbug.dev/106963): Replace with an ffx product-bundle clean command once |
| # one exists. |
| echo-info "Deleting old product bundles." |
| rm -rf ~/.local/share/Fuchsia/ffx/pbms |
| |
| echo-info "Refetching the workstation_eng.qemu-x64 product bundle." |
| ffx product-bundle get workstation_eng.qemu-x64 |
| |
| echo |
| echo-info "Your Fuchsia SDK has been updated to version `$FUCHSIA_EMBEDDER_DIR/tools/ffx version`." |
| echo-info "You will need to restart your emulator by running:" |
| echo '$FUCHSIA_EMBEDDER_DIR/tools/ffx emu start workstation_eng.qemu-x64' |