resolving discussions
This commit is contained in:
		
							parent
							
								
									dffa42839c
								
							
						
					
					
						commit
						7e876e4681
					
				@ -310,7 +310,7 @@ module Homebrew
 | 
			
		||||
        Install.perform_preinstall_checks_once
 | 
			
		||||
        Install.check_cc_argv(args.cc)
 | 
			
		||||
 | 
			
		||||
        formulae_installer = Install.get_formulae_dependencies(
 | 
			
		||||
        formulae_installer = Install.formulae_installer(
 | 
			
		||||
          installed_formulae,
 | 
			
		||||
          installed_on_request:       !args.as_dependency?,
 | 
			
		||||
          installed_as_dependency:    args.as_dependency?,
 | 
			
		||||
@ -337,7 +337,7 @@ module Homebrew
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        if args.ask?
 | 
			
		||||
          dependants = Upgrade.get_dependants(
 | 
			
		||||
          dependants = Upgrade.dependants(
 | 
			
		||||
            installed_formulae,
 | 
			
		||||
            flags:                      args.flags_only,
 | 
			
		||||
            ask:                        args.ask?,
 | 
			
		||||
@ -354,7 +354,7 @@ module Homebrew
 | 
			
		||||
            dry_run:                    args.dry_run?,
 | 
			
		||||
          )
 | 
			
		||||
 | 
			
		||||
          formulae_dependencies = Install.get_hierarchy(formulae_installer, dependants)
 | 
			
		||||
          formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
 | 
			
		||||
          # Main block: if asking the user is enabled, show dependency and size information.
 | 
			
		||||
          Install.ask_formulae(formulae_dependencies, args: args)
 | 
			
		||||
        end
 | 
			
		||||
@ -364,7 +364,7 @@ module Homebrew
 | 
			
		||||
                                 verbose: args.verbose?)
 | 
			
		||||
 | 
			
		||||
        unless args.ask?
 | 
			
		||||
          dependants = Upgrade.get_dependants(
 | 
			
		||||
          dependants = Upgrade.dependants(
 | 
			
		||||
            installed_formulae,
 | 
			
		||||
            flags:                      args.flags_only,
 | 
			
		||||
            dry_run:                    args.dry_run?,
 | 
			
		||||
@ -381,7 +381,7 @@ module Homebrew
 | 
			
		||||
          )
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if dependants
 | 
			
		||||
        if dependants.present?
 | 
			
		||||
          Upgrade.upgrade_dependents(
 | 
			
		||||
            dependants, installed_formulae,
 | 
			
		||||
            flags:                      args.flags_only,
 | 
			
		||||
 | 
			
		||||
@ -130,13 +130,13 @@ module Homebrew
 | 
			
		||||
        unless formulae.empty?
 | 
			
		||||
          Install.perform_preinstall_checks_once
 | 
			
		||||
 | 
			
		||||
          formulae_keg = formulae.map do |formula|
 | 
			
		||||
          formulae_kegs = formulae.map do |formula|
 | 
			
		||||
            if formula.pinned?
 | 
			
		||||
              onoe "#{formula.full_name} is pinned. You must unpin it to reinstall."
 | 
			
		||||
              next
 | 
			
		||||
            end
 | 
			
		||||
            Migrator.migrate_if_needed(formula, force: args.force?)
 | 
			
		||||
            Homebrew::Reinstall.get_formula_to_reinstall(
 | 
			
		||||
            Homebrew::Reinstall.formula_installer(
 | 
			
		||||
              formula,
 | 
			
		||||
              flags:                      args.flags_only,
 | 
			
		||||
              force_bottle:               args.force_bottle?,
 | 
			
		||||
@ -153,7 +153,7 @@ module Homebrew
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          if args.ask?
 | 
			
		||||
            dependants = Upgrade.get_dependants(
 | 
			
		||||
            dependants = Upgrade.dependants(
 | 
			
		||||
              formulae,
 | 
			
		||||
              flags:                      args.flags_only,
 | 
			
		||||
              ask:                        args.ask?,
 | 
			
		||||
@ -168,15 +168,15 @@ module Homebrew
 | 
			
		||||
              verbose:                    args.verbose?,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            formulae_dependencies = formulae_keg.map(&:formula_installer)
 | 
			
		||||
            formulae_installer = formulae_kegs.map(&:formula_installer)
 | 
			
		||||
 | 
			
		||||
            formulae_dependencies = Install.get_hierarchy(formulae_dependencies, dependants)
 | 
			
		||||
            formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
 | 
			
		||||
            # Main block: if asking the user is enabled, show dependency and size information.
 | 
			
		||||
            Install.ask_formulae(formulae_dependencies, args: args)
 | 
			
		||||
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          formulae_keg.each do |f|
 | 
			
		||||
          formulae_kegs.each do |f|
 | 
			
		||||
            Homebrew::Reinstall.reinstall_formula(
 | 
			
		||||
              f,
 | 
			
		||||
              flags:                      args.flags_only,
 | 
			
		||||
@ -195,7 +195,7 @@ module Homebrew
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          unless args.ask?
 | 
			
		||||
            dependants = Upgrade.get_dependants(
 | 
			
		||||
            dependants = Upgrade.dependants(
 | 
			
		||||
              formulae,
 | 
			
		||||
              flags:                      args.flags_only,
 | 
			
		||||
              force_bottle:               args.force_bottle?,
 | 
			
		||||
@ -210,7 +210,7 @@ module Homebrew
 | 
			
		||||
            )
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          if dependants
 | 
			
		||||
          if dependants.present?
 | 
			
		||||
            Upgrade.upgrade_dependents(
 | 
			
		||||
              dependants, formulae,
 | 
			
		||||
              flags:                      args.flags_only,
 | 
			
		||||
 | 
			
		||||
@ -220,7 +220,7 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
        Install.perform_preinstall_checks_once
 | 
			
		||||
 | 
			
		||||
        formulae_installer = Upgrade.get_formulae_dependencies(
 | 
			
		||||
        formulae_installer = Upgrade.formulae_installer(
 | 
			
		||||
          formulae_to_install,
 | 
			
		||||
          flags:                      args.flags_only,
 | 
			
		||||
          dry_run:                    args.dry_run?,
 | 
			
		||||
@ -237,7 +237,7 @@ module Homebrew
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        if args.ask?
 | 
			
		||||
          dependants = Upgrade.get_dependants(
 | 
			
		||||
          dependants = Upgrade.dependants(
 | 
			
		||||
            formulae_to_install,
 | 
			
		||||
            flags:                      args.flags_only,
 | 
			
		||||
            dry_run:                    args.dry_run?,
 | 
			
		||||
@ -253,7 +253,7 @@ module Homebrew
 | 
			
		||||
            verbose:                    args.verbose?,
 | 
			
		||||
          )
 | 
			
		||||
 | 
			
		||||
          formulae_dependencies = Install.get_hierarchy(formulae_installer, dependants)
 | 
			
		||||
          formulae_dependencies = Install.collect_dependencies(formulae_installer, dependants)
 | 
			
		||||
          # Main block: if asking the user is enabled, show dependency and size information.
 | 
			
		||||
          Install.ask_formulae(formulae_dependencies, args: args)
 | 
			
		||||
 | 
			
		||||
@ -264,7 +264,7 @@ module Homebrew
 | 
			
		||||
                                 verbose: args.verbose?)
 | 
			
		||||
 | 
			
		||||
        unless args.ask?
 | 
			
		||||
          dependants = Upgrade.get_dependants(
 | 
			
		||||
          dependants = Upgrade.dependants(
 | 
			
		||||
            formulae_to_install,
 | 
			
		||||
            flags:                      args.flags_only,
 | 
			
		||||
            dry_run:                    args.dry_run?,
 | 
			
		||||
@ -280,7 +280,7 @@ module Homebrew
 | 
			
		||||
          )
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        if dependants
 | 
			
		||||
        if dependants.present?
 | 
			
		||||
          Upgrade.upgrade_dependents(
 | 
			
		||||
            dependants, formulae_to_install,
 | 
			
		||||
            flags:                      args.flags_only,
 | 
			
		||||
 | 
			
		||||
@ -232,7 +232,7 @@ module Homebrew
 | 
			
		||||
        false
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def get_formulae_dependencies(
 | 
			
		||||
      def formulae_installer(
 | 
			
		||||
        formulae_to_install,
 | 
			
		||||
        installed_on_request: true,
 | 
			
		||||
        installed_as_dependency: false,
 | 
			
		||||
@ -354,7 +354,7 @@ module Homebrew
 | 
			
		||||
        puts formula_names.join(" ")
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def get_hierarchy(formulae_installer, dependants)
 | 
			
		||||
      def collect_dependencies(formulae_installer, dependants)
 | 
			
		||||
        formulae_dependencies = formulae_installer.flat_map do |f|
 | 
			
		||||
          [f.formula, f.compute_dependencies.flatten.filter do |c|
 | 
			
		||||
            c.is_a? Dependency
 | 
			
		||||
@ -446,55 +446,6 @@ module Homebrew
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # Build a unique list of formulae to size by including:
 | 
			
		||||
      # 1. The original formulae to install.
 | 
			
		||||
      # 2. Their outdated dependents (subject to pruning criteria).
 | 
			
		||||
      # 3. Optionally, any installed formula that depends on one of these and is outdated.
 | 
			
		||||
      def compute_sized_formulae(formulae, args:)
 | 
			
		||||
        sized_formulae = formulae.flat_map do |formula|
 | 
			
		||||
          # Always include the formula itself.
 | 
			
		||||
          formula_list = [formula]
 | 
			
		||||
 | 
			
		||||
          deps = args.build_from_source? ? formula.deps.build : formula.deps.required
 | 
			
		||||
 | 
			
		||||
          outdated_dependents = deps.map(&:to_formula).reject(&:pinned?).select do |dep|
 | 
			
		||||
            dep.installed_kegs.empty? || (dep.bottled? && dep.outdated?)
 | 
			
		||||
          end
 | 
			
		||||
          deps.map(&:to_formula).each do |f|
 | 
			
		||||
            prune_build = f.recursive_dependencies do |_, dep|
 | 
			
		||||
              :prune if dep.build?
 | 
			
		||||
            end
 | 
			
		||||
            # select the outdated one or not installed
 | 
			
		||||
            outdated_dependents.concat(prune_build.map(&:to_formula).reject(&:pinned?).select do |dep|
 | 
			
		||||
              dep.installed_kegs.empty? || (dep.bottled? && dep.outdated?)
 | 
			
		||||
            end)
 | 
			
		||||
          end
 | 
			
		||||
          formula_list.concat(outdated_dependents)
 | 
			
		||||
 | 
			
		||||
          formula_list
 | 
			
		||||
        end
 | 
			
		||||
        # Add any installed formula that depends on one of the sized formulae and is outdated.
 | 
			
		||||
        unless Homebrew::EnvConfig.no_installed_dependents_check?
 | 
			
		||||
          loop do
 | 
			
		||||
            new_parents = Formula.installed.select do |installed_formula|
 | 
			
		||||
              next unless installed_formula.bottled?
 | 
			
		||||
              next unless installed_formula.outdated?
 | 
			
		||||
 | 
			
		||||
              required_deps = installed_formula.deps.required.map(&:to_formula)
 | 
			
		||||
              required_deps.intersect?(sized_formulae)
 | 
			
		||||
            end
 | 
			
		||||
 | 
			
		||||
            # Exclude anything already in sized_formulae
 | 
			
		||||
            new_parents -= sized_formulae
 | 
			
		||||
            break if new_parents.empty?
 | 
			
		||||
 | 
			
		||||
            sized_formulae.concat(new_parents)
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        sized_formulae.uniq(&:to_s).compact
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # Compute the total sizes (download, installed, and net) for the given formulae.
 | 
			
		||||
      def compute_total_sizes(sized_formulae, debug: false)
 | 
			
		||||
        total_download_size  = 0
 | 
			
		||||
 | 
			
		||||
@ -7,8 +7,8 @@ require "messages"
 | 
			
		||||
 | 
			
		||||
module Homebrew
 | 
			
		||||
  module Reinstall
 | 
			
		||||
    Formula_keg = Struct.new(:formula_installer, :keg, :formula, :options)
 | 
			
		||||
    def self.get_formula_to_reinstall(
 | 
			
		||||
    FormulaKeg = Struct.new(:formula_installer, :keg, :formula, :options)
 | 
			
		||||
    def self.formula_installer(
 | 
			
		||||
      formula,
 | 
			
		||||
      flags:,
 | 
			
		||||
      force_bottle: false,
 | 
			
		||||
@ -62,7 +62,7 @@ module Homebrew
 | 
			
		||||
          verbose:,
 | 
			
		||||
        }.compact,
 | 
			
		||||
      )
 | 
			
		||||
      Formula_keg.new(fi, keg, formula, options)
 | 
			
		||||
      FormulaKeg.new(fi, keg, formula, options)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def self.reinstall_formula(
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ module Homebrew
 | 
			
		||||
  module Upgrade
 | 
			
		||||
    Dependents = Struct.new(:upgradeable, :pinned, :skipped)
 | 
			
		||||
 | 
			
		||||
    def self.get_formulae_dependencies(
 | 
			
		||||
    def self.formulae_installer(
 | 
			
		||||
      formulae_to_install,
 | 
			
		||||
      flags:,
 | 
			
		||||
      dry_run: false,
 | 
			
		||||
@ -95,7 +95,7 @@ module Homebrew
 | 
			
		||||
        rescue CannotInstallFormulaError => e
 | 
			
		||||
          ofail e
 | 
			
		||||
        rescue UnsatisfiedRequirements, DownloadError => e
 | 
			
		||||
          ofail "#{formula}: #{e}"
 | 
			
		||||
          ofail "#{fi.formula.full_name}: #{e}"
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        upgrade_formula(fi, dry_run:, verbose:)
 | 
			
		||||
@ -260,7 +260,7 @@ module Homebrew
 | 
			
		||||
      @puts_no_installed_dependents_check_disable_message_if_not_already = true
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def self.get_dependants(
 | 
			
		||||
    def self.dependants(
 | 
			
		||||
      formulae,
 | 
			
		||||
      flags:,
 | 
			
		||||
      dry_run: false,
 | 
			
		||||
@ -285,8 +285,11 @@ module Homebrew
 | 
			
		||||
        end
 | 
			
		||||
        return
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      installed_formulae = ((dry_run || ask) ? formulae : FormulaInstaller.installed.to_a).dup
 | 
			
		||||
      if dry_run || ask
 | 
			
		||||
        installed_formulae = formulae.dup
 | 
			
		||||
      else
 | 
			
		||||
        installed_formulae = FormulaInstaller.installed.to_a.dup
 | 
			
		||||
      end
 | 
			
		||||
      installed_formulae.reject! { |f| f.core_formula? && f.versioned_formula? }
 | 
			
		||||
      return if installed_formulae.empty?
 | 
			
		||||
 | 
			
		||||
@ -369,7 +372,7 @@ module Homebrew
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      unless dry_run
 | 
			
		||||
        formulae_dependencies = get_formulae_dependencies(
 | 
			
		||||
        formulae_dependencies = formulae_installer(
 | 
			
		||||
          upgradeable,
 | 
			
		||||
          flags:,
 | 
			
		||||
          force_bottle:,
 | 
			
		||||
@ -439,7 +442,7 @@ module Homebrew
 | 
			
		||||
      return if dry_run
 | 
			
		||||
 | 
			
		||||
      reinstallable_broken_dependents.each do |formula|
 | 
			
		||||
        formula_installer = Reinstall.get_formula_to_reinstall(
 | 
			
		||||
        formula_installer = Reinstall.formula_installer(
 | 
			
		||||
          formula,
 | 
			
		||||
          flags:,
 | 
			
		||||
          force_bottle:,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user