summaryrefslogtreecommitdiff
path: root/lib/puppet/provider
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r--lib/puppet/provider/vcsrepo/cvs.rb87
-rw-r--r--lib/puppet/provider/vcsrepo/svn.rb6
2 files changed, 87 insertions, 6 deletions
diff --git a/lib/puppet/provider/vcsrepo/cvs.rb b/lib/puppet/provider/vcsrepo/cvs.rb
new file mode 100644
index 0000000..68d22c1
--- /dev/null
+++ b/lib/puppet/provider/vcsrepo/cvs.rb
@@ -0,0 +1,87 @@
+Puppet::Type.type(:vcsrepo).provide(:cvs) do
+ desc "Supports CVS repositories/workspaces"
+
+ commands :cvs => 'cvs'
+ defaultfor :cvs => :exists
+
+ def create
+ if !@resource.value(:source)
+ create_repository(@resource.value(:path))
+ else
+ checkout_repository
+ end
+ end
+
+ def exists?
+ if @resource.value(:source)
+ directory = File.join(@resource.value(:path), 'CVS')
+ else
+ directory = File.join(@resource.value(:path), 'CVSROOT')
+ end
+ File.directory?(directory)
+ end
+
+ def destroy
+ 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'
+ end
+ end
+
+ def revision=(desired)
+ at_path do
+ cvs('update', '-r', desired, '.')
+ end
+ end
+
+ private
+
+ def tag_file
+ File.join(@resource.value(:path), 'CVS', 'Tag')
+ end
+
+ def checkout_repository
+ dirname, basename = File.split(@resource.value(:path))
+ Dir.chdir(dirname) do
+ args = ['-d', @resource.value(:source)]
+ if @resource.value(:compression)
+ args.push('-z', @resource.value(:compression))
+ end
+ args.push('checkout', '-d', basename, module_name)
+ cvs(*args)
+ end
+ if @resource.value(:revision)
+ self.revision = @resource.value(:revision)
+ end
+ end
+
+ # When the source:
+ # * Starts with ':' (eg, :pserver:...)
+ def module_name
+ if (source = @resource.value(:source))
+ source[0, 1] == ':' ? File.basename(source) : '.'
+ end
+ end
+
+ def create_repository(path)
+ cvs('-d', path, 'init')
+ end
+
+ # Note: We don't rely on Dir.chdir's behavior of automatically returning the
+ # value of the last statement -- for easier stubbing.
+ def at_path(&block) #:nodoc:
+ value = nil
+ Dir.chdir(@resource.value(:path)) do
+ value = yield
+ end
+ value
+ end
+
+end
diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb
index 226cc63..c85ffa4 100644
--- a/lib/puppet/provider/vcsrepo/svn.rb
+++ b/lib/puppet/provider/vcsrepo/svn.rb
@@ -56,12 +56,6 @@ Puppet::Type.type(:vcsrepo).provide(:svn) do
svnadmin(*args)
end
- def reset(desired)
- at_path do
- git('reset', '--hard', desired)
- end
- end
-
# Note: We don't rely on Dir.chdir's behavior of automatically returning the
# value of the last statement -- for easier stubbing.
def at_path(&block) #:nodoc: