github.phpd.cn/thought-machine/please@v12.2.0+incompatible/tools/misc/get_plz.sh (about)

     1  #!/bin/sh
     2  #
     3  # Downloads a precompiled copy of Please from our s3 bucket and installs it.
     4  set -e
     5  
     6  VERSION=`curl -fsSL https://get.please.build/latest_version`
     7  # Find the os / arch to download. You can do this quite nicely with go env
     8  # but we use this script on machines that don't necessarily have Go itself.
     9  OS=`uname`
    10  if [ "$OS" = "Linux" ]; then
    11      GOOS="linux"
    12  elif [ "$OS" = "Darwin" ]; then
    13      GOOS="darwin"
    14  else
    15      echo "Unknown operating system $OS"
    16      exit 1
    17  fi
    18  
    19  PLEASE_URL="https://get.please.build/${GOOS}_amd64/${VERSION}/please_${VERSION}.tar.gz"
    20  
    21  LOCATION="${HOME}/.please"
    22  DIR="${LOCATION}/${VERSION}"
    23  mkdir -p "$DIR"
    24  
    25  echo "Downloading Please ${VERSION} to ${DIR}..."
    26  curl -fsSL "${PLEASE_URL}" | tar -xzpf- --strip-components=1 -C "$DIR"
    27  # Link it all back up a dir
    28  for x in `ls "$DIR"`; do
    29      ln -sf "${DIR}/${x}" "$LOCATION"
    30  done
    31  ln -sf "${LOCATION}/please" "${LOCATION}/plz"
    32  
    33  if ! hash plz 2>/dev/null; then
    34      echo "Adding plz to PATH..."
    35      if [ -d ~/.local/bin ]; then
    36          ln -s ~/.please/plz ~/.local/bin/plz
    37      elif [ -f ~/.profile ]; then
    38          echo 'export PATH="${PATH}:~/.please"' >> ~/.profile
    39          echo "You may need to run 'source ~/.profile' to pick up the new PATH."
    40      else
    41          echo "Unsure how to add to PATH, not modifying anything."
    42      fi
    43  fi
    44  
    45  echo "Please installed."
    46  echo "Run plz --help for more information about how to invoke it,"
    47  echo "or plz help for information on specific help topics."