Class: Plat4m::Sniffer::Linux::Dnf

Inherits:
NixManager show all
Defined in:
lib/plat4m/sniff/linux.rb

Instance Method Summary collapse

Methods inherited from NixManager

#initialize, #make_install_command, #make_uninstall_command

Methods inherited from PkgManager

#has_sudo?, #initialize, #install, #is_root?, #make_install_command, #make_uninstall_command, #select_available, #select_uninstalled, #uninstall

Constructor Details

This class inherits a constructor from Plat4m::Sniffer::Linux::NixManager

Instance Method Details

#available?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


189
190
191
# File 'lib/plat4m/sniff/linux.rb', line 189

def available?(pkg)
  !!(`dnf repoquery --info #{pkg} 2>/dev/null`.strip =~ /Name\s*:\s*#{pkg}/)
end

#installed?(pkg) ⇒ Boolean

Returns:

  • (Boolean)


179
180
181
182
183
184
185
186
187
# File 'lib/plat4m/sniff/linux.rb', line 179

def installed?(pkg)
  if @distro[:release] >= '41'
    # dnf v5
    system("dnf list --installed #{pkg} >/dev/null 2>&1")
  else
    # dnf <= v4
    system("dnf list installed #{pkg} >/dev/null 2>&1")
  end
end