Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag --overwrite to brew install to govern the keg-linking step #12691

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Lint/NestedMethodDefinition:
Metrics/AbcSize:
Max: 280
Metrics/BlockLength:
Max: 103
Max: 106
Exclude:
# TODO: extract more of the bottling logic
- "dev-cmd/bottle.rb"
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ def install_args
[:switch, "-g", "--git", {
description: "Create a Git repository, useful for creating patches to the software.",
}],
[:switch, "--overwrite", {
description: "Delete files that already exist in the prefix while linking.",
}],
].each do |*args, **options|
send(*args, **options)
conflicts "--cask", args.last
Expand Down Expand Up @@ -226,6 +229,7 @@ def install
interactive: args.interactive?,
keep_tmp: args.keep_tmp?,
force: args.force?,
overwrite: args.overwrite?,
debug: args.debug?,
quiet: args.quiet?,
verbose: args.verbose?,
Expand Down
8 changes: 5 additions & 3 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FormulaInstaller

attr_predicate :installed_as_dependency?, :installed_on_request?
attr_predicate :show_summary_heading?, :show_header?
attr_predicate :force_bottle?, :ignore_deps?, :only_deps?, :interactive?, :git?, :force?, :keep_tmp?
attr_predicate :force_bottle?, :ignore_deps?, :only_deps?, :interactive?, :git?, :force?, :overwrite?, :keep_tmp?
attr_predicate :verbose?, :debug?, :quiet?

# TODO: Remove when removed from `test-bot`.
Expand All @@ -64,13 +64,15 @@ def initialize(
cc: nil,
options: Options.new,
force: false,
overwrite: false,
debug: false,
quiet: false,
verbose: false
)
@formula = formula
@env = env
@force = force
@overwrite = overwrite
@keep_tmp = keep_tmp
@link_keg = !formula.keg_only? || link_keg
@show_header = show_header
Expand Down Expand Up @@ -951,7 +953,7 @@ def link(keg)

unless link_keg
begin
keg.optlink(verbose: verbose?)
keg.optlink(verbose: verbose?, overwrite: overwrite?)
rescue Keg::LinkError => e
ofail "Failed to create #{formula.opt_prefix}"
puts "Things that depend on #{formula.full_name} will probably not build."
Expand Down Expand Up @@ -982,7 +984,7 @@ def link(keg)
backup_dir = HOMEBREW_CACHE/"Backup"

begin
keg.link(verbose: verbose?)
keg.link(verbose: verbose?, overwrite: overwrite?)
rescue Keg::ConflictError => e
conflict_file = e.dst
if formula.link_overwrite?(conflict_file) && !link_overwrite_backup.key?(conflict_file)
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def install_formulae(
interactive: false,
keep_tmp: false,
force: false,
overwrite: false,
debug: false,
quiet: false,
verbose: false
Expand All @@ -291,6 +292,7 @@ def install_formulae(
interactive: interactive,
keep_tmp: keep_tmp,
force: force,
overwrite: overwrite,
debug: debug,
quiet: quiet,
verbose: verbose,
Expand Down