"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/dev/tools/repackage_gradle_wrapper.sh" (13 Nov 2020, 2497 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env bash
    2 # Copyright 2014 The Flutter Authors. All rights reserved.
    3 # Use of this source code is governed by a BSD-style license that can be
    4 # found in the LICENSE file.
    5 
    6 set -e
    7 
    8 # Update this URL to get another version of the Gradle wrapper.
    9 # If the AOSP folks have changed the layout of their templates, you may also need to update the
   10 # script below to grab the right files...
   11 WRAPPER_SRC_URL="https://android.googlesource.com/platform/tools/base/+archive/0b5c1398d1d04ac245a310de98825cb7b3278e2a/templates.tgz"
   12 
   13 case "$(uname -s)" in
   14   Darwin)
   15     SHASUM="shasum"
   16     ;;
   17   *)
   18     SHASUM="sha1sum"
   19     ;;
   20 esac
   21 
   22 function follow_links() {
   23   cd -P "${1%/*}"
   24   file="$PWD/${1##*/}"
   25   while [ -h "$file" ]; do
   26     # On Mac OS, readlink -f doesn't work.
   27     cd -P "${file%/*}"
   28     file="$(readlink "$file")"
   29     cd -P "${file%/*}"
   30     file="$PWD/${file##*/}"
   31   done
   32   echo "$PWD/${file##*/}"
   33 }
   34 
   35 # Convert a filesystem path to a format usable by Dart's URI parser.
   36 function path_uri() {
   37   # Reduce multiple leading slashes to a single slash.
   38   echo "$1" | sed -E -e "s,^/+,/,"
   39 }
   40 
   41 PROG_NAME="$(path_uri "$(follow_links "$BASH_SOURCE")")"
   42 BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
   43 FLUTTER_ROOT="$(cd "${BIN_DIR}/../.." ; pwd -P)"
   44 
   45 WRAPPER_VERSION_PATH="$FLUTTER_ROOT/bin/internal/gradle_wrapper.version"
   46 WRAPPER_TEMP_DIR="$FLUTTER_ROOT/bin/cache/gradle-wrapper-temp"
   47 
   48 echo "Downloading gradle wrapper..."
   49 rm -rf "$WRAPPER_TEMP_DIR"
   50 mkdir "$WRAPPER_TEMP_DIR"
   51 curl --continue-at - --location --output "$WRAPPER_TEMP_DIR/templates.tgz" "$WRAPPER_SRC_URL" 2>&1
   52 
   53 echo
   54 echo "Repackaging files..."
   55 mkdir "$WRAPPER_TEMP_DIR/unpack"
   56 tar xzf "$WRAPPER_TEMP_DIR/templates.tgz" -C "$WRAPPER_TEMP_DIR/unpack" gradle NOTICE
   57 
   58 mkdir "$WRAPPER_TEMP_DIR/repack"
   59 mv "$WRAPPER_TEMP_DIR/unpack/gradle/wrapper"/* "$WRAPPER_TEMP_DIR/repack/"
   60 mv "$WRAPPER_TEMP_DIR/unpack/NOTICE" "$WRAPPER_TEMP_DIR/repack/"
   61 
   62 pushd "$WRAPPER_TEMP_DIR/repack" > /dev/null
   63 STAMP=`for h in $(find . -type f); do $SHASUM $h; done | $SHASUM | cut -d' ' -f1`
   64 echo "Packaged files:"
   65 tar cvzf ../gradle-wrapper.tgz *
   66 popd > /dev/null
   67 
   68 echo
   69 echo "Uploading repackaged gradle wrapper..."
   70 echo "Content hash: $STAMP"
   71 gsutil.py cp -n "$WRAPPER_TEMP_DIR/gradle-wrapper.tgz" "gs://flutter_infra/gradle-wrapper/$STAMP/gradle-wrapper.tgz"
   72 
   73 echo "flutter_infra/gradle-wrapper/$STAMP/gradle-wrapper.tgz" > "$WRAPPER_VERSION_PATH"
   74 
   75 rm -rf "$WRAPPER_TEMP_DIR"
   76 echo
   77 echo "All done. Updated bin/internal/gradle_wrapper.version, don't forget to commit!"