Class: Autoproj::PackageManagers::YumManager
- Inherits:
-
ShellScriptManager
- Object
- Manager
- ShellScriptManager
- Autoproj::PackageManagers::YumManager
- Defined in:
- lib/autoproj/package_managers/yum_manager.rb
Overview
Package manager interface for systems that use yum
Instance Attribute Summary
Attributes inherited from ShellScriptManager
#auto_install_cmd, #needs_locking, #needs_root, #user_install_cmd
Attributes inherited from Manager
Instance Method Summary collapse
- #filter_uptodate_packages(packages) ⇒ Object
-
#initialize(ws) ⇒ YumManager
constructor
A new instance of YumManager.
- #install(packages, filter_uptodate_packages: false, install_only: false) ⇒ Object
Methods inherited from ShellScriptManager
execute, #generate_auto_os_script, #generate_script, #generate_user_os_script, #needs_locking?, #needs_root?, #osdeps_interaction
Methods inherited from Manager
#call_while_empty?, #configure_manager, #enabled?, #initialize_environment, #os_dependencies, #silent?, #strict?
Constructor Details
#initialize(ws) ⇒ YumManager
Returns a new instance of YumManager.
5 6 7 8 9 |
# File 'lib/autoproj/package_managers/yum_manager.rb', line 5 def initialize(ws) super(ws, true, %w[yum install], %w[yum install -y]) end |
Instance Method Details
#filter_uptodate_packages(packages) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/autoproj/package_managers/yum_manager.rb', line 11 def filter_uptodate_packages(packages) result = `LANG=C rpm -q --queryformat "%{NAME}\n" '#{packages.join("' '")}'` installed_packages = [] new_packages = [] result.split("\n").each_with_index do |line, index| line = line.strip if line =~ /package (.*) is not installed/ package_name = $1 unless packages.include?(package_name) # something is wrong, fallback to installing everything return packages end new_packages << package_name else package_name = line.strip unless packages.include?(package_name) # something is wrong, fallback to installing everything return packages end installed_packages << package_name end end new_packages end |
#install(packages, filter_uptodate_packages: false, install_only: false) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/autoproj/package_managers/yum_manager.rb', line 37 def install(packages, filter_uptodate_packages: false, install_only: false) packages = filter_uptodate_packages(packages) if filter_uptodate_packages patterns, packages = packages.partition { |pkg| pkg =~ /^@/ } patterns = patterns.map { |str| str[1..-1] } result = false unless patterns.empty? result |= super(patterns, auto_install_cmd: %w[yum groupinstall -y], user_install_cmd: %w[yum groupinstall]) end result |= super(packages) unless packages.empty? if result # Invalidate caching of installed packages, as we just # installed new packages ! @installed_packages = nil end end |