| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 # Run pub.dart on the Dart VM. This script assumes the Dart SDK's directory | 6 # Run pub.dart on the Dart VM. This script assumes the Dart SDK's directory |
| 7 # structure. | 7 # structure. |
| 8 | 8 |
| 9 function follow_links() { | 9 PROG_NAME=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && \ |
| 10 file="$1" | 10 PROG_NAME=$PROG_NAME/$(basename -- "$0") |
| 11 while [ -h "$file" ]; do | |
| 12 # On Mac OS, readlink -f doesn't work. | |
| 13 file="$(readlink "$file")" | |
| 14 done | |
| 15 echo "$file" | |
| 16 } | |
| 17 | 11 |
| 18 # Unlike $0, $BASH_SOURCE points to the absolute path of this file. | 12 # resolve symlinks |
| 19 PROG_NAME="$(follow_links "$BASH_SOURCE")" | 13 while [ -h $PROG_NAME ]; do |
| 14 DIR=$(dirname -- "$PROG_NAME") |
| 15 SYM=$(readlink $PROG_NAME) |
| 16 PROG_NAME=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") |
| 17 done |
| 20 | 18 |
| 21 # Handle the case where dart-sdk/bin has been symlinked to. | 19 # Handle the case where dart-sdk/bin has been symlinked to. |
| 22 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" | 20 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" |
| 23 | 21 |
| 24 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" | 22 SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)" |
| 25 | 23 |
| 26 SNAPSHOT="$BIN_DIR/snapshots/pub.dart.snapshot" | 24 SNAPSHOT="$BIN_DIR/snapshots/pub.dart.snapshot" |
| 27 | 25 |
| 28 if test -f "$SNAPSHOT"; then | 26 if test -f "$SNAPSHOT"; then |
| 29 # We are running the snapshot in the built SDK. | 27 # We are running the snapshot in the built SDK. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 45 | 43 |
| 46 # Use the Dart binary in the built SDK so pub can find the version file next | 44 # Use the Dart binary in the built SDK so pub can find the version file next |
| 47 # to it. | 45 # to it. |
| 48 DART="$BUILD_DIR/dart-sdk/bin/dart" | 46 DART="$BUILD_DIR/dart-sdk/bin/dart" |
| 49 PACKAGES_DIR="$BUILD_DIR/packages/" | 47 PACKAGES_DIR="$BUILD_DIR/packages/" |
| 50 | 48 |
| 51 PUB="$SDK_DIR/lib/_internal/pub/bin/pub.dart" | 49 PUB="$SDK_DIR/lib/_internal/pub/bin/pub.dart" |
| 52 | 50 |
| 53 exec "$DART" "--checked" "--package-root=$PACKAGES_DIR" "$PUB" "$@" | 51 exec "$DART" "--checked" "--package-root=$PACKAGES_DIR" "$PUB" "$@" |
| 54 fi | 52 fi |
| OLD | NEW |