Merge pull request #15781 from MikeMcQuaid/post_install_improvements_fixes
post_install: improvements and fixes.
This commit is contained in:
commit
389bcf4eb4
@ -826,6 +826,7 @@ case "${HOMEBREW_COMMAND}" in
|
|||||||
ln) HOMEBREW_COMMAND="link" ;;
|
ln) HOMEBREW_COMMAND="link" ;;
|
||||||
instal) HOMEBREW_COMMAND="install" ;; # gem does the same
|
instal) HOMEBREW_COMMAND="install" ;; # gem does the same
|
||||||
uninstal) HOMEBREW_COMMAND="uninstall" ;;
|
uninstal) HOMEBREW_COMMAND="uninstall" ;;
|
||||||
|
post_install) HOMEBREW_COMMAND="postinstall" ;;
|
||||||
rm) HOMEBREW_COMMAND="uninstall" ;;
|
rm) HOMEBREW_COMMAND="uninstall" ;;
|
||||||
remove) HOMEBREW_COMMAND="uninstall" ;;
|
remove) HOMEBREW_COMMAND="uninstall" ;;
|
||||||
abv) HOMEBREW_COMMAND="info" ;;
|
abv) HOMEBREW_COMMAND="info" ;;
|
||||||
|
@ -28,6 +28,8 @@ module Homebrew
|
|||||||
if f.post_install_defined?
|
if f.post_install_defined?
|
||||||
fi = FormulaInstaller.new(f, **{ debug: args.debug?, quiet: args.quiet?, verbose: args.verbose? }.compact)
|
fi = FormulaInstaller.new(f, **{ debug: args.debug?, quiet: args.quiet?, verbose: args.verbose? }.compact)
|
||||||
fi.post_install
|
fi.post_install
|
||||||
|
else
|
||||||
|
opoo "#{f}: no `post_install` method was defined in the formula!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,23 +12,24 @@ module Commands
|
|||||||
# If you are going to change anything in below hash,
|
# If you are going to change anything in below hash,
|
||||||
# be sure to also update appropriate case statement in brew.sh
|
# be sure to also update appropriate case statement in brew.sh
|
||||||
HOMEBREW_INTERNAL_COMMAND_ALIASES = {
|
HOMEBREW_INTERNAL_COMMAND_ALIASES = {
|
||||||
"ls" => "list",
|
"ls" => "list",
|
||||||
"homepage" => "home",
|
"homepage" => "home",
|
||||||
"-S" => "search",
|
"-S" => "search",
|
||||||
"up" => "update",
|
"up" => "update",
|
||||||
"ln" => "link",
|
"ln" => "link",
|
||||||
"instal" => "install", # gem does the same
|
"instal" => "install", # gem does the same
|
||||||
"uninstal" => "uninstall",
|
"uninstal" => "uninstall",
|
||||||
"rm" => "uninstall",
|
"post_install" => "postinstall",
|
||||||
"remove" => "uninstall",
|
"rm" => "uninstall",
|
||||||
"abv" => "info",
|
"remove" => "uninstall",
|
||||||
"dr" => "doctor",
|
"abv" => "info",
|
||||||
"--repo" => "--repository",
|
"dr" => "doctor",
|
||||||
"environment" => "--env",
|
"--repo" => "--repository",
|
||||||
"--config" => "config",
|
"environment" => "--env",
|
||||||
"-v" => "--version",
|
"--config" => "config",
|
||||||
"lc" => "livecheck",
|
"-v" => "--version",
|
||||||
"tc" => "typecheck",
|
"lc" => "livecheck",
|
||||||
|
"tc" => "typecheck",
|
||||||
}.freeze
|
}.freeze
|
||||||
# This pattern is used to split descriptions at full stops. We only consider a
|
# This pattern is used to split descriptions at full stops. We only consider a
|
||||||
# dot as a full stop if it is either followed by a whitespace or at the end of
|
# dot as a full stop if it is either followed by a whitespace or at the end of
|
||||||
|
@ -1095,6 +1095,36 @@ on_request: installed_on_request?, options: options)
|
|||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(Pathname) }
|
||||||
|
def post_install_formula_path
|
||||||
|
# Use the formula from the keg when any of the following is true:
|
||||||
|
# * We're installing from the JSON API
|
||||||
|
# * We're installing a local bottle file
|
||||||
|
# * The formula doesn't exist in the tap (or the tap isn't installed)
|
||||||
|
# * The formula in the tap has a different `pkg_version``.
|
||||||
|
#
|
||||||
|
# In all other cases, including if the formula from the keg is unreadable
|
||||||
|
# (third-party taps may `require` some of their own libraries) or if there
|
||||||
|
# is no formula present in the keg (as is the case with very old bottles),
|
||||||
|
# use the formula from the tap.
|
||||||
|
keg_formula_path = formula.opt_prefix/".brew/#{formula.name}.rb"
|
||||||
|
return keg_formula_path if formula.loaded_from_api?
|
||||||
|
return keg_formula_path if formula.local_bottle_path.present?
|
||||||
|
|
||||||
|
tap_formula_path = formula.specified_path
|
||||||
|
return keg_formula_path unless tap_formula_path.exist?
|
||||||
|
|
||||||
|
begin
|
||||||
|
keg_formula = Formulary.factory(keg_formula_path)
|
||||||
|
tap_formula = Formulary.factory(tap_formula_path)
|
||||||
|
return keg_formula_path if keg_formula.pkg_version != tap_formula.pkg_version
|
||||||
|
|
||||||
|
tap_formula_path
|
||||||
|
rescue FormulaUnavailableError, FormulaUnreadableError
|
||||||
|
tap_formula_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def post_install
|
def post_install
|
||||||
args = [
|
args = [
|
||||||
@ -1105,34 +1135,7 @@ on_request: installed_on_request?, options: options)
|
|||||||
HOMEBREW_LIBRARY_PATH/"postinstall.rb"
|
HOMEBREW_LIBRARY_PATH/"postinstall.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Use the formula from the keg if:
|
args << post_install_formula_path
|
||||||
# * Installing from a local bottle, or
|
|
||||||
# * The formula doesn't exist in the tap (or the tap isn't installed), or
|
|
||||||
# * The formula in the tap has a different pkg_version.
|
|
||||||
#
|
|
||||||
# In all other cases, including if the formula from the keg is unreadable
|
|
||||||
# (third-party taps may `require` some of their own libraries) or if there
|
|
||||||
# is no formula present in the keg (as is the case with old bottles), use
|
|
||||||
# the formula from the tap.
|
|
||||||
formula_path = begin
|
|
||||||
keg_formula_path = formula.opt_prefix/".brew/#{formula.name}.rb"
|
|
||||||
tap_formula_path = formula.specified_path
|
|
||||||
keg_formula = Formulary.factory(keg_formula_path)
|
|
||||||
tap_formula = Formulary.factory(tap_formula_path) if tap_formula_path.exist?
|
|
||||||
other_version_installed = (keg_formula.pkg_version != tap_formula&.pkg_version)
|
|
||||||
|
|
||||||
if formula.local_bottle_path.present? ||
|
|
||||||
!tap_formula_path.exist? ||
|
|
||||||
other_version_installed
|
|
||||||
keg_formula_path
|
|
||||||
else
|
|
||||||
tap_formula_path
|
|
||||||
end
|
|
||||||
rescue FormulaUnavailableError, FormulaUnreadableError
|
|
||||||
tap_formula_path
|
|
||||||
end
|
|
||||||
|
|
||||||
args << formula_path
|
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available?
|
if Sandbox.available?
|
||||||
|
@ -1651,6 +1651,23 @@ _brew_pin() {
|
|||||||
__brew_complete_installed_formulae
|
__brew_complete_installed_formulae
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_brew_post_install() {
|
||||||
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
case "${cur}" in
|
||||||
|
-*)
|
||||||
|
__brewcomp "
|
||||||
|
--debug
|
||||||
|
--help
|
||||||
|
--quiet
|
||||||
|
--verbose
|
||||||
|
"
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
__brew_complete_installed_formulae
|
||||||
|
}
|
||||||
|
|
||||||
_brew_postgresql_upgrade_database() {
|
_brew_postgresql_upgrade_database() {
|
||||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
case "${cur}" in
|
case "${cur}" in
|
||||||
@ -2713,6 +2730,7 @@ _brew() {
|
|||||||
options) _brew_options ;;
|
options) _brew_options ;;
|
||||||
outdated) _brew_outdated ;;
|
outdated) _brew_outdated ;;
|
||||||
pin) _brew_pin ;;
|
pin) _brew_pin ;;
|
||||||
|
post_install) _brew_post_install ;;
|
||||||
postgresql-upgrade-database) _brew_postgresql_upgrade_database ;;
|
postgresql-upgrade-database) _brew_postgresql_upgrade_database ;;
|
||||||
postinstall) _brew_postinstall ;;
|
postinstall) _brew_postinstall ;;
|
||||||
pr-automerge) _brew_pr_automerge ;;
|
pr-automerge) _brew_pr_automerge ;;
|
||||||
|
@ -1134,6 +1134,14 @@ __fish_brew_complete_arg 'pin' -l verbose -d 'Make some output more verbose'
|
|||||||
__fish_brew_complete_arg 'pin' -a '(__fish_brew_suggest_formulae_installed)'
|
__fish_brew_complete_arg 'pin' -a '(__fish_brew_suggest_formulae_installed)'
|
||||||
|
|
||||||
|
|
||||||
|
__fish_brew_complete_cmd 'post_install' 'Rerun the post-install steps for formula'
|
||||||
|
__fish_brew_complete_arg 'post_install' -l debug -d 'Display any debugging information'
|
||||||
|
__fish_brew_complete_arg 'post_install' -l help -d 'Show this message'
|
||||||
|
__fish_brew_complete_arg 'post_install' -l quiet -d 'Make some output more quiet'
|
||||||
|
__fish_brew_complete_arg 'post_install' -l verbose -d 'Make some output more verbose'
|
||||||
|
__fish_brew_complete_arg 'post_install' -a '(__fish_brew_suggest_formulae_installed)'
|
||||||
|
|
||||||
|
|
||||||
__fish_brew_complete_cmd 'postgresql-upgrade-database' 'Upgrades the database for the `postgresql` formula'
|
__fish_brew_complete_cmd 'postgresql-upgrade-database' 'Upgrades the database for the `postgresql` formula'
|
||||||
__fish_brew_complete_arg 'postgresql-upgrade-database' -l debug -d 'Display any debugging information'
|
__fish_brew_complete_arg 'postgresql-upgrade-database' -l debug -d 'Display any debugging information'
|
||||||
__fish_brew_complete_arg 'postgresql-upgrade-database' -l help -d 'Show this message'
|
__fish_brew_complete_arg 'postgresql-upgrade-database' -l help -d 'Show this message'
|
||||||
|
@ -68,6 +68,7 @@ nodenv-sync
|
|||||||
options
|
options
|
||||||
outdated
|
outdated
|
||||||
pin
|
pin
|
||||||
|
post_install
|
||||||
postgresql-upgrade-database
|
postgresql-upgrade-database
|
||||||
postinstall
|
postinstall
|
||||||
pr-automerge
|
pr-automerge
|
||||||
|
@ -22,6 +22,7 @@ __brew_list_aliases() {
|
|||||||
ln link
|
ln link
|
||||||
instal install
|
instal install
|
||||||
uninstal uninstall
|
uninstal uninstall
|
||||||
|
post_install postinstall
|
||||||
rm uninstall
|
rm uninstall
|
||||||
remove uninstall
|
remove uninstall
|
||||||
abv info
|
abv info
|
||||||
@ -1404,6 +1405,17 @@ _brew_pin() {
|
|||||||
'*::installed_formula:__brew_installed_formulae'
|
'*::installed_formula:__brew_installed_formulae'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# brew post_install
|
||||||
|
_brew_post_install() {
|
||||||
|
_arguments \
|
||||||
|
'--debug[Display any debugging information]' \
|
||||||
|
'--help[Show this message]' \
|
||||||
|
'--quiet[Make some output more quiet]' \
|
||||||
|
'--verbose[Make some output more verbose]' \
|
||||||
|
- installed_formula \
|
||||||
|
'*::installed_formula:__brew_installed_formulae'
|
||||||
|
}
|
||||||
|
|
||||||
# brew postgresql-upgrade-database
|
# brew postgresql-upgrade-database
|
||||||
_brew_postgresql_upgrade_database() {
|
_brew_postgresql_upgrade_database() {
|
||||||
_arguments \
|
_arguments \
|
||||||
|
@ -533,7 +533,7 @@ issuing the `brew upgrade` *`formula`* command. See also `unpin`.
|
|||||||
|
|
||||||
Upgrades the database for the `postgresql` formula.
|
Upgrades the database for the `postgresql` formula.
|
||||||
|
|
||||||
### `postinstall` *`installed_formula`* [...]
|
### `postinstall`, `post_install` *`installed_formula`* [...]
|
||||||
|
|
||||||
Rerun the post-install steps for *`formula`*.
|
Rerun the post-install steps for *`formula`*.
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ Pin the specified \fIformula\fR, preventing them from being upgraded when issuin
|
|||||||
.SS "\fBpostgresql\-upgrade\-database\fR"
|
.SS "\fBpostgresql\-upgrade\-database\fR"
|
||||||
Upgrades the database for the \fBpostgresql\fR formula\.
|
Upgrades the database for the \fBpostgresql\fR formula\.
|
||||||
.
|
.
|
||||||
.SS "\fBpostinstall\fR \fIinstalled_formula\fR [\.\.\.]"
|
.SS "\fBpostinstall\fR, \fBpost_install\fR \fIinstalled_formula\fR [\.\.\.]"
|
||||||
Rerun the post\-install steps for \fIformula\fR\.
|
Rerun the post\-install steps for \fIformula\fR\.
|
||||||
.
|
.
|
||||||
.SS "\fBpyenv\-sync\fR"
|
.SS "\fBpyenv\-sync\fR"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user