| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-08 00:10:56 +00:00
										 |  |  | # HOMEBREW_CURLRC, HOMEBREW_LIBRARY is from the user environment | 
					
						
							| 
									
										
										
										
											2021-04-24 00:02:50 +09:00
										 |  |  | # HOMEBREW_CACHE, HOMEBREW_CURL, HOMEBREW_LINUX, HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION, HOMEBREW_MACOS, | 
					
						
							|  |  |  | # HOMEBREW_MACOS_VERSION_NUMERIC and HOMEBREW_PROCESSOR are set by brew.sh | 
					
						
							| 
									
										
										
										
											2021-04-23 22:56:08 +09:00
										 |  |  | # shellcheck disable=SC2154 | 
					
						
							|  |  |  | source "${HOMEBREW_LIBRARY}/Homebrew/utils/lock.sh" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  | VENDOR_DIR="${HOMEBREW_LIBRARY}/Homebrew/vendor" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  | # Built from https://github.com/Homebrew/homebrew-portable-ruby. | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  | set_ruby_variables() { | 
					
						
							|  |  |  |   if [[ -n "${HOMEBREW_MACOS}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     if [[ "${VENDOR_PHYSICAL_PROCESSOR}" == "x86_64" ]] || | 
					
						
							|  |  |  |        # Handle the case where /usr/local/bin/brew is run under arm64. | 
					
						
							|  |  |  |        # It's a x86_64 installation there (we refuse to install arm64 binaries) so | 
					
						
							|  |  |  |        # use a x86_64 Portable Ruby. | 
					
						
							|  |  |  |        [[ "${VENDOR_PHYSICAL_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]] | 
					
						
							|  |  |  |     then | 
					
						
							| 
									
										
										
										
											2024-05-16 14:57:20 +09:00
										 |  |  |       ruby_FILENAME="portable-ruby-3.3.1.el_capitan.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_SHA="34312337c0add491f876b04e8b273a258453d6b633226130ef3105373a97c950" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     elif [[ "${VENDOR_PHYSICAL_PROCESSOR}" == "arm64" ]] | 
					
						
							|  |  |  |     then | 
					
						
							| 
									
										
										
										
											2024-05-16 14:57:20 +09:00
										 |  |  |       ruby_FILENAME="portable-ruby-3.3.1.arm64_big_sur.bottle.tar.gz" | 
					
						
							|  |  |  |       ruby_SHA="86ff822590529e8e9093cdc1702a1d3321678c85347d30f82db4f993db8f9eb1" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  |   elif [[ -n "${HOMEBREW_LINUX}" ]] | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     case "${VENDOR_PROCESSOR}" in | 
					
						
							|  |  |  |       x86_64) | 
					
						
							| 
									
										
										
										
											2024-05-16 14:57:20 +09:00
										 |  |  |         ruby_FILENAME="portable-ruby-3.3.1.x86_64_linux.bottle.tar.gz" | 
					
						
							|  |  |  |         ruby_SHA="f49956aa43522c8e86127f7f5d377af2651fe35da975f5993eb2d038865c118c" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |         ;; | 
					
						
							|  |  |  |       *) ;; | 
					
						
							|  |  |  |     esac | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Dynamic variables can't be detected by shellcheck | 
					
						
							|  |  |  |   # shellcheck disable=SC2034 | 
					
						
							|  |  |  |   if [[ -n "${ruby_SHA}" && -n "${ruby_FILENAME}" ]] | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     ruby_URLs=() | 
					
						
							|  |  |  |     if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN}" ]] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       ruby_URLs+=("${HOMEBREW_ARTIFACT_DOMAIN}/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}") | 
					
						
							| 
									
										
										
										
											2024-05-14 16:03:35 +09:00
										 |  |  |       if [[ -n "${HOMEBREW_ARTIFACT_DOMAIN_NO_FALLBACK}" ]] | 
					
						
							|  |  |  |       then | 
					
						
							|  |  |  |         ruby_URL="${ruby_URLs[0]}" | 
					
						
							|  |  |  |         return | 
					
						
							|  |  |  |       fi | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  |     if [[ -n "${HOMEBREW_BOTTLE_DOMAIN}" ]] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       ruby_URLs+=("${HOMEBREW_BOTTLE_DOMAIN}/bottles-portable-ruby/${ruby_FILENAME}") | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     ruby_URLs+=( | 
					
						
							|  |  |  |       "https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}" | 
					
						
							| 
									
										
										
										
											2024-05-16 14:57:20 +09:00
										 |  |  |       "https://github.com/Homebrew/homebrew-portable-ruby/releases/download/3.3.1/${ruby_FILENAME}" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |     ) | 
					
						
							|  |  |  |     ruby_URL="${ruby_URLs[0]}" | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-04-09 09:17:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 17:40:58 -06:00
										 |  |  | check_linux_glibc_version() { | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   if [[ -z "${HOMEBREW_LINUX}" || -z "${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION}" ]] | 
					
						
							| 
									
										
										
										
											2020-12-16 17:40:58 -06:00
										 |  |  |   then | 
					
						
							|  |  |  |     return 0 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   local glibc_version | 
					
						
							|  |  |  |   local glibc_version_major | 
					
						
							|  |  |  |   local glibc_version_minor | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   local minimum_required_major="${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION%.*}" | 
					
						
							|  |  |  |   local minimum_required_minor="${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION#*.}" | 
					
						
							| 
									
										
										
										
											2020-12-15 06:43:11 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   if [[ "$(/usr/bin/ldd --version)" =~ \ [0-9]\.[0-9]+ ]] | 
					
						
							| 
									
										
										
										
											2020-12-14 16:49:52 -06:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |     glibc_version="${BASH_REMATCH[0]// /}" | 
					
						
							|  |  |  |     glibc_version_major="${glibc_version%.*}" | 
					
						
							|  |  |  |     glibc_version_minor="${glibc_version#*.}" | 
					
						
							|  |  |  |     if ((glibc_version_major < minimum_required_major || glibc_version_minor < minimum_required_minor)) | 
					
						
							| 
									
										
										
										
											2020-12-14 16:49:52 -06:00
										 |  |  |     then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |       odie "Vendored tools require system Glibc ${HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION} or later (yours is ${glibc_version})." | 
					
						
							| 
									
										
										
										
											2020-12-14 16:49:52 -06:00
										 |  |  |     fi | 
					
						
							|  |  |  |   else | 
					
						
							| 
									
										
										
										
											2020-12-15 06:43:11 -06:00
										 |  |  |     odie "Failed to detect system Glibc version." | 
					
						
							| 
									
										
										
										
											2020-12-14 16:49:52 -06:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2020-12-15 06:43:11 -06:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-12-14 16:49:52 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | fetch() { | 
					
						
							|  |  |  |   local -a curl_args | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   local url | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   local sha | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   local first_try=1 | 
					
						
							|  |  |  |   local vendor_locations | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   local temporary_path | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-08 15:51:58 -07:00
										 |  |  |   curl_args=() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # do not load .curlrc unless requested (must be the first argument) | 
					
						
							| 
									
										
										
										
											2021-05-18 17:10:20 +05:30
										 |  |  |   # HOMEBREW_CURLRC isn't misspelt here | 
					
						
							|  |  |  |   # shellcheck disable=SC2153 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ -z "${HOMEBREW_CURLRC}" ]] | 
					
						
							| 
									
										
										
										
											2018-04-08 15:51:58 -07:00
										 |  |  |   then | 
					
						
							|  |  |  |     curl_args[${#curl_args[*]}]="-q" | 
					
						
							| 
									
										
										
										
											2023-08-22 17:17:43 -04:00
										 |  |  |   elif [[ "${HOMEBREW_CURLRC}" == /* ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     curl_args+=("-q" "--config" "${HOMEBREW_CURLRC}") | 
					
						
							| 
									
										
										
										
											2018-04-08 15:51:58 -07:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 13:37:18 +01:00
										 |  |  |   # Authorization is needed for GitHub Packages but harmless on GitHub Releases | 
					
						
							| 
									
										
										
										
											2018-04-08 15:51:58 -07:00
										 |  |  |   curl_args+=( | 
					
						
							| 
									
										
										
										
											2016-08-07 12:51:46 +02:00
										 |  |  |     --fail | 
					
						
							|  |  |  |     --remote-time | 
					
						
							|  |  |  |     --location | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     --user-agent "${HOMEBREW_USER_AGENT_CURL}" | 
					
						
							| 
									
										
										
										
											2022-01-27 15:44:34 +00:00
										 |  |  |     --header "Authorization: ${HOMEBREW_GITHUB_PACKAGES_AUTH}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ -n "${HOMEBREW_QUIET}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2017-05-11 08:58:40 -07:00
										 |  |  |     curl_args[${#curl_args[*]}]="--silent" | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   elif [[ -z "${HOMEBREW_VERBOSE}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2017-05-11 08:58:40 -07:00
										 |  |  |     curl_args[${#curl_args[*]}]="--progress-bar" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "100600" ]] | 
					
						
							| 
									
										
										
										
											2017-09-25 19:15:58 +01:00
										 |  |  |   then | 
					
						
							|  |  |  |     curl_args[${#curl_args[*]}]="--insecure" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   temporary_path="${CACHED_LOCATION}.incomplete" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   mkdir -p "${HOMEBREW_CACHE}" | 
					
						
							|  |  |  |   [[ -n "${HOMEBREW_QUIET}" ]] || ohai "Downloading ${VENDOR_URL}" >&2 | 
					
						
							|  |  |  |   if [[ -f "${CACHED_LOCATION}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     [[ -n "${HOMEBREW_QUIET}" ]] || echo "Already downloaded: ${CACHED_LOCATION}" >&2 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |     for url in "${VENDOR_URLs[@]}" | 
					
						
							|  |  |  |     do | 
					
						
							|  |  |  |       [[ -n "${HOMEBREW_QUIET}" || -n "${first_try}" ]] || ohai "Downloading ${url}" >&2 | 
					
						
							|  |  |  |       first_try='' | 
					
						
							|  |  |  |       if [[ -f "${temporary_path}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |       then | 
					
						
							| 
									
										
										
										
											2023-02-10 23:15:40 -05:00
										 |  |  |         # HOMEBREW_CURL is set by brew.sh (and isn't misspelt here) | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |         # shellcheck disable=SC2153 | 
					
						
							|  |  |  |         "${HOMEBREW_CURL}" "${curl_args[@]}" -C - "${url}" -o "${temporary_path}" | 
					
						
							|  |  |  |         if [[ $? -eq 33 ]] | 
					
						
							|  |  |  |         then | 
					
						
							|  |  |  |           [[ -n "${HOMEBREW_QUIET}" ]] || echo "Trying a full download" >&2 | 
					
						
							|  |  |  |           rm -f "${temporary_path}" | 
					
						
							|  |  |  |           "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}" | 
					
						
							|  |  |  |         fi | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         "${HOMEBREW_CURL}" "${curl_args[@]}" "${url}" -o "${temporary_path}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |       fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |       [[ -f "${temporary_path}" ]] && break | 
					
						
							|  |  |  |     done | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     if [[ ! -f "${temporary_path}" ]] | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  |     then | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |       vendor_locations="$(printf "  - %s\n" "${VENDOR_URLs[@]}")" | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  |       odie <<EOS | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  | Failed to download ${VENDOR_NAME} from the following locations: | 
					
						
							|  |  |  | ${vendor_locations} | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 15:21:24 -05:00
										 |  |  | Do not file an issue on GitHub about this; you will need to figure out for | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  | yourself what issue with your internet connection restricts your access to | 
					
						
							| 
									
										
										
										
											2021-05-12 13:37:18 +01:00
										 |  |  | GitHub (used for Homebrew updates and binary packages). | 
					
						
							| 
									
										
										
										
											2018-01-14 13:49:26 +00:00
										 |  |  | EOS | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     trap '' SIGINT | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     mv "${temporary_path}" "${CACHED_LOCATION}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     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 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     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 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     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 | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |     sha="$( | 
					
						
							|  |  |  |       ruby <<EOSCRIPT | 
					
						
							|  |  |  | require 'digest/sha2' | 
					
						
							|  |  |  | digest = Digest::SHA256.new | 
					
						
							|  |  |  | File.open('${CACHED_LOCATION}', 'rb') { |f| digest.update(f.read) } | 
					
						
							|  |  |  | puts digest.hexdigest | 
					
						
							| 
									
										
										
										
											2017-05-29 21:48:12 -07:00
										 |  |  | EOSCRIPT | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |     )"
 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2020-05-02 13:53:45 +01:00
										 |  |  |     odie "Cannot verify checksum ('shasum' or 'sha256sum' not found)!" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ "${sha}" != "${VENDOR_SHA}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							|  |  |  |     odie <<EOS | 
					
						
							|  |  |  | Checksum mismatch. | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  | Expected: ${VENDOR_SHA} | 
					
						
							|  |  |  |   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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ -n "${HOMEBREW_VERBOSE}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							|  |  |  |     tar_args="xvzf" | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     tar_args="xzf" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   mkdir -p "${VENDOR_DIR}/portable-${VENDOR_NAME}" | 
					
						
							|  |  |  |   safe_cd "${VENDOR_DIR}/portable-${VENDOR_NAME}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   trap '' SIGINT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ -d "${VENDOR_VERSION}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     mv "${VENDOR_VERSION}" "${VENDOR_VERSION}.reinstall" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   safe_cd "${VENDOR_DIR}" | 
					
						
							|  |  |  |   [[ -n "${HOMEBREW_QUIET}" ]] || ohai "Pouring ${VENDOR_FILENAME}" >&2 | 
					
						
							|  |  |  |   tar "${tar_args}" "${CACHED_LOCATION}" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if [[ "${VENDOR_PROCESSOR}" != "${HOMEBREW_PROCESSOR}" ]] || | 
					
						
							|  |  |  |      [[ "${VENDOR_PHYSICAL_PROCESSOR}" != "${HOMEBREW_PHYSICAL_PROCESSOR}" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     return 0 | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   safe_cd "${VENDOR_DIR}/portable-${VENDOR_NAME}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-08 00:10:56 +00:00
										 |  |  |   if "./${VENDOR_VERSION}/bin/${VENDOR_NAME}" --version >/dev/null | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     ln -sfn "${VENDOR_VERSION}" current | 
					
						
							|  |  |  |     if [[ -d "${VENDOR_VERSION}.reinstall" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |       rm -rf "${VENDOR_VERSION}.reinstall" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     fi | 
					
						
							|  |  |  |   else | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     rm -rf "${VENDOR_VERSION}" | 
					
						
							|  |  |  |     if [[ -d "${VENDOR_VERSION}.reinstall" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |       mv "${VENDOR_VERSION}.reinstall" "${VENDOR_VERSION}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     odie "Failed to install ${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 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     case "${option}" in | 
					
						
							| 
									
										
										
										
											2021-09-16 01:08:02 +08:00
										 |  |  |       -\? | -h | --help | --usage) | 
					
						
							|  |  |  |         brew help vendor-install | 
					
						
							|  |  |  |         exit $? | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       --verbose) HOMEBREW_VERBOSE=1 ;; | 
					
						
							|  |  |  |       --quiet) HOMEBREW_QUIET=1 ;; | 
					
						
							|  |  |  |       --debug) HOMEBREW_DEBUG=1 ;; | 
					
						
							|  |  |  |       --*) ;; | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |       -*) | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |         [[ "${option}" == *v* ]] && HOMEBREW_VERBOSE=1 | 
					
						
							|  |  |  |         [[ "${option}" == *q* ]] && HOMEBREW_QUIET=1 | 
					
						
							|  |  |  |         [[ "${option}" == *d* ]] && HOMEBREW_DEBUG=1 | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |         ;; | 
					
						
							|  |  |  |       *) | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |         if [[ -n "${VENDOR_NAME}" ]] | 
					
						
							|  |  |  |         then | 
					
						
							|  |  |  |           if [[ -n "${HOMEBREW_DEVELOPER}" ]] | 
					
						
							|  |  |  |           then | 
					
						
							|  |  |  |             if [[ -n "${PROCESSOR_TARGET}" ]] | 
					
						
							|  |  |  |             then | 
					
						
							| 
									
										
										
										
											2024-01-18 09:41:19 -08:00
										 |  |  |               odie "This command does not take more than vendor and processor targets!" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |             else | 
					
						
							|  |  |  |               VENDOR_PHYSICAL_PROCESSOR="${option}" | 
					
						
							|  |  |  |               VENDOR_PROCESSOR="${option}" | 
					
						
							|  |  |  |             fi | 
					
						
							| 
									
										
										
										
											2024-01-18 17:35:47 +00:00
										 |  |  |           else | 
					
						
							|  |  |  |             odie "This command does not take multiple vendor targets!" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |           fi | 
					
						
							| 
									
										
										
										
											2024-01-18 17:35:47 +00:00
										 |  |  |         else | 
					
						
							|  |  |  |           VENDOR_NAME="${option}" | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  |         fi | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |         ;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   [[ -z "${VENDOR_NAME}" ]] && odie "This command requires a vendor target!" | 
					
						
							|  |  |  |   [[ -n "${HOMEBREW_DEBUG}" ]] && set -x | 
					
						
							| 
									
										
										
										
											2024-01-18 14:38:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if [[ -z "${VENDOR_PHYSICAL_PROCESSOR}" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     VENDOR_PHYSICAL_PROCESSOR="${HOMEBREW_PHYSICAL_PROCESSOR}" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -z "${VENDOR_PROCESSOR}" ]] | 
					
						
							|  |  |  |   then | 
					
						
							|  |  |  |     VENDOR_PROCESSOR="${HOMEBREW_PROCESSOR}" | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   set_ruby_variables | 
					
						
							| 
									
										
										
										
											2020-12-16 17:40:58 -06:00
										 |  |  |   check_linux_glibc_version | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-08 10:03:24 +01:00
										 |  |  |   filename_var="${VENDOR_NAME}_FILENAME" | 
					
						
							|  |  |  |   sha_var="${VENDOR_NAME}_SHA" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   url_var="${VENDOR_NAME}_URL" | 
					
						
							| 
									
										
										
										
											2021-04-08 10:03:24 +01:00
										 |  |  |   VENDOR_FILENAME="${!filename_var}" | 
					
						
							|  |  |  |   VENDOR_SHA="${!sha_var}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   VENDOR_URL="${!url_var}" | 
					
						
							| 
									
										
										
										
											2023-11-29 15:27:50 +00:00
										 |  |  |   VENDOR_VERSION="$(cat "${VENDOR_DIR}/portable-${VENDOR_NAME}-version")" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   if [[ -z "${VENDOR_URL}" || -z "${VENDOR_SHA}" ]] | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   then | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |     odie "No Homebrew ${VENDOR_NAME} ${VENDOR_VERSION} available for ${HOMEBREW_PROCESSOR} processors!" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  |   # Expand the name to an array of variables | 
					
						
							|  |  |  |   # The array name must be "${VENDOR_NAME}_URLs"! Otherwise substitution errors will occur! | 
					
						
							|  |  |  |   # shellcheck disable=SC2086 | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   read -r -a VENDOR_URLs <<<"$(eval "echo "\$\{${url_var}s[@]\}"")" | 
					
						
							| 
									
										
										
										
											2021-09-12 21:28:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   CACHED_LOCATION="${HOMEBREW_CACHE}/${VENDOR_FILENAME}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-18 17:28:35 +05:30
										 |  |  |   lock "vendor-install-${VENDOR_NAME}" | 
					
						
							| 
									
										
										
										
											2016-05-03 16:01:42 +08:00
										 |  |  |   fetch | 
					
						
							|  |  |  |   install | 
					
						
							|  |  |  | } |