Class: Homebrew::Cmd::FetchCmd Private

Inherits:
AbstractCommand show all
Includes:
Fetch
Defined in:
sorbet/rbi/dsl/homebrew/cmd/fetch_cmd.rbi,
cmd/fetch.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::Cmd::FetchCmd. Please instead update this file by running bin/tapioca dsl Homebrew::Cmd::FetchCmd.

Defined Under Namespace

Classes: Args

Constant Summary collapse

FETCH_MAX_TRIES =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

5

Instance Method Summary collapse

Methods included from Fetch

#fetch_bottle?

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::Cmd::FetchCmd::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



9
# File 'sorbet/rbi/dsl/homebrew/cmd/fetch_cmd.rbi', line 9

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'cmd/fetch.rb', line 71

def run
  Formulary.enable_factory_cache!

  bucket = if args.deps?
    args.named.to_formulae_and_casks.flat_map do |formula_or_cask|
      case formula_or_cask
      when Formula
        formula = formula_or_cask
        [formula, *formula.recursive_dependencies.map(&:to_formula)]
      else
        formula_or_cask
      end
    end
  else
    args.named.to_formulae_and_casks
  end.uniq

  os_arch_combinations = args.os_arch_combinations

  puts "Fetching: #{bucket * ", "}" if bucket.size > 1
  bucket.each do |formula_or_cask|
    case formula_or_cask
    when Formula
      formula = T.cast(formula_or_cask, Formula)
      ref = formula.loaded_from_api? ? formula.full_name : formula.path

      os_arch_combinations.each do |os, arch|
        SimulateSystem.with(os:, arch:) do
          formula = Formulary.factory(ref, args.HEAD? ? :head : :stable)

          formula.print_tap_action verb: "Fetching"

          fetched_bottle = false
          if fetch_bottle?(
            formula,
            force_bottle:               args.force_bottle?,
            bottle_tag:                 args.bottle_tag&.to_sym,
            build_from_source_formulae: args.build_from_source_formulae,
            os:                         args.os&.to_sym,
            arch:                       args.arch&.to_sym,
          )
            begin
              formula.clear_cache if args.force?

              bottle_tag = if (bottle_tag = args.bottle_tag&.to_sym)
                Utils::Bottles::Tag.from_symbol(bottle_tag)
              else
                Utils::Bottles::Tag.new(system: os, arch:)
              end

              bottle = formula.bottle_for_tag(bottle_tag)

              if bottle.nil?
                opoo "Bottle for tag #{bottle_tag.to_sym.inspect} is unavailable."
                next
              end

              begin
                bottle.fetch_tab
              rescue DownloadError
                retry if retry_fetch?(bottle)
                raise
              end
              fetch_formula(bottle)
            rescue Interrupt
              raise
            rescue => e
              raise if Homebrew::EnvConfig.developer?

              fetched_bottle = false
              onoe e.message
              opoo "Bottle fetch failed, fetching the source instead."
            else
              fetched_bottle = true
            end
          end

          next if fetched_bottle

          fetch_formula(formula)

          formula.resources.each do |r|
            fetch_resource(r)
            r.patches.each { |p| fetch_patch(p) if p.external? }
          end

          formula.patchlist.each { |p| fetch_patch(p) if p.external? }
        end
      end
    else
      cask = formula_or_cask
      ref = cask.loaded_from_api? ? cask.full_name : cask.sourcefile_path

      os_arch_combinations.each do |os, arch|
        next if os == :linux

        SimulateSystem.with(os:, arch:) do
          cask = Cask::CaskLoader.load(ref)

          if cask.url.nil? || cask.sha256.nil?
            opoo "Cask #{cask} is not supported on os #{os} and arch #{arch}"
            next
          end

          quarantine = args.quarantine?
          quarantine = true if quarantine.nil?

          download = Cask::Download.new(cask, quarantine:)
          fetch_cask(download)
        end
      end
    end
  end
end