fetch/build formula from source when modified
closes Homebrew/homebrew#36068 Closes Homebrew/homebrew#41397. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
d88f84138e
commit
da2e4d417d
@ -32,6 +32,13 @@ module Homebrew
|
||||
def fetch_bottle? f
|
||||
return true if ARGV.force_bottle? && f.bottle
|
||||
return false unless f.bottle && f.pour_bottle?
|
||||
if f.file_modified?
|
||||
filename = f.path.to_s.gsub("#{HOMEBREW_PREFIX}/", "")
|
||||
opoo "Formula file is modified!"
|
||||
puts "Fetching source because #{filename} has local changes"
|
||||
puts "To fetch the bottle instead, run with --force-bottle"
|
||||
return false
|
||||
end
|
||||
return false if ARGV.build_from_source? || ARGV.build_bottle?
|
||||
return false unless f.bottle.compatible_cellar?
|
||||
return true
|
||||
|
||||
@ -601,6 +601,14 @@ class Formula
|
||||
s << ") #{path}>"
|
||||
end
|
||||
|
||||
def file_modified?
|
||||
return false unless which("git")
|
||||
path.parent.cd do
|
||||
diff = Utils.popen_read("git", "diff", "origin/master", "--", "#{path}")
|
||||
!diff.empty? && $?.exitstatus == 0
|
||||
end
|
||||
end
|
||||
|
||||
# Standard parameters for CMake builds.
|
||||
# Setting CMAKE_FIND_FRAMEWORK to "LAST" tells CMake to search for our
|
||||
# libraries before trying to utilize Frameworks, many of which will be from
|
||||
@ -1187,4 +1195,3 @@ class Formula
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ class FormulaInstaller
|
||||
|
||||
bottle = formula.bottle
|
||||
return true if force_bottle? && bottle
|
||||
return false if build_from_source? || build_bottle? || interactive?
|
||||
return false if build_from_source? || build_bottle? || interactive? || formula.file_modified?
|
||||
return false unless options.empty?
|
||||
|
||||
return true if formula.local_bottle_path
|
||||
@ -180,6 +180,12 @@ class FormulaInstaller
|
||||
build_bottle_preinstall if build_bottle?
|
||||
|
||||
unless @poured_bottle
|
||||
if formula.file_modified?
|
||||
filename = formula.path.to_s.gsub("#{HOMEBREW_PREFIX}/", "")
|
||||
opoo "Formula file is modified!"
|
||||
puts "Building from source because #{filename} has local changes"
|
||||
puts "To install from a bottle instead, run with --force-bottle"
|
||||
end
|
||||
compute_and_install_dependencies if @pour_failed and not ignore_deps?
|
||||
build
|
||||
clean
|
||||
|
||||
@ -7,6 +7,7 @@ class BottleHookTests < Homebrew::TestCase
|
||||
def bottle; end
|
||||
def local_bottle_path; end
|
||||
def some_random_method; true; end
|
||||
def file_modified?; end
|
||||
end
|
||||
|
||||
def setup
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user