@@ -42,8 +42,14 @@ def to_formula(prefer_stub: false)
4242 formula
4343 end
4444
45- sig { params ( minimum_version : T . nilable ( Version ) , minimum_revision : T . nilable ( Integer ) ) . returns ( T ::Boolean ) }
46- def installed? ( minimum_version : nil , minimum_revision : nil )
45+ sig {
46+ params (
47+ minimum_version : T . nilable ( Version ) ,
48+ minimum_revision : T . nilable ( Integer ) ,
49+ bottle_os_version : T . nilable ( String ) ,
50+ ) . returns ( T ::Boolean )
51+ }
52+ def installed? ( minimum_version : nil , minimum_revision : nil , bottle_os_version : nil )
4753 formula = begin
4854 to_formula ( prefer_stub : true )
4955 rescue FormulaUnavailableError
@@ -80,8 +86,8 @@ def installed?(minimum_version: nil, minimum_revision: nil)
8086 end
8187 end
8288
83- def satisfied? ( inherited_options = [ ] , minimum_version : nil , minimum_revision : nil )
84- installed? ( minimum_version :, minimum_revision :) &&
89+ def satisfied? ( inherited_options = [ ] , minimum_version : nil , minimum_revision : nil , bottle_os_version : nil )
90+ installed? ( minimum_version :, minimum_revision :, bottle_os_version : ) &&
8591 missing_options ( inherited_options ) . empty?
8692 end
8793
@@ -261,22 +267,37 @@ def hash
261267 [ name , tags , bounds ] . hash
262268 end
263269
264- sig { params ( minimum_version : T . nilable ( Version ) , minimum_revision : T . nilable ( Integer ) ) . returns ( T ::Boolean ) }
265- def installed? ( minimum_version : nil , minimum_revision : nil )
266- use_macos_install? || super
270+ sig {
271+ params (
272+ minimum_version : T . nilable ( Version ) ,
273+ minimum_revision : T . nilable ( Integer ) ,
274+ bottle_os_version : T . nilable ( String ) ,
275+ ) . returns ( T ::Boolean )
276+ }
277+ def installed? ( minimum_version : nil , minimum_revision : nil , bottle_os_version : nil )
278+ use_macos_install? ( bottle_os_version :) || super
267279 end
268280
269- sig { returns ( T ::Boolean ) }
270- def use_macos_install?
281+ sig { params ( bottle_os_version : T . nilable ( String ) ) . returns ( T ::Boolean ) }
282+ def use_macos_install? ( bottle_os_version : nil )
271283 # Check whether macOS is new enough for dependency to not be required.
272284 if Homebrew ::SimulateSystem . simulating_or_running_on_macos?
273- # Assume the oldest macOS version when simulating a generic macOS version
274- return true if Homebrew ::SimulateSystem . current_os == :macos && !bounds . key? ( :since )
285+ # If there's no since bound, the dependency is always available from macOS
286+ return true if !bounds . key? ( :since ) && Homebrew ::SimulateSystem . current_os == :macos
287+
288+ # When installing a bottle built on an older macOS version, use that version
289+ # to determine if the dependency should come from macOS or Homebrew
290+ effective_os = if bottle_os_version . present? && Homebrew ::SimulateSystem . current_os != :macos
291+ # bottle_os_version is a string like "14" for Sonoma, "15" for Sequoia
292+ # Convert it to a MacOS version symbol for comparison
293+ MacOSVersion . new ( bottle_os_version )
294+ else
295+ MacOSVersion . from_symbol ( Homebrew ::SimulateSystem . current_os )
296+ end
275297
276- if Homebrew ::SimulateSystem . current_os != :macos
277- current_os = MacOSVersion . from_symbol ( Homebrew ::SimulateSystem . current_os )
278- since_os = MacOSVersion . from_symbol ( bounds [ :since ] ) if bounds . key? ( :since )
279- return true if current_os >= since_os
298+ if bounds . key? ( :since )
299+ since_os = MacOSVersion . from_symbol ( bounds [ :since ] )
300+ return true if effective_os >= since_os
280301 end
281302 end
282303
0 commit comments