~ubuntu-branches/ubuntu/quantal/puppet/quantal

« back to all changes in this revision

Viewing changes to lib/puppet/provider/package/zypper.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-14 01:56:30 UTC
  • mfrom: (1.1.29) (3.1.43 sid)
  • Revision ID: package-import@ubuntu.com-20120714015630-ntj41rkvkq4zph4y
Tags: 2.7.18-1ubuntu1
* Resynchronise with Debian. (LP: #1023931) Remaining changes:
  - debian/puppetmaster-passenger.postinst: Make sure we error if puppet
    config print doesn't work
  - debian/puppetmaster-passenger.postinst: Ensure upgrades from
    <= 2.7.11-1 fixup passenger apache configuration.
* Dropped upstreamed patches:
  - debian/patches/CVE-2012-1906_CVE-2012-1986_to_CVE-2012-1989.patch
  - debian/patches/puppet-12844
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch
* Drop Build-Depends on ruby-rspec (in universe):
  - debian/control: remove ruby-rspec from Build-Depends
  - debian/patches/no-rspec.patch: make Rakefile work anyway if rspec
    isn't installed so we can use it in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
  has_feature :versionable
5
5
 
6
6
  commands :zypper => "/usr/bin/zypper"
7
 
  commands :rpm    => "rpm"
8
7
 
9
8
  confine    :operatingsystem => [:suse, :sles, :sled, :opensuse]
10
9
 
 
10
  #on zypper versions <1.0, the version option returns 1
 
11
  #some versions of zypper output on stderr
 
12
  def zypper_version
 
13
    cmd = [self.class.command(:zypper),"--version"]
 
14
    execute(cmd, { :failonfail => false, :combine => true})
 
15
  end
 
16
 
11
17
  # Install a package using 'zypper'.
12
18
  def install
13
19
    should = @resource.should(:ensure)
22
28
      # Add the package version
23
29
      wanted = "#{wanted}-#{should}"
24
30
    end
25
 
    output = zypper "--quiet", :install, "-l", "-y", wanted
 
31
 
 
32
    #This has been tested with following zypper versions
 
33
    #SLE 10.2: 0.6.104
 
34
    #SLE 11.0: 1.0.8
 
35
    #OpenSuse 10.2: 0.6.13
 
36
    #OpenSuse 11.2: 1.2.8
 
37
    #Assume that this will work on newer zypper versions
 
38
 
 
39
    #extract version numbers and convert to integers
 
40
    major, minor, patch = zypper_version.scan(/\d+/).map{ |x| x.to_i }
 
41
    self.debug "Detected zypper version #{major}.#{minor}.#{patch}"
 
42
 
 
43
    #zypper version < 1.0 does not support --quiet flag
 
44
    quiet = "--quiet"
 
45
    if major < 1
 
46
      quiet = "--terse"
 
47
    end
 
48
 
 
49
    license = "--auto-agree-with-licenses"
 
50
    noconfirm = "--no-confirm"
 
51
 
 
52
    #zypper 0.6.13 (OpenSuSE 10.2) does not support auto agree with licenses
 
53
    if major < 1 and minor <= 6 and patch <= 13
 
54
      zypper quiet, :install, noconfirm, wanted
 
55
    else
 
56
      zypper quiet, :install, license, noconfirm, wanted
 
57
    end
26
58
 
27
59
    unless self.query
28
60
      raise Puppet::ExecutionFailure.new(
36
68
    #zypper can only get a list of *all* available packages?
37
69
    output = zypper "list-updates"
38
70
 
39
 
    if output =~ /#{Regexp.escape @resource[:name]}\s*\|\s*([^\s\|]+)/
 
71
    if output =~ /#{Regexp.escape @resource[:name]}\s*\|.*?\|\s*([^\s\|]+)/
40
72
      return $1
41
73
    else
42
74
      # zypper didn't find updates, pretend the current