| #!/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 |
| no_version_bump=0 |
| while [[ $# -gt 0 ]]; do |
| case $1 in |
| --cleanup) |
| cleanup=1 |
| shift # past argument |
| ;; |
| --no-version-bump) |
| no_version_bump=1 |
| shift # past argument |
| ;; |
| *) |
| shift # past value |
| ;; |
| esac |
| done |
| |
| if [[ "${no_version_bump}" -eq 0 ]] |
| then |
| echo-info "Updating the Fuchsia SDK checkout..." |
| git -C $FUCHSIA_EMBEDDER_DIR/third_party/sdk-integration pull origin main |
| fi |
| |
| echo-info "Building the embedder to fetch the updated Fuchsia SDK tools..." |
| pushd $FUCHSIA_EMBEDDER_DIR |
| $FUCHSIA_EMBEDDER_DIR/tools/bazel clean |
| $FUCHSIA_EMBEDDER_DIR/tools/bazel build --config=fuchsia_x64 //src/embedder |
| popd |
| |
| if [[ "${cleanup}" -eq 0 ]] |
| then |
| echo-info "flutter-embedder's Fuchsia SDK has been updated to version $($FUCHSIA_EMBEDDER_DIR/tools/ffx version)." |
| echo-warning 'You should restart any running emulators (`$FUCHSIA_EMBEDDER_DIR/tools/ffx emu stop`)' |
| echo-warning 'and update your product bundles (`$FUCHSIA_EMBEDDER_DIR/tools/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..." |
| $FUCHSIA_EMBEDDER_DIR/tools/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..." |
| $FUCHSIA_EMBEDDER_DIR/tools/ffx product-bundle get workstation_eng.qemu-x64 |
| |
| echo |
| echo-info "flutter-embedder's 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' |
| echo-info "Or if you're running from a non-graphical environment:" |
| echo '$FUCHSIA_EMBEDDER_DIR/tools/ffx emu start workstation_eng.qemu-x64 --headless' |