Merge pull request #4290 from MikeMcQuaid/check-linkage
linkage_checker: fix cache invalidation.
This commit is contained in:
commit
9c1a988c32
@ -607,7 +607,7 @@ class FormulaInstaller
|
||||
# Updates the cache for a particular formula after doing an install
|
||||
CacheStoreDatabase.use(:linkage) do |db|
|
||||
break unless db.created?
|
||||
LinkageChecker.new(keg, formula, cache_db: db)
|
||||
LinkageChecker.new(keg, formula, cache_db: db, rebuild_cache: true)
|
||||
end
|
||||
|
||||
# Update tab with actual runtime dependencies
|
||||
|
||||
@ -272,6 +272,11 @@ class Keg
|
||||
end
|
||||
|
||||
def uninstall
|
||||
CacheStoreDatabase.use(:linkage) do |db|
|
||||
break unless db.created?
|
||||
LinkageCacheStore.new(path, db).flush_cache!
|
||||
end
|
||||
|
||||
path.rmtree
|
||||
path.parent.rmdir_if_possible
|
||||
remove_opt_record if optlinked?
|
||||
|
||||
@ -6,19 +6,19 @@ require "cache_store"
|
||||
# by the `brew linkage` command
|
||||
#
|
||||
class LinkageCacheStore < CacheStore
|
||||
# @param [String] keg_name
|
||||
# @param [String] keg_path
|
||||
# @param [CacheStoreDatabase] database
|
||||
# @return [nil]
|
||||
def initialize(keg_name, database)
|
||||
@keg_name = keg_name
|
||||
def initialize(keg_path, database)
|
||||
@keg_path = keg_path
|
||||
super(database)
|
||||
end
|
||||
|
||||
# Returns `true` if the database has any value for the current `keg_name`
|
||||
# Returns `true` if the database has any value for the current `keg_path`
|
||||
#
|
||||
# @return [Boolean]
|
||||
def keg_exists?
|
||||
!database.get(@keg_name).nil?
|
||||
!database.get(@keg_path).nil?
|
||||
end
|
||||
|
||||
# Inserts dylib-related information into the cache if it does not exist or
|
||||
@ -35,7 +35,7 @@ class LinkageCacheStore < CacheStore
|
||||
EOS
|
||||
end
|
||||
|
||||
database.set @keg_name, ruby_hash_to_json_string(hash_values)
|
||||
database.set @keg_path, ruby_hash_to_json_string(hash_values)
|
||||
end
|
||||
|
||||
# @param [Symbol] the type to fetch from the `LinkageCacheStore`
|
||||
@ -55,7 +55,7 @@ class LinkageCacheStore < CacheStore
|
||||
|
||||
# @return [nil]
|
||||
def flush_cache!
|
||||
database.delete(@keg_name)
|
||||
database.delete(@keg_path)
|
||||
end
|
||||
|
||||
private
|
||||
@ -65,7 +65,7 @@ class LinkageCacheStore < CacheStore
|
||||
# @param [Symbol] type
|
||||
# @return [Hash]
|
||||
def fetch_hash_values(type)
|
||||
keg_cache = database.get(@keg_name)
|
||||
keg_cache = database.get(@keg_path)
|
||||
return {} unless keg_cache
|
||||
json_string_to_ruby_hash(keg_cache)[type.to_s]
|
||||
end
|
||||
|
||||
@ -6,10 +6,11 @@ class LinkageChecker
|
||||
attr_reader :undeclared_deps
|
||||
|
||||
def initialize(keg, formula = nil, cache_db:,
|
||||
use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil?)
|
||||
use_cache: !ENV["HOMEBREW_LINKAGE_CACHE"].nil?,
|
||||
rebuild_cache: false)
|
||||
@keg = keg
|
||||
@formula = formula || resolve_formula(keg)
|
||||
@store = LinkageCacheStore.new(keg.name, cache_db) if use_cache
|
||||
@store = LinkageCacheStore.new(keg.to_s, cache_db) if use_cache
|
||||
|
||||
@system_dylibs = Set.new
|
||||
@broken_dylibs = Set.new
|
||||
@ -21,7 +22,7 @@ class LinkageChecker
|
||||
@undeclared_deps = []
|
||||
@unnecessary_deps = []
|
||||
|
||||
check_dylibs
|
||||
check_dylibs(rebuild_cache: rebuild_cache)
|
||||
end
|
||||
|
||||
def display_normal_output
|
||||
@ -67,9 +68,16 @@ class LinkageChecker
|
||||
Regexp.last_match(2)
|
||||
end
|
||||
|
||||
def check_dylibs
|
||||
def check_dylibs(rebuild_cache:)
|
||||
keg_files_dylibs = nil
|
||||
|
||||
if rebuild_cache
|
||||
store&.flush_cache!
|
||||
else
|
||||
keg_files_dylibs = store&.fetch_type(:keg_files_dylibs)
|
||||
end
|
||||
|
||||
keg_files_dylibs_was_empty = false
|
||||
keg_files_dylibs = store&.fetch_type(:keg_files_dylibs)
|
||||
keg_files_dylibs ||= {}
|
||||
if keg_files_dylibs.empty?
|
||||
keg_files_dylibs_was_empty = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user