Bottles: allow skipping or_later tags

This is a developer-only feature, so it's gated via `HOMEBREW_DEVELOPER`.
This is intended to enable testing of macOS 10.15; users building software
manually to test compatibility of early betas need to be able to build
software from source instead of via pouring 10.14 bottles. This isn't
intended to be a general-purpose `HOMEBREW_BUILD_FROM_SOURCE` replacement,
and has no effect on released versions of macOS.
This commit is contained in:
Misty De Meo 2019-06-05 19:48:38 -07:00
parent 80230eccf7
commit 5ab34abd17
No known key found for this signature in database
GPG Key ID: 76CF846A2F674B2C
3 changed files with 30 additions and 5 deletions

View File

@ -123,6 +123,10 @@ module HomebrewArgvExtension
!ENV["HOMEBREW_DEVELOPER"].nil?
end
def skip_or_later_bottles?
homebrew_developer? && !ENV["HOMEBREW_SKIP_OR_LATER_BOTTLES"].nil?
end
def no_sandbox?
include?("--no-sandbox") || !ENV["HOMEBREW_NO_SANDBOX"].nil?
end

View File

@ -16,8 +16,13 @@ module Utils
alias generic_find_matching_tag find_matching_tag
def find_matching_tag(tag)
generic_find_matching_tag(tag) ||
find_older_compatible_tag(tag)
# Used primarily by developers testing beta macOS releases.
if OS::Mac.prerelease? && ARGV.skip_or_later_bottles?
generic_find_matching_tag(tag)
else
generic_find_matching_tag(tag) ||
find_older_compatible_tag(tag)
end
end
def tag_without_or_later(tag)

View File

@ -20,9 +20,25 @@ describe Utils::Bottles::Collector do
end
it "uses older tags when needed", :needs_macos do
subject[:yosemite] = "foo"
expect(subject.fetch_checksum_for(:yosemite)).to eq(["foo", :yosemite])
expect(subject.fetch_checksum_for(:mavericks)).to be nil
subject[:mavericks] = "foo"
expect(subject.send(:find_matching_tag, :mavericks)).to eq(:mavericks)
expect(subject.send(:find_matching_tag, :yosemite)).to eq(:mavericks)
end
it "does not use older tags when requested not to", :needs_macos do
allow(ARGV).to receive(:skip_or_later_bottles?).and_return(true)
allow(OS::Mac).to receive(:prerelease?).and_return(true)
subject[:mavericks] = "foo"
expect(subject.send(:find_matching_tag, :mavericks)).to eq(:mavericks)
expect(subject.send(:find_matching_tag, :yosemite)).to be_nil
end
it "ignores HOMEBREW_SKIP_OR_LATER_BOTTLES on release versions", :needs_macos do
allow(ARGV).to receive(:skip_or_later_bottles?).and_return(true)
allow(OS::Mac).to receive(:prerelease?).and_return(false)
subject[:mavericks] = "foo"
expect(subject.send(:find_matching_tag, :mavericks)).to eq(:mavericks)
expect(subject.send(:find_matching_tag, :yosemite)).to eq(:mavericks)
end
end
end