| 
									
										
										
										
											2019-03-09 13:00:15 -05:00
										 |  |  | #:  @hide_from_man_page | 
					
						
							| 
									
										
										
										
											2019-01-30 21:32:05 +00:00
										 |  |  | #:  * `vendor-install` [<target>] | 
					
						
							|  |  |  | #: | 
					
						
							|  |  |  | #:  Install Homebrew's portable Ruby. | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-04 09:31:37 +01:00
										 |  |  | # Don't need shellcheck to follow this `source`. | 
					
						
							|  |  |  | # shellcheck disable=SC1090 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | VENDOR_DIR="$HOMEBREW_LIBRARY/Homebrew/vendor" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  | # Built from https://github.com/Homebrew/homebrew-portable-ruby. | 
					
						
							| 
									
										
										
										
											2018-10-04 09:31:37 +01:00
										 |  |  | # | 
					
						
							|  |  |  | # Dynamic variables can't be detected by shellcheck | 
					
						
							|  |  |  | # shellcheck disable=SC2034 | 
					
						
							| 
									
										
										
										
											2016-09-18 19:57:19 +01:00
										 |  |  | if [[ -n "$HOMEBREW_MACOS" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | then | 
					
						
							|  |  |  |   if [[ "$HOMEBREW_PROCESSOR" = "Intel" ]] | 
					
						
							|  |  |  |   then | 
					
						
							| 
									
										
										
										
											2019-01-27 12:49:41 +00:00
										 |  |  |     ruby_URL="$HOMEBREW_BOTTLE_DOMAIN/bottles-portable-ruby/portable-ruby-2.3.7.mavericks.bottle.tar.gz" | 
					
						
							|  |  |  |     ruby_URL2="https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.3.7/portable-ruby-2.3.7.mavericks.bottle.tar.gz" | 
					
						
							|  |  |  |     ruby_SHA="539ae571968fc74d4ec3a839cb33edc5786c219a5e6ae7fb6a09ec5fc1b04e4e" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2016-07-14 15:41:09 +08:00
										 |  |  | elif [[ -n "$HOMEBREW_LINUX" ]] | 
					
						
							|  |  |  | then | 
					
						
							| 
									
										
										
										
											2017-11-26 20:13:00 -08:00
										 |  |  |   case "$HOMEBREW_PROCESSOR" in | 
					
						
							|  |  |  |     x86_64) | 
					
						
							| 
									
										
										
										
											2018-07-12 21:54:25 +01:00
										 |  |  |       ruby_URL="$HOMEBREW_BOTTLE_DOMAIN/bottles-portable-ruby/portable-ruby-2.3.7.x86_64_linux.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_URL2="https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.3.7/portable-ruby-2.3.7.x86_64_linux.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_SHA="9df214085a0e566a580eea3dd9eab14a2a94930ff74fbf97fb1284e905c8921d" | 
					
						
							| 
									
										
										
										
											2018-05-04 08:00:01 -07:00
										 |  |  |       ;; | 
					
						
							| 
									
										
										
										
											2019-02-24 22:36:56 -08:00
										 |  |  |     aarch64) | 
					
						
							|  |  |  |       ruby_URL="$HOMEBREW_BOTTLE_DOMAIN/bottles-portable-ruby/portable-ruby-2.3.7.aarch64_linux.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_URL2="https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.3.7/portable-ruby-2.3.7.aarch64_linux.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_SHA="e5a72a9deabe500d5d2eaed29e2eb84868ade962eda3ddc68ea169adbb7ac5a2" | 
					
						
							|  |  |  |       ;; | 
					
						
							| 
									
										
										
										
											2018-10-04 13:55:35 -07:00
										 |  |  |     armv[67]*) | 
					
						
							|  |  |  |       ruby_URL="$HOMEBREW_BOTTLE_DOMAIN/bottles-portable-ruby/portable-ruby-2.3.7.armv6_linux.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_URL2="https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.3.7/portable-ruby-2.3.7.armv6_linux.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_SHA="17dce8965d7c935ec1dd0c5bb0be937b685ffe65529141d9e6ed78f4925b4570" | 
					
						
							|  |  |  |       ;; | 
					
						
							| 
									
										
										
										
											2017-11-26 20:13:00 -08:00
										 |  |  |   esac | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-16 10:27:35 -08:00
										 |  |  | # Execute the specified command, and suppress stderr unless HOMEBREW_STDERR is set. | 
					
						
							|  |  |  | quiet_stderr() { | 
					
						
							|  |  |  |   if [[ -z "$HOMEBREW_STDERR" ]]; then | 
					
						
							|  |  |  |     command "$@" 2>/dev/null | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     command "$@" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | fetch() { | 
					
						
							|  |  |  |   local -a curl_args | 
					
						
							|  |  |  |   local sha | 
					
						
							|  |  |  |   local temporary_path | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-08 15:51:58 -07:00
										 |  |  |   curl_args=() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # do not load .curlrc unless requested (must be the first argument) | 
					
						
							| 
									
										
										
										
											2018-04-09 15:43:03 -07:00
										 |  |  |   if [[ -z "$HOMEBREW_CURLRC" ]] | 
					
						
							| 
									
										
										
										
											2018-04-08 15:51:58 -07:00
										 |  |  |   then | 
					
						
							|  |  |  |     curl_args[${#curl_args[*]}]="-q" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   curl_args+=( | 
					
						
							| 
									
										
										
										
											2016-08-07 12:51:46 +02:00
										 |  |  |     --fail | 
					
						
							|  |  |  |     --remote-time | 
					
						
							|  |  |  |     --location | 
					
						
							|  |  |  |     --user-agent "$HOMEBREW_USER_AGENT_CURL" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -n "$HOMEBREW_QUIET" ]] | 
					
						
							|  |  |  |   then | 
					
						
							| 
									
										
										
										
											2017-05-11 08:58:40 -07:00
										 |  |  |     curl_args[${#curl_args[*]}]="--silent" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   elif [[ -z "$HOMEBREW_VERBOSE" ]] | 
					
						
							|  |  |  |   then | 
					
						
							| 
									
										
										
										
											2017-05-11 08:58:40 -07:00
										 |  |  |     curl_args[${#curl_args[*]}]="--progress-bar" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-25 19:15:58 +01:00
										 |  |  |   if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "100600" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     curl_args[${#curl_args[*]}]="--insecure" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-07 12:51:46 +02:00
										 |  |  |   temporary_path="$CACHED_LOCATION.incomplete" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   mkdir -p "$HOMEBREW_CACHE" | 
					
						
							| 
									
										
										
										
											2017-09-25 06:53:23 +01:00
										 |  |  |   [[ -n "$HOMEBREW_QUIET" ]] || echo "==> Downloading $VENDOR_URL" >&2 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   if [[ -f "$CACHED_LOCATION" ]] | 
					
						
							|  |  |  |   then | 
					
						
							| 
									
										
										
										
											2017-09-25 06:53:23 +01:00
										 |  |  |     [[ -n "$HOMEBREW_QUIET" ]] || echo "Already downloaded: $CACHED_LOCATION" >&2 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   else | 
					
						
							|  |  |  |     if [[ -f "$temporary_path" ]] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       "$HOMEBREW_CURL" "${curl_args[@]}" -C - "$VENDOR_URL" -o "$temporary_path" | 
					
						
							|  |  |  |       if [[ $? -eq 33 ]] | 
					
						
							|  |  |  |       then | 
					
						
							| 
									
										
										
										
											2017-09-25 06:53:23 +01:00
										 |  |  |         [[ -n "$HOMEBREW_QUIET" ]] || echo "Trying a full download" >&2 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |         rm -f "$temporary_path" | 
					
						
							|  |  |  |         "$HOMEBREW_CURL" "${curl_args[@]}" "$VENDOR_URL" -o "$temporary_path" | 
					
						
							|  |  |  |       fi | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       "$HOMEBREW_CURL" "${curl_args[@]}" "$VENDOR_URL" -o "$temporary_path" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if [[ ! -f "$temporary_path" ]] | 
					
						
							|  |  |  |     then | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  |       [[ -n "$HOMEBREW_QUIET" ]] || echo "==> Downloading $VENDOR_URL2" >&2 | 
					
						
							|  |  |  |       "$HOMEBREW_CURL" "${curl_args[@]}" "$VENDOR_URL2" -o "$temporary_path" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if [[ ! -f "$temporary_path" ]] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       odie <<EOS | 
					
						
							|  |  |  | Failed to download $VENDOR_URL and $VENDOR_URL2! | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Do not file an issue on GitHub about this: you will need to figure out for | 
					
						
							|  |  |  | yourself what issue with your internet connection restricts your access to | 
					
						
							|  |  |  | both Bintray (used for Homebrew bottles/binary packages) and GitHub | 
					
						
							|  |  |  | (used for Homebrew updates). | 
					
						
							|  |  |  | EOS | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     trap '' SIGINT | 
					
						
							|  |  |  |     mv "$temporary_path" "$CACHED_LOCATION" | 
					
						
							|  |  |  |     trap - SIGINT | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 20:51:32 +01:00
										 |  |  |   if [[ -x "/usr/bin/shasum" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2017-10-17 20:51:32 +01:00
										 |  |  |     sha="$(/usr/bin/shasum -a 256 "$CACHED_LOCATION" | cut -d' ' -f1)" | 
					
						
							| 
									
										
										
										
											2018-03-17 23:02:05 -07:00
										 |  |  |   elif [[ -x "$(type -P sha256sum)" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							|  |  |  |     sha="$(sha256sum "$CACHED_LOCATION" | cut -d' ' -f1)" | 
					
						
							| 
									
										
										
										
											2018-03-17 23:02:05 -07:00
										 |  |  |   elif [[ -x "$(type -P ruby)" ]] | 
					
						
							| 
									
										
										
										
											2017-05-29 21:48:12 -07:00
										 |  |  |   then | 
					
						
							|  |  |  |     sha="$(ruby <<EOSCRIPT | 
					
						
							|  |  |  |             require 'digest/sha2' | 
					
						
							|  |  |  |             digest = Digest::SHA256.new | 
					
						
							|  |  |  |             File.open('$CACHED_LOCATION', 'rb') { |f| digest.update(f.read) } | 
					
						
							|  |  |  |             puts digest.hexdigest | 
					
						
							|  |  |  | EOSCRIPT | 
					
						
							|  |  |  | )"
 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   else | 
					
						
							|  |  |  |     odie "Cannot verify the checksum ('shasum' or 'sha256sum' not found)!" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ "$sha" != "$VENDOR_SHA" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     odie <<EOS | 
					
						
							|  |  |  | Checksum mismatch. | 
					
						
							|  |  |  | Expected: $VENDOR_SHA | 
					
						
							| 
									
										
										
										
											2019-04-01 16:02:13 -04:00
										 |  |  |   Actual: $sha | 
					
						
							|  |  |  |  Archive: $CACHED_LOCATION | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | To retry an incomplete download, remove the file above. | 
					
						
							|  |  |  | EOS | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | install() { | 
					
						
							|  |  |  |   local tar_args | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -n "$HOMEBREW_VERBOSE" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     tar_args="xvzf" | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     tar_args="xzf" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   mkdir -p "$VENDOR_DIR/portable-$VENDOR_NAME" | 
					
						
							|  |  |  |   safe_cd "$VENDOR_DIR/portable-$VENDOR_NAME" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   trap '' SIGINT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -d "$VENDOR_VERSION" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     mv "$VENDOR_VERSION" "$VENDOR_VERSION.reinstall" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   safe_cd "$VENDOR_DIR" | 
					
						
							| 
									
										
										
										
											2017-09-25 06:53:23 +01:00
										 |  |  |   [[ -n "$HOMEBREW_QUIET" ]] || echo "==> Pouring $(basename "$VENDOR_URL")" >&2 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   tar "$tar_args" "$CACHED_LOCATION" | 
					
						
							|  |  |  |   safe_cd "$VENDOR_DIR/portable-$VENDOR_NAME" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-16 10:27:35 -08:00
										 |  |  |   if quiet_stderr "./$VENDOR_VERSION/bin/$VENDOR_NAME" --version >/dev/null | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							|  |  |  |     ln -sfn "$VENDOR_VERSION" current | 
					
						
							|  |  |  |     if [[ -d "$VENDOR_VERSION.reinstall" ]] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       rm -rf "$VENDOR_VERSION.reinstall" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     rm -rf "$VENDOR_VERSION" | 
					
						
							|  |  |  |     if [[ -d "$VENDOR_VERSION.reinstall" ]] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       mv "$VENDOR_VERSION.reinstall" "$VENDOR_VERSION" | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2018-10-04 09:31:37 +01:00
										 |  |  |     odie "Failed to vendor $VENDOR_NAME $VENDOR_VERSION." | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   trap - SIGINT | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | homebrew-vendor-install() { | 
					
						
							|  |  |  |   local option | 
					
						
							|  |  |  |   local url_var | 
					
						
							|  |  |  |   local sha_var | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for option in "$@" | 
					
						
							|  |  |  |   do | 
					
						
							|  |  |  |     case "$option" in | 
					
						
							|  |  |  |       -\?|-h|--help|--usage) brew help vendor-install; exit $? ;; | 
					
						
							| 
									
										
										
										
											2016-08-07 12:51:46 +02:00
										 |  |  |       --verbose)             HOMEBREW_VERBOSE=1 ;; | 
					
						
							|  |  |  |       --quiet)               HOMEBREW_QUIET=1 ;; | 
					
						
							|  |  |  |       --debug)               HOMEBREW_DEBUG=1 ;; | 
					
						
							|  |  |  |       --*)                   ;; | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |       -*) | 
					
						
							|  |  |  |         [[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1 | 
					
						
							|  |  |  |         [[ "$option" = *q* ]] && HOMEBREW_QUIET=1 | 
					
						
							|  |  |  |         [[ "$option" = *d* ]] && HOMEBREW_DEBUG=1 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       *) | 
					
						
							|  |  |  |         [[ -n "$VENDOR_NAME" ]] && odie "This command does not take multiple vendor targets" | 
					
						
							|  |  |  |         VENDOR_NAME="$option" | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   [[ -z "$VENDOR_NAME" ]] && odie "This command requires one vendor target." | 
					
						
							|  |  |  |   [[ -n "$HOMEBREW_DEBUG" ]] && set -x | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   url_var="${VENDOR_NAME}_URL" | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  |   url2_var="${VENDOR_NAME}_URL2" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   sha_var="${VENDOR_NAME}_SHA" | 
					
						
							|  |  |  |   VENDOR_URL="${!url_var}" | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  |   VENDOR_URL2="${!url2_var}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   VENDOR_SHA="${!sha_var}" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -z "$VENDOR_URL" || -z "$VENDOR_SHA" ]] | 
					
						
							|  |  |  |   then | 
					
						
							| 
									
										
										
										
											2016-08-10 20:06:14 +01:00
										 |  |  |     odie <<-EOS | 
					
						
							|  |  |  | Cannot find a vendored version of $VENDOR_NAME for your $HOMEBREW_PROCESSOR | 
					
						
							|  |  |  | processor on $HOMEBREW_PRODUCT! | 
					
						
							|  |  |  | EOS | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-07 12:51:46 +02:00
										 |  |  |   VENDOR_VERSION="$(<"$VENDOR_DIR/portable-$VENDOR_NAME-version")" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   CACHED_LOCATION="$HOMEBREW_CACHE/$(basename "$VENDOR_URL")" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   lock "vendor-install-$VENDOR_NAME" | 
					
						
							|  |  |  |   fetch | 
					
						
							|  |  |  |   install | 
					
						
							|  |  |  | } |