1 require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
3 Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) do
4 desc "Supports Subversion repositories"
6 commands :svn => 'svn',
7 :svnadmin => 'svnadmin',
10 has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration
13 if !@resource.value(:source)
14 create_repository(@resource.value(:path))
16 checkout_repository(@resource.value(:source),
17 @resource.value(:path),
18 @resource.value(:revision))
23 def working_copy_exists?
24 if File.directory?(@resource.value(:path))
25 # :path is an svn checkout
26 return true if File.directory?(File.join(@resource.value(:path), '.svn'))
27 if File.file?(File.join(@resource.value(:path), 'format'))
28 # :path is an svn server
29 return true if svnlook('uuid', @resource.value(:path))
40 FileUtils.rm_rf(@resource.value(:path))
45 (self.revision >= self.latest) and (@resource.value(:source) == self.sourceurl)
50 args = ['--non-interactive']
51 if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password)
52 args.push('--username', @resource.value(:basic_auth_username))
53 args.push('--password', @resource.value(:basic_auth_password))
54 args.push('--no-auth-cache')
57 if @resource.value(:force)
61 if @resource.value(:configuration)
62 args.push('--config-dir', @resource.value(:configuration))
69 args = buildargs.push('info', '-r', 'HEAD')
71 svn(*args)[/^Revision:\s+(\d+)/m, 1]
76 args = buildargs.push('info')
78 svn(*args)[/^URL:\s+(\S+)/m, 1]
83 args = buildargs.push('info')
85 svn(*args)[/^Revision:\s+(\d+)/m, 1]
89 def revision=(desired)
90 args = if @resource.value(:source)
91 buildargs.push('switch', '-r', desired, @resource.value(:source))
93 buildargs.push('update', '-r', desired)
103 def checkout_repository(source, path, revision)
104 args = buildargs.push('checkout')
106 args.push('-r', revision)
108 args.push(source, path)
112 def create_repository(path)
114 if @resource.value(:fstype)
115 args.push('--fs-type', @resource.value(:fstype))
122 if @resource.value(:owner) or @resource.value(:group)