diff options
author | Bruce Williams <bruce@codefluency.com> | 2010-03-14 01:03:21 -0800 |
---|---|---|
committer | Bruce Williams <bruce@codefluency.com> | 2010-03-14 01:03:21 -0800 |
commit | 3ba51924b6a118dc5cedc37c607283bbdb9cbe54 (patch) | |
tree | 2abd4ca34c5b42d5bc329e00c69c9197aa8e32bb /lib/puppet | |
parent | c714947908b69c538ea9d050d4375e2b3f19e7ac (diff) |
Basic Bazaar support
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/provider/vcsrepo/bzr.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/puppet/provider/vcsrepo/bzr.rb b/lib/puppet/provider/vcsrepo/bzr.rb new file mode 100644 index 0000000..a6e12cd --- /dev/null +++ b/lib/puppet/provider/vcsrepo/bzr.rb @@ -0,0 +1,63 @@ +require File.join(File.dirname(__FILE__), '..', 'vcsrepo') + +Puppet::Type.type(:vcsrepo).provide(:bzr, :parent => Puppet::Provider::Vcsrepo) do + desc "Supports Bazaar repositories" + + commands :bzr => 'bzr' + defaultfor :bzr => :exists + + def create + if !@resource.value(:source) + create_repository(@resource.value(:path)) + else + clone_repository(@resource.value(:revision)) + end + end + + def exists? + File.directory?(File.join(@resource.value(:path), '.bzr')) + end + + def destroy + FileUtils.rm_rf(@resource.value(:path)) + end + + def revision + at_path do + current_revid = bzr('version-info')[/^revision-id:\s+(\S+)/, 1] + desired = @resource.value(:revision) + begin + desired_revid = bzr('revision-info', desired).strip.split(/\s+/).last + rescue Puppet::ExecutionFailure + # Possible revid available during update (but definitely not current) + desired_revid = nil + end + if current_revid == desired_revid + desired + else + current_revid + end + end + end + + def revision=(desired) + bzr('update', '-r', desired, @resource.value(:path)) + end + + private + + def create_repository(path) + bzr('init', path) + end + + def clone_repository(revision) + args = ['branch'] + if revision + args.push('-r', revision) + end + args.push(@resource.value(:source), + @resource.value(:path)) + bzr(*args) + end + +end |