Class: RubyInstaller::Build::Components::Msys2

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_installer/build/components/01_msys2.rb

Constant Summary

Constants included from RubyInstaller::Build::Colors

RubyInstaller::Build::Colors::ColorMap, RubyInstaller::Build::Colors::ESC, RubyInstaller::Build::Colors::NND

Instance Attribute Summary

Attributes inherited from Base

#builtin_packages_dir, #msys, #pacman_args, #task_index

Instance Method Summary collapse

Methods inherited from Base

#autorebase, #check_hash, depends, #download, #initialize, #kill_all_msys2_processes, #puts, #run_verbose, #shell_escape, #shell_join

Methods included from RubyInstaller::Build::Colors

colored, disable_colors, enable_colors, initialize

Constructor Details

This class inherits a constructor from RubyInstaller::Build::Components::Base

Instance Method Details

#descriptionObject



5
6
7
# File 'lib/ruby_installer/build/components/01_msys2.rb', line 5

def description
  "MSYS2 base installation"
end

#execute(args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby_installer/build/components/01_msys2.rb', line 30

def execute(args)
  hash = ENV['MSYS2_VERSION'] ? nil : msys2_download_hash
  downloaded_path = download(msys2_download_uri, hash)

  puts "Run the MSYS2 installer ..."
  if run_verbose(downloaded_path) && msys.with_msys_apps_enabled { run_verbose("sh", "-lc", "true") }
    puts green(" Success")
  else
    puts red(" Failed")
    raise "MSYS2 installer failed.\n\nYou might download MSYS2 from the official site: https://www.msys2.org/ and run the installer manually.\nThen you can use 'ridk install' to install necessary tools and to keep MSYS2 up-to-date."
  end
end

#needed?(try_kill: true) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby_installer/build/components/01_msys2.rb', line 9

def needed?(try_kill: true)
  begin
    autorebase

    if msys.with_msys_apps_enabled(if_no_msys: :raise) { run_verbose("sh", "-lc", "true") }
      puts "MSYS2 seems to be " + green("properly installed")
      false
    else
      if try_kill
        # Already running MSYS2 processes might interference with our MSYS2 through shared memory.
        kill_all_msys2_processes
        return needed?(try_kill: false)
      end
      true
    end
  rescue Msys2Installation::MsysNotFound
    puts "MSYS2 seems to be " + red("unavailable")
    true
  end
end