1 require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
3 Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo) do
4 desc "Supports CVS repositories/workspaces"
6 optional_commands :cvs => 'cvs'
7 has_features :gzip_compression, :reference_tracking, :modules
10 if !@resource.value(:source)
11 create_repository(@resource.value(:path))
19 if @resource.value(:source)
20 directory = File.join(@resource.value(:path), 'CVS')
22 directory = File.join(@resource.value(:path), 'CVSROOT')
24 File.directory?(directory)
27 def working_copy_exists?
28 File.directory?(File.join(@resource.value(:path), 'CVS'))
32 FileUtils.rm_rf(@resource.value(:path))
36 debug "Checking for updates because 'ensure => latest'"
38 # We cannot use -P to prune empty dirs, otherwise
39 # CVS would report those as "missing", regardless
40 # if they have contents or updates.
41 is_current = (cvs('-nq', 'update', '-d').strip == "")
42 if (!is_current) then debug "There are updates available on the checkout's current branch/tag." end
48 # CVS does not have a conecpt like commit-IDs or change
49 # sets, so we can only have the current branch name (or the
50 # requested one, if that differs) as the "latest" revision.
51 should = @resource.value(:revision)
52 current = self.revision
53 return should != current ? should : current
58 if File.exist?(tag_file)
59 contents = File.read(tag_file).strip
60 # Note: Doesn't differentiate between N and T entries
61 @rev = contents[1..-1]
65 debug "Checkout is on branch/tag '#{@rev}'"
70 def revision=(desired)
72 cvs('update', '-dr', desired, '.')
81 File.join(@resource.value(:path), 'CVS', 'Tag')
84 def checkout_repository
85 dirname, basename = File.split(@resource.value(:path))
87 args = ['-d', @resource.value(:source)]
88 if @resource.value(:compression)
89 args.push('-z', @resource.value(:compression))
92 if @resource.value(:revision)
93 args.push('-r', @resource.value(:revision))
95 args.push('-d', basename, module_name)
101 # * Starts with ':' (eg, :pserver:...)
103 if (m = @resource.value(:module))
105 elsif (source = @resource.value(:source))
106 source[0, 1] == ':' ? File.basename(source) : '.'
110 def create_repository(path)
111 cvs('-d', path, 'init')
115 if @resource.value(:owner) or @resource.value(:group)