Class: Homebrew::InstallSteps::Runner Private
- Includes:
- SystemCommand::Mixin, Utils::Output::Mixin
- Defined in:
- install_steps.rb,
install_steps/formula_actions.rb
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.
Constant Summary collapse
- PRIVILEGED_STEP_REQUEST =
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.
"homebrew_cask_privileged_step"- PRIVILEGED_STEP_SUCCEEDED =
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.
"homebrew_cask_privileged_step_succeeded"- CONTENT_PATH_TOKENS =
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.
Path tokens reuse the step base resolution; formula metadata tokens are resolved separately. Anything else is left verbatim so literal braces in templates are never rewritten.
%w[ prefix opt_prefix bin sbin lib libexec share pkgshare var etc pkgetc staged_path appdir caskroom_path temp rack bash_completion zsh_completion fish_completion pwsh_completion ].freeze
- IMPLICIT_SUDO_STEP_TYPES =
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.
%w[delete_keychain_certificate set_ownership].freeze
Instance Method Summary collapse
- #initialize(context:, command: SystemCommand) ⇒ void constructor private
- #make_cpython_venv_activation_scripts_writable(lib_cellar) ⇒ void private
-
#run(steps, phase: :install, privileged_step_handler: nil, reset_guard_results: true) ⇒ void
private
privileged_step_handlerdelegates steps that may needsudoto the caller (the parent process broker for sandboxed cask steps), andreset_guard_results: falselets that broker run steps one at a time while keeping guard snapshots from earlier steps in the same plan. - #sandbox_write_paths(steps, phase: :install) ⇒ Array<Pathname> private
- #sudo_required?(steps) ⇒ Boolean private
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Constructor Details
#initialize(context:, command: SystemCommand) ⇒ void
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.
887 888 889 890 891 |
# File 'install_steps.rb', line 887 def initialize(context:, command: SystemCommand) @context = context @command = command @guard_results = T.let({}, T::Hash[PathSpec, T::Boolean]) end |
Instance Method Details
#make_cpython_venv_activation_scripts_writable(lib_cellar) ⇒ void
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.
273 274 275 |
# File 'install_steps/formula_actions.rb', line 273 def make_cpython_venv_activation_scripts_writable(lib_cellar) FileUtils.chmod "u+w", lib_cellar.glob("venv/scripts/**/*").select(&:file?) end |
#run(steps, phase: :install, privileged_step_handler: nil, reset_guard_results: true) ⇒ void
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.
privileged_step_handler delegates steps that may need sudo to the
caller (the parent process broker for sandboxed cask steps), and
reset_guard_results: false lets that broker run steps one at a time
while keeping guard snapshots from earlier steps in the same plan.
905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
# File 'install_steps.rb', line 905 def run(steps, phase: :install, privileged_step_handler: nil, reset_guard_results: true) @guard_results.clear if reset_guard_results DSL.normalise_steps(steps).each_with_index do |step, index| next if phase != :uninstall && !step_guards_match?(step) if privileged_step_handler && sudo_required?([step]) privileged_step_handler.call(index) elsif phase == :uninstall run_uninstall_step(step) else run_install_step(step) end end end |
#sandbox_write_paths(steps, phase: :install) ⇒ Array<Pathname>
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.
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
# File 'install_steps.rb', line 921 def sandbox_write_paths(steps, phase: :install) DSL.normalise_steps(steps).flat_map do |step| if phase == :uninstall next [] if step["type"] != "symlink" || step["uninstall"] != true next [resolve_path(step_path(step, "target")).parent] end case step.fetch("type") when "mkdir", "mkdir_p", "touch", "write" [resolve_path(step_path(step, "path")).parent] when "move" [resolve_path(step_path(step, "source")).parent, resolve_path(step_path(step, "target")).parent] when "move_children", "move_contents" [resolve_path(step_path(step, "source")), resolve_path(step_path(step, "target"))] when "copy", "symlink" [resolve_path(step_path(step, "target")).parent] when "remove" step_paths(step, "paths").flat_map { |path| (path) }.map(&:parent) when "inreplace", "change_dylib_id" key = (step["type"] == "inreplace") ? "path" : "source" [resolve_path(step_path(step, key))] when "link_dir", "link_children" [resolve_path(step_path(step, "target"))] when "run" paths = step.key?("stdout_path") ? [resolve_path(step_path(step, "stdout_path")).parent] : [] if step.key?("writable_paths") paths.concat(step_paths(step, "writable_paths").map do |path| resolve_path(path) end) end paths when "set_permissions", "set_ownership" existing_step_paths(step) else [] end end.uniq end |
#sudo_required?(steps) ⇒ Boolean
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.
962 963 964 965 966 967 |
# File 'install_steps.rb', line 962 def sudo_required?(steps) DSL.normalise_steps(steps).any? do |step| step["sudo"] == true || step["sudo"] == "if_needed" || IMPLICIT_SUDO_STEP_TYPES.include?(step["type"]) end end |