brew-postgresql-upgrade-database: don't use old kegs. (#35169)

Instead always rely on the versioned formulae that are properly supported.

Reference #34879.
master
Mike McQuaid 2018-12-16 20:01:17 +00:00 committed by GitHub
parent 5c61ae3abd
commit 49dcf82cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -25,13 +25,14 @@ if old_datadir.exist?
EOS
end
old_bin = Pathname.glob("#{HOMEBREW_PREFIX}/Cellar/#{name}{,@#{pg_version_data}}/#{pg_version_data}.*/bin").first
old_bin ||= begin
old_pg_name = "#{name}@#{pg_version_data}"
old_pg_glob = "#{HOMEBREW_PREFIX}/Cellar/#{old_pg_name}/#{pg_version_data}.*/bin"
old_bin = Pathname.glob(old_pg_glob).first
old_bin ||= begin
Formula[old_pg_name]
ohai "brew install #{old_pg_name}"
system "brew", "install", old_pg_name
Pathname.glob("#{HOMEBREW_PREFIX}/Cellar/#{old_pg_name}/#{pg_version_data}.*/bin").first
Pathname.glob(old_pg_glob).first
rescue FormulaUnavailableError
nil
end