Class: NativePackageInstaller::Platform::MSYS2

Inherits:
Object
  • Object
show all
Defined in:
lib/native-package-installer/platform/msys2.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_platform?Boolean

Returns:

  • (Boolean)

22
23
24
25
# File 'lib/native-package-installer/platform/msys2.rb', line 22

def current_platform?
  return false if package_prefix.nil?
  not pacman_path.nil?
end

.package_prefixObject


42
43
44
45
46
47
48
49
50
51
# File 'lib/native-package-installer/platform/msys2.rb', line 42

def package_prefix
  case RUBY_PLATFORM
  when "x86-mingw32"
    "mingw-w64-i686-"
  when "x64-mingw32"
    "mingw-w64-x86_64-"
  else
    nil
  end
end

.pacman_pathObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/native-package-installer/platform/msys2.rb', line 27

def pacman_path
  finder = ExecutableFinder.new("pacman")
  case RUBY_PLATFORM
  when "x86-mingw32"
    Dir.glob("c:/msys{64,32,*}/usr/bin") do |bin|
      finder.append_path(bin)
    end
  when "x64-mingw32"
    Dir.glob("c:/msys{64,*}/usr/bin") do |bin|
      finder.append_path(bin)
    end
  end
  finder.find
end

Instance Method Details

#install_commandObject


61
62
63
64
65
# File 'lib/native-package-installer/platform/msys2.rb', line 61

def install_command
  pacman_dir, pacman = File.split(self.class.pacman_path)
  ENV["PATH"] = [pacman_dir, ENV["PATH"]].join(File::PATH_SEPARATOR)
  "#{pacman} -S --noconfirm"
end

#need_super_user_priviledge?Boolean

Returns:

  • (Boolean)

67
68
69
# File 'lib/native-package-installer/platform/msys2.rb', line 67

def need_super_user_priviledge?
  false
end

#package(spec) ⇒ Object


54
55
56
57
58
59
# File 'lib/native-package-installer/platform/msys2.rb', line 54

def package(spec)
  base_name = spec[:msys2]
  return nil if base_name.nil?

  "#{self.class.package_prefix}#{base_name}"
end