Class: Homebrew::DevCmd::Unpack Private

Inherits:
AbstractCommand show all
Includes:
FileUtils
Defined in:
dev-cmd/unpack.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/unpack.rbi

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.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, #raise_sh_command_error!

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::Unpack::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.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/unpack.rbi', line 10

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.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'dev-cmd/unpack.rb', line 35

def run
  formulae = args.named.to_formulae

  if (dir = args.destdir)
    unpack_dir = Pathname.new(dir).expand_path
    unpack_dir.mkpath
  else
    unpack_dir = Pathname.pwd
  end

  odie "Cannot write to #{unpack_dir}" unless unpack_dir.writable?

  formulae.each do |f|
    stage_dir = unpack_dir/"#{f.name}-#{f.version}"

    if stage_dir.exist?
      odie "Destination #{stage_dir} already exists!" unless args.force?

      rm_rf stage_dir
    end

    oh1 "Unpacking #{Formatter.identifier(f.full_name)} to: #{stage_dir}"

    # show messages about tar
    with_env VERBOSE: "1" do
      f.brew do
        f.patch if args.patch?
        cp_r getwd, stage_dir, preserve: true
      end
    end

    next unless args.git?

    ohai "Setting up Git repository"
    cd(stage_dir) do
      system "git", "init", "-q"
      system "git", "add", "-A"
      system "git", "commit", "-q", "-m", "brew-unpack"
    end
  end
end