From 9aa17796f99f7f6966b1a0753b606f4e7b508c8a Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Sat, 12 Nov 2011 13:31:01 +0100 Subject: [PATCH 1/2] Fix (#10787) - Various fixes/tweaks for the CVS provider --- lib/puppet/provider/vcsrepo/cvs.rb | 51 +++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index e82c23a..d8d8abe 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -28,19 +28,45 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) FileUtils.rm_rf(@resource.value(:path)) end - def revision - if File.exist?(tag_file) - contents = File.read(tag_file) - # Note: Doesn't differentiate between N and T entries - contents[1..-1] - else - 'MAIN' + def latest? + debug "Checking for updates because 'ensure => latest'" + at_path do + # We cannot use -P to prune empty dirs, otherwise + # CVS would report those as "missing", regardless + # if they have contents or updates. + is_current = (cvs('-nq', 'update', '-d').strip == "") + if (!is_current) then debug "There are updates available on the checkout's current branch/tag." end + return is_current end end + + def latest + # CVS does not have a conecpt like commit-IDs or change + # sets, so we can only have the current branch name (or the + # requested one, if that differs) as the "latest" revision. + should = @resource.value(:revision) + current = self.revision + return should != current ? should : current + end + + def revision + if !@rev + if File.exist?(tag_file) + contents = File.read(tag_file).strip + # Note: Doesn't differentiate between N and T entries + @rev = contents[1..-1] + else + @rev = 'HEAD' + end + debug "Checkout is on branch/tag '#{@rev}'" + end + return @rev + end def revision=(desired) at_path do - cvs('update', '-r', desired, '.') + cvs('update', '-dr', desired, '.') + @rev = desired end end @@ -57,12 +83,13 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) if @resource.value(:compression) args.push('-z', @resource.value(:compression)) end - args.push('checkout', '-d', basename, module_name) + args.push('checkout') + if @resource.value(:revision) + args.push('-r', @resource.value(:revision)) + end + args.push('-d', basename, module_name) cvs(*args) end - if @resource.value(:revision) - self.revision = @resource.value(:revision) - end end # When the source: From 924e13367b19e82fab94a13231b4febb1d3f09ac Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Sat, 12 Nov 2011 14:08:13 +0100 Subject: [PATCH 2/2] Fix owner/group as well (#10787) --- lib/puppet/provider/vcsrepo/cvs.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb index d8d8abe..c42136e 100644 --- a/lib/puppet/provider/vcsrepo/cvs.rb +++ b/lib/puppet/provider/vcsrepo/cvs.rb @@ -13,6 +13,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) else checkout_repository end + update_owner end def exists? @@ -66,6 +67,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) def revision=(desired) at_path do cvs('update', '-dr', desired, '.') + update_owner @rev = desired end end @@ -104,4 +106,10 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) cvs('-d', path, 'init') end + def update_owner + if @resource.value(:owner) or @resource.value(:group) + set_ownership + end + end + end