| 
									
										
										
										
											2021-09-11 01:00:23 +01:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 16:07:47 +01:00
										 |  |  | require_relative "startup" | 
					
						
							| 
									
										
										
										
											2021-01-21 12:34:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 14:23:33 +02:00
										 |  |  | require "English" | 
					
						
							| 
									
										
										
										
											2021-03-24 09:04:49 +01:00
										 |  |  | require "fileutils" | 
					
						
							| 
									
										
										
										
											2018-08-17 22:42:37 -04:00
										 |  |  | require "json" | 
					
						
							|  |  |  | require "json/add/exception" | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  | require "forwardable" | 
					
						
							| 
									
										
										
										
											2023-03-08 09:16:53 -08:00
										 |  |  | require "set" | 
					
						
							| 
									
										
										
										
											2018-07-17 14:23:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-12 15:17:12 -08:00
										 |  |  | require "extend/array" | 
					
						
							|  |  |  | require "extend/blank" | 
					
						
							|  |  |  | require "extend/enumerable" | 
					
						
							|  |  |  | require "extend/string" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-03 14:10:40 +00:00
										 |  |  | HOMEBREW_API_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_API_DEFAULT_DOMAIN").freeze | 
					
						
							| 
									
										
										
										
											2022-05-30 04:25:24 +01:00
										 |  |  | HOMEBREW_BOTTLE_DEFAULT_DOMAIN = ENV.fetch("HOMEBREW_BOTTLE_DEFAULT_DOMAIN").freeze | 
					
						
							|  |  |  | HOMEBREW_BREW_DEFAULT_GIT_REMOTE = ENV.fetch("HOMEBREW_BREW_DEFAULT_GIT_REMOTE").freeze | 
					
						
							|  |  |  | HOMEBREW_CORE_DEFAULT_GIT_REMOTE = ENV.fetch("HOMEBREW_CORE_DEFAULT_GIT_REMOTE").freeze | 
					
						
							|  |  |  | HOMEBREW_DEFAULT_CACHE = ENV.fetch("HOMEBREW_DEFAULT_CACHE").freeze | 
					
						
							|  |  |  | HOMEBREW_DEFAULT_LOGS = ENV.fetch("HOMEBREW_DEFAULT_LOGS").freeze | 
					
						
							|  |  |  | HOMEBREW_DEFAULT_TEMP = ENV.fetch("HOMEBREW_DEFAULT_TEMP").freeze | 
					
						
							|  |  |  | HOMEBREW_REQUIRED_RUBY_VERSION = ENV.fetch("HOMEBREW_REQUIRED_RUBY_VERSION").freeze | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HOMEBREW_PRODUCT = ENV.fetch("HOMEBREW_PRODUCT").freeze | 
					
						
							|  |  |  | HOMEBREW_VERSION = ENV.fetch("HOMEBREW_VERSION").freeze | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | HOMEBREW_WWW = "https://brew.sh" | 
					
						
							| 
									
										
										
										
											2023-09-09 12:04:54 -04:00
										 |  |  | HOMEBREW_API_WWW = "https://formulae.brew.sh" | 
					
						
							| 
									
										
										
										
											2022-09-11 22:10:37 -05:00
										 |  |  | HOMEBREW_DOCS_WWW = "https://docs.brew.sh" | 
					
						
							| 
									
										
										
										
											2022-05-30 04:25:24 +01:00
										 |  |  | HOMEBREW_SYSTEM = ENV.fetch("HOMEBREW_SYSTEM").freeze | 
					
						
							|  |  |  | HOMEBREW_PROCESSOR = ENV.fetch("HOMEBREW_PROCESSOR").freeze | 
					
						
							| 
									
										
										
										
											2023-02-15 16:34:50 +00:00
										 |  |  | HOMEBREW_PHYSICAL_PROCESSOR = ENV.fetch("HOMEBREW_PHYSICAL_PROCESSOR").freeze | 
					
						
							| 
									
										
										
										
											2009-10-15 12:36:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 04:25:24 +01:00
										 |  |  | HOMEBREW_BREWED_CURL_PATH = Pathname(ENV.fetch("HOMEBREW_BREWED_CURL_PATH")).freeze | 
					
						
							|  |  |  | HOMEBREW_USER_AGENT_CURL = ENV.fetch("HOMEBREW_USER_AGENT_CURL").freeze | 
					
						
							| 
									
										
										
										
											2018-09-02 16:15:09 +01:00
										 |  |  | HOMEBREW_USER_AGENT_RUBY = | 
					
						
							| 
									
										
										
										
											2023-12-16 11:47:46 +00:00
										 |  |  |   "#{ENV.fetch("HOMEBREW_USER_AGENT")} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze | 
					
						
							| 
									
										
										
										
											2018-09-02 16:15:09 +01:00
										 |  |  | HOMEBREW_USER_AGENT_FAKE_SAFARI = | 
					
						
							| 
									
										
										
										
											2023-10-21 09:37:57 +01:00
										 |  |  |   # Don't update this beyond 10.15.7 until Safari actually updates their | 
					
						
							|  |  |  |   # user agent to be beyond 10.15.7 (not the case as-of macOS 14) | 
					
						
							|  |  |  |   "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 " \ | 
					
						
							| 
									
										
										
										
											2023-10-20 19:43:41 -04:00
										 |  |  |   "(KHTML, like Gecko) Version/17.0 Safari/605.1.15" | 
					
						
							| 
									
										
										
										
											2022-05-30 04:25:24 +01:00
										 |  |  | HOMEBREW_GITHUB_PACKAGES_AUTH = ENV.fetch("HOMEBREW_GITHUB_PACKAGES_AUTH").freeze | 
					
						
							| 
									
										
										
										
											2009-11-05 21:37:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-24 13:25:18 +00:00
										 |  |  | HOMEBREW_DEFAULT_PREFIX = ENV.fetch("HOMEBREW_GENERIC_DEFAULT_PREFIX").freeze | 
					
						
							|  |  |  | HOMEBREW_DEFAULT_REPOSITORY = ENV.fetch("HOMEBREW_GENERIC_DEFAULT_REPOSITORY").freeze | 
					
						
							|  |  |  | HOMEBREW_MACOS_ARM_DEFAULT_PREFIX = ENV.fetch("HOMEBREW_MACOS_ARM_DEFAULT_PREFIX").freeze | 
					
						
							|  |  |  | HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY = ENV.fetch("HOMEBREW_MACOS_ARM_DEFAULT_REPOSITORY").freeze | 
					
						
							|  |  |  | HOMEBREW_LINUX_DEFAULT_PREFIX = ENV.fetch("HOMEBREW_LINUX_DEFAULT_PREFIX").freeze | 
					
						
							|  |  |  | HOMEBREW_LINUX_DEFAULT_REPOSITORY = ENV.fetch("HOMEBREW_LINUX_DEFAULT_REPOSITORY").freeze | 
					
						
							| 
									
										
										
										
											2023-02-14 14:19:40 +00:00
										 |  |  | HOMEBREW_PREFIX_PLACEHOLDER = "$HOMEBREW_PREFIX" | 
					
						
							| 
									
										
										
										
											2023-07-18 10:59:27 +01:00
										 |  |  | HOMEBREW_CELLAR_PLACEHOLDER = "$HOMEBREW_CELLAR" | 
					
						
							| 
									
										
										
										
											2023-03-21 19:05:41 -07:00
										 |  |  | # Needs a leading slash to avoid `File.expand.path` complaining about non-absolute home. | 
					
						
							|  |  |  | HOMEBREW_HOME_PLACEHOLDER = "/$HOME" | 
					
						
							| 
									
										
										
										
											2023-03-22 19:43:49 -07:00
										 |  |  | HOMEBREW_CASK_APPDIR_PLACEHOLDER = "$APPDIR" | 
					
						
							| 
									
										
										
										
											2019-09-30 16:09:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-24 13:25:18 +00:00
										 |  |  | HOMEBREW_MACOS_NEWEST_UNSUPPORTED = ENV.fetch("HOMEBREW_MACOS_NEWEST_UNSUPPORTED").freeze | 
					
						
							|  |  |  | HOMEBREW_MACOS_OLDEST_SUPPORTED = ENV.fetch("HOMEBREW_MACOS_OLDEST_SUPPORTED").freeze | 
					
						
							|  |  |  | HOMEBREW_MACOS_OLDEST_ALLOWED = ENV.fetch("HOMEBREW_MACOS_OLDEST_ALLOWED").freeze | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-29 21:23:44 +01:00
										 |  |  | HOMEBREW_PULL_API_REGEX = | 
					
						
							| 
									
										
										
										
											2024-01-18 22:18:42 +00:00
										 |  |  |   %r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)} | 
					
						
							| 
									
										
										
										
											2020-11-29 21:23:44 +01:00
										 |  |  | HOMEBREW_PULL_OR_COMMIT_URL_REGEX = | 
					
						
							| 
									
										
										
										
											2024-01-18 22:18:42 +00:00
										 |  |  |   %r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})] | 
					
						
							|  |  |  | HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/ | 
					
						
							| 
									
										
										
										
											2020-11-29 21:23:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-29 09:11:35 +00:00
										 |  |  | require "env_config" | 
					
						
							| 
									
										
										
										
											2023-05-09 02:15:28 +02:00
										 |  |  | require "macos_version" | 
					
						
							| 
									
										
										
										
											2021-03-24 09:04:49 +01:00
										 |  |  | require "os" | 
					
						
							| 
									
										
										
										
											2020-11-29 21:23:44 +01:00
										 |  |  | require "messages" | 
					
						
							| 
									
										
										
										
											2021-05-12 16:07:47 +01:00
										 |  |  | require "default_prefix" | 
					
						
							| 
									
										
										
										
											2013-10-21 04:24:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   extend FileUtils | 
					
						
							| 
									
										
										
										
											2012-03-15 10:57:34 +13:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-16 11:47:46 +00:00
										 |  |  |   DEFAULT_CELLAR = "#{DEFAULT_PREFIX}/Cellar".freeze | 
					
						
							|  |  |  |   DEFAULT_MACOS_CELLAR = "#{HOMEBREW_DEFAULT_PREFIX}/Cellar".freeze | 
					
						
							|  |  |  |   DEFAULT_MACOS_ARM_CELLAR = "#{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}/Cellar".freeze | 
					
						
							|  |  |  |   DEFAULT_LINUX_CELLAR = "#{HOMEBREW_LINUX_DEFAULT_PREFIX}/Cellar".freeze | 
					
						
							| 
									
										
										
										
											2018-09-06 16:58:17 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   class << self | 
					
						
							| 
									
										
										
										
											2020-09-23 03:43:54 +02:00
										 |  |  |     attr_writer :failed, :raise_deprecation_exceptions, :auditing | 
					
						
							| 
									
										
										
										
											2016-08-12 21:06:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 15:36:04 +11:00
										 |  |  |     def default_prefix?(prefix = HOMEBREW_PREFIX) | 
					
						
							| 
									
										
										
										
											2018-09-06 16:58:17 -07:00
										 |  |  |       prefix.to_s == DEFAULT_PREFIX | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |     def failed? | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  |       @failed ||= false | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |       @failed == true | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-20 02:10:54 -04:00
										 |  |  |     def messages | 
					
						
							|  |  |  |       @messages ||= Messages.new | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |     def raise_deprecation_exceptions? | 
					
						
							|  |  |  |       @raise_deprecation_exceptions == true | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-09-02 12:38:18 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |     def auditing? | 
					
						
							|  |  |  |       @auditing == true | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2023-02-23 10:04:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def running_as_root? | 
					
						
							|  |  |  |       @process_uid ||= Process.uid | 
					
						
							|  |  |  |       @process_uid.zero? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def owner_uid | 
					
						
							|  |  |  |       @owner_uid ||= HOMEBREW_BREW_FILE.stat.uid | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def running_as_root_but_not_owned_by_root? | 
					
						
							|  |  |  |       running_as_root? && !owner_uid.zero? | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2023-03-10 17:53:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def auto_update_command? | 
					
						
							|  |  |  |       ENV.fetch("HOMEBREW_AUTO_UPDATE_COMMAND", false).present? | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-29 21:23:44 +01:00
										 |  |  | require "context" | 
					
						
							| 
									
										
										
										
											2023-04-15 19:35:00 -07:00
										 |  |  | require "git_repository" | 
					
						
							| 
									
										
										
										
											2020-11-29 21:23:44 +01:00
										 |  |  | require "extend/pathname" | 
					
						
							|  |  |  | require "cli/args" | 
					
						
							| 
									
										
										
										
											2011-08-02 12:00:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | require "PATH" | 
					
						
							| 
									
										
											  
											
												Core change: XCode only install, with CLT or both
Allow XCode without the Command Line Tools to
work with homebrew, so it's not necessary
to register an Apple Dev ID and/or go to the
XCode prefs and download the CLT. Yay!
Further, this commit allows to use the CLT
solely (without the need for XCode).
Saves quite some megs.
(Some furmulae require xcodebuild)
Of course XCode together with the CLT is still
fine and has been tested on 10.7 and 10.6
with Xcode 4 and Xcode 3.
Only on Lion or above, tell the user about the options,
which are
- Xcode without CLT
- CLT without Xcode
- both (ok, it's not directly stated, but implicit)
So if no Xcode is found and we are on Lion or above,
we don't fail but check for the CLTs now.
For older Macs, the old message that Xcode is needed
and the installer should be run is still displayed.
If the CLT are not found but Xcode is, then we
print out about the experimental status of this setup.
Closes Homebrew/homebrew#10510.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
											
										 
											2012-02-26 21:04:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-15 05:40:43 +01:00
										 |  |  | ENV["HOMEBREW_PATH"] ||= ENV.fetch("PATH") | 
					
						
							|  |  |  | ORIGINAL_PATHS = PATH.new(ENV.fetch("HOMEBREW_PATH")).map do |p| | 
					
						
							| 
									
										
										
										
											2019-10-13 10:03:26 +01:00
										 |  |  |   Pathname.new(p).expand_path | 
					
						
							|  |  |  | rescue | 
					
						
							|  |  |  |   nil | 
					
						
							| 
									
										
										
										
											2016-09-17 15:17:27 +01:00
										 |  |  | end.compact.freeze | 
					
						
							| 
									
										
										
										
											2015-06-26 15:19:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-02 14:32:31 +02:00
										 |  |  | require "system_command" | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | require "exceptions" | 
					
						
							|  |  |  | require "utils" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "official_taps" | 
					
						
							|  |  |  | require "tap" | 
					
						
							|  |  |  | require "tap_constants" |