| #!/bin/bash | |
| # Copyright 2017 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. | |
| set -e | |
| SCRIPT_TO_DELETE="" | |
| if [[ "$0" != *"scripts/bootstrap" ]]; then | |
| SCRIPT_TO_DELETE=$(realpath "$0") | |
| fi | |
| temp_bootstrap_jiri="" | |
| cleanup() { | |
| if [[ -n "$temp_bootstrap_jiri" ]]; then | |
| rm -f "$temp_bootstrap_jiri" | |
| fi | |
| if [[ -n "$SCRIPT_TO_DELETE" ]]; then | |
| rm -f "$SCRIPT_TO_DELETE" | |
| fi | |
| } | |
| trap cleanup EXIT SIGINT SIGTERM | |
| function usage { | |
| cat <<END | |
| usage: bootstrap | |
| Bootstrap the Platform Source Tree. | |
| END | |
| } | |
| if [[ $# -gt 0 ]]; then | |
| usage | |
| exit 1 | |
| fi | |
| # The fetched script will | |
| # - create "fuchsia" directory if it does not exist, | |
| # - download "jiri" command to "fuchsia/.jiri_root/bin" | |
| temp_bootstrap_jiri=$(mktemp) | |
| # Download and decode to the temporary file | |
| curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" | base64 --decode > "$temp_bootstrap_jiri" | |
| # Execute the script from the file | |
| bash "$temp_bootstrap_jiri" fuchsia | |
| cd fuchsia | |
| .jiri_root/bin/jiri import -name=integration flower https://fuchsia.googlesource.com/integration | |
| .jiri_root/bin/jiri update -fetch-packages-timeout=120 -hook-timeout=24 | |
| echo "Done creating a Platform Source Tree at \"$(pwd)\"." | |
| echo "Recommended: export PATH=\"$(pwd)/.jiri_root/bin:\$PATH\"" |