Class: Autoproj::PackageManagers::ZypperManager

Inherits:
ShellScriptManager show all
Defined in:
lib/autoproj/package_managers/zypper_manager.rb

Overview

Package manger for OpenSuse and Suse (untested)

Instance Attribute Summary

Attributes inherited from ShellScriptManager

#auto_install_cmd, #needs_locking, #needs_root, #user_install_cmd

Attributes inherited from Manager

#enabled, #silent, #ws

Instance Method Summary collapse

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) ⇒ ZypperManager

Returns a new instance of ZypperManager.



5
6
7
8
9
# File 'lib/autoproj/package_managers/zypper_manager.rb', line 5

def initialize(ws)
    super(ws, true,
            %w[zypper install],
            %w[zypper -n install])
end

Instance Method Details

#filter_uptodate_packages(packages) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/autoproj/package_managers/zypper_manager.rb', line 11

def filter_uptodate_packages(packages)
    `LANG=C rpm -q --whatprovides '#{packages.join("' '")}'`
    has_all_pkgs = $?.success?

    if has_all_pkgs
        []
    else
        packages # let zypper filter, we need root now anyways
    end
end

#install(packages, filter_uptodate_packages: false, install_only: false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/autoproj/package_managers/zypper_manager.rb', line 22

def install(packages, filter_uptodate_packages: false, install_only: false)
    if filter_uptodate_packages || install_only
        packages = filter_uptodate_packages(packages)
    end

    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[zypper --non-interactive install --type pattern],
                        user_install_cmd: %w[zypper install --type pattern])
    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