From e3fc5c4960de988b81e470d9e1f6a66c1bfd15e2 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 19 Dec 2011 22:56:43 +0000 Subject: [PATCH] (#11414) Test Augeas versions correctly with versioncmp The release of Augeas 0.10.0 broke simplistic version comparisons with the >= operator, so now use versioncmp. (Cherry pick of 735acad5 but without the accompanying test, which doesn't exist in 2.6.x). --- lib/puppet/provider/augeas/augeas.rb | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 7dbd062..70406f6 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -19,9 +19,11 @@ require 'augeas' if Puppet.features.augeas? require 'strscan' +require 'puppet/util/package' Puppet::Type.type(:augeas).provide(:augeas) do include Puppet::Util + include Puppet::Util::Package confine :true => Puppet.features.augeas? @@ -143,7 +145,7 @@ def open_augeas debug("Opening augeas with root #{root}, lens path #{load_path}, flags #{flags}") @aug = Augeas::open(root, load_path,flags) - debug("Augeas version #{get_augeas_version} is installed") if get_augeas_version >= "0.3.6" + debug("Augeas version #{get_augeas_version} is installed") if versioncmp(get_augeas_version, "0.3.6") >= 0 if resource[:incl] aug.set("/augeas/load/Xfm/lens", resource[:lens]) @@ -279,7 +281,7 @@ def need_to_run? # If we have a verison of augeas which is at least 0.3.6 then we # can make the changes now, see if changes were made, and # actually do the save. - if return_value and get_augeas_version >= "0.3.6" + if return_value and versioncmp(get_augeas_version, "0.3.6") >= 0 debug("Will attempt to save and only run if files changed") set_augeas_save_mode(SAVE_NOOP) do_execute_changes @@ -303,7 +305,7 @@ def execute_changes # Re-connect to augeas, and re-execute the changes begin open_augeas - set_augeas_save_mode(SAVE_OVERWRITE) if get_augeas_version >= "0.3.6" + set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0 do_execute_changes -- 1.7.5.4