librarian-puppet 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/librarian/puppet.rb +19 -5
- data/lib/librarian/puppet/dsl.rb +32 -10
- data/lib/librarian/puppet/extension.rb +7 -0
- data/lib/librarian/puppet/source/git.rb +0 -72
- data/lib/librarian/puppet/source/local.rb +66 -3
- data/lib/librarian/puppet/util.rb +3 -0
- data/lib/librarian/puppet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTJiNjNkOTc5NTIwMzIyMjc4ZTk4ZjYxNDU1OTk1YWU0Zjk2YmZmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2U0MmZhMWMyZTUyYzJjMDNmOGFlOTUxZTI5OGI1NjQzOGYwNzk1MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2VhNTk1MzliMzU5YzliNmQ4YWJjY2Y2YTc4ZDUyMjBhZjU3ZWE2ODY4MDVl
|
10
|
+
YmRmZDBiNjNmNzdkNDQ2ODk4MmZmMWIwMDVkNWE5YWIyOTAxZjE0YTU2ODY5
|
11
|
+
YWQ5YWNlOGQ1MGY2OTUzZjliODEyMDI4ZjAxOTRkMjJlOTc4Zjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjAyNmJkM2Q3ODczMzBiYWFhODQzZmY2NDdjM2E4NDViZjgwMTcwZGZhMmEx
|
14
|
+
MDJhYjcxOTYyODc5YmUwYjliYjIyNGZjMzViYzljZGY0Y2ZjOTljOWZjNDAw
|
15
|
+
YWJjMDEwOWUwY2JkODQ3ODAwMzJjZDBlNTIyZDFkMzNhOGJmMjE=
|
data/lib/librarian/puppet.rb
CHANGED
@@ -5,14 +5,27 @@ require 'open3_backport' if RUBY_VERSION < '1.9'
|
|
5
5
|
|
6
6
|
status = nil
|
7
7
|
out = nil
|
8
|
+
err = nil
|
8
9
|
error = nil
|
9
10
|
|
10
11
|
begin
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
if RUBY_VERSION < '1.9'
|
13
|
+
# Ruby 1.8.x backport of popen3 doesn't allow the 'env' hash argument
|
14
|
+
# Not sanitizing the environment for the moment.
|
15
|
+
Open3.popen3('puppet --version') {|stdin, stdout, stderr, wait_thr|
|
16
|
+
pid = wait_thr.pid # pid of the started process.
|
17
|
+
out = stdout.read
|
18
|
+
err = stderr.read
|
19
|
+
status = wait_thr.value # Process::Status object returned.
|
20
|
+
}
|
21
|
+
else
|
22
|
+
Open3.popen3({"GEM_PATH"=> nil},'puppet --version') {|stdin, stdout, stderr, wait_thr|
|
23
|
+
pid = wait_thr.pid # pid of the started process.
|
24
|
+
out = stdout.read
|
25
|
+
err = stderr.read
|
26
|
+
status = wait_thr.value # Process::Status object returned.
|
27
|
+
}
|
28
|
+
end
|
16
29
|
rescue => e
|
17
30
|
error = e
|
18
31
|
end
|
@@ -22,6 +35,7 @@ if status.nil? or status.exitstatus != 0
|
|
22
35
|
Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc).
|
23
36
|
#{out.nil? or out.empty? ? "puppet --version returned #{status.exitstatus}" : out}
|
24
37
|
#{error.message unless error.nil?}
|
38
|
+
#{err unless err.nil?}
|
25
39
|
EOF
|
26
40
|
exit 1
|
27
41
|
end
|
data/lib/librarian/puppet/dsl.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'librarian/dsl'
|
2
|
+
require 'librarian/dsl/target'
|
2
3
|
require 'librarian/puppet/source'
|
3
4
|
|
4
5
|
module Librarian
|
@@ -11,17 +12,38 @@ module Librarian
|
|
11
12
|
source :git => Source::Git
|
12
13
|
source :path => Source::Path
|
13
14
|
source :github_tarball => Source::GitHubTarball
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
# copied from Librarian::Dsl to use our own Receiver
|
17
|
+
def run(specfile = nil, sources = [])
|
18
|
+
specfile, sources = nil, specfile if specfile.kind_of?(Array) && sources.empty?
|
19
|
+
|
20
|
+
Target.new(self).tap do |target|
|
21
|
+
target.precache_sources(sources)
|
22
|
+
debug_named_source_cache("Pre-Cached Sources", target)
|
23
|
+
|
24
|
+
specfile ||= Proc.new if block_given?
|
25
|
+
receiver = Receiver.new(target)
|
26
|
+
receiver.run(specfile)
|
27
|
+
|
28
|
+
debug_named_source_cache("Post-Cached Sources", target)
|
29
|
+
end.to_spec
|
30
|
+
end
|
31
|
+
|
32
|
+
class Receiver < Librarian::Dsl::Receiver
|
33
|
+
attr_reader :specfile
|
34
|
+
|
35
|
+
# save the specfile and call librarian
|
36
|
+
def run(specfile = nil)
|
37
|
+
@specfile = specfile
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
# implement the 'modulefile' syntax for Puppetfile
|
42
|
+
def modulefile
|
43
|
+
File.read(Pathname.new(specfile).parent.join('Modulefile')).lines.each do |line|
|
44
|
+
regexp = /\s*dependency\s+('|")([^'"]+)\1\s*(?:,\s*('|")([^'"]+)\3)?/
|
45
|
+
regexp =~ line && mod($2, $4)
|
46
|
+
end
|
25
47
|
end
|
26
48
|
end
|
27
49
|
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
require 'librarian/source/git'
|
2
2
|
require 'librarian/puppet/source/local'
|
3
|
-
begin
|
4
|
-
require 'puppet'
|
5
|
-
rescue LoadError
|
6
|
-
$stderr.puts <<-EOF
|
7
|
-
Unable to load puppet, the puppet gem is required for :git source.
|
8
|
-
Install it with: gem install puppet
|
9
|
-
EOF
|
10
|
-
exit 1
|
11
|
-
end
|
12
|
-
|
13
3
|
|
14
4
|
module Librarian
|
15
5
|
module Source
|
@@ -71,68 +61,6 @@ module Librarian
|
|
71
61
|
end
|
72
62
|
end
|
73
63
|
|
74
|
-
def fetch_version(name, extra)
|
75
|
-
cache!
|
76
|
-
found_path = found_path(name)
|
77
|
-
module_version
|
78
|
-
end
|
79
|
-
|
80
|
-
def fetch_dependencies(name, version, extra)
|
81
|
-
dependencies = Set.new
|
82
|
-
|
83
|
-
if modulefile?
|
84
|
-
metadata = ::Puppet::ModuleTool::Metadata.new
|
85
|
-
|
86
|
-
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
87
|
-
|
88
|
-
metadata.dependencies.each do |dependency|
|
89
|
-
dependency_name = dependency.instance_variable_get(:@full_module_name)
|
90
|
-
version = dependency.instance_variable_get(:@version_requirement)
|
91
|
-
gem_requirement = Requirement.new(version).gem_requirement
|
92
|
-
dependencies << Dependency.new(dependency_name, gem_requirement, forge_source)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
if specfile?
|
97
|
-
spec = environment.dsl(Pathname(specfile))
|
98
|
-
dependencies.merge spec.dependencies
|
99
|
-
end
|
100
|
-
|
101
|
-
dependencies
|
102
|
-
end
|
103
|
-
|
104
|
-
def forge_source
|
105
|
-
Forge.from_lock_options(environment, :remote=>"http://forge.puppetlabs.com")
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
# Naming this method 'version' causes an exception to be raised.
|
111
|
-
def module_version
|
112
|
-
return '0.0.1' unless modulefile?
|
113
|
-
|
114
|
-
metadata = ::Puppet::ModuleTool::Metadata.new
|
115
|
-
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
116
|
-
|
117
|
-
metadata.version
|
118
|
-
end
|
119
|
-
|
120
|
-
def modulefile
|
121
|
-
File.join(filesystem_path, 'Modulefile')
|
122
|
-
end
|
123
|
-
|
124
|
-
def modulefile?
|
125
|
-
File.exists?(modulefile)
|
126
|
-
end
|
127
|
-
|
128
|
-
def specfile
|
129
|
-
File.join(filesystem_path, environment.specfile_name)
|
130
|
-
end
|
131
|
-
|
132
|
-
def specfile?
|
133
|
-
File.exists?(specfile)
|
134
|
-
end
|
135
|
-
|
136
64
|
end
|
137
65
|
end
|
138
66
|
end
|
@@ -1,3 +1,13 @@
|
|
1
|
+
begin
|
2
|
+
require 'puppet'
|
3
|
+
rescue LoadError
|
4
|
+
$stderr.puts <<-EOF
|
5
|
+
Unable to load puppet, the puppet gem is required for :git and :path source.
|
6
|
+
Install it with: gem install puppet
|
7
|
+
EOF
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
|
1
11
|
module Librarian
|
2
12
|
module Puppet
|
3
13
|
module Source
|
@@ -31,14 +41,67 @@ module Librarian
|
|
31
41
|
def fetch_version(name, extra)
|
32
42
|
cache!
|
33
43
|
found_path = found_path(name)
|
34
|
-
|
44
|
+
module_version
|
35
45
|
end
|
36
46
|
|
37
47
|
def fetch_dependencies(name, version, extra)
|
38
|
-
|
48
|
+
dependencies = Set.new
|
49
|
+
|
50
|
+
if modulefile?
|
51
|
+
evaluate_modulefile(modulefile).dependencies.each do |dependency|
|
52
|
+
dependency_name = dependency.instance_variable_get(:@full_module_name)
|
53
|
+
version = dependency.instance_variable_get(:@version_requirement)
|
54
|
+
gem_requirement = Requirement.new(version).gem_requirement
|
55
|
+
dependencies << Dependency.new(dependency_name, gem_requirement, forge_source)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if specfile?
|
60
|
+
spec = environment.dsl(Pathname(specfile))
|
61
|
+
dependencies.merge spec.dependencies
|
62
|
+
end
|
63
|
+
|
64
|
+
dependencies
|
65
|
+
end
|
66
|
+
|
67
|
+
def forge_source
|
68
|
+
Forge.from_lock_options(environment, :remote=>"http://forge.puppetlabs.com")
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
# Naming this method 'version' causes an exception to be raised.
|
74
|
+
def module_version
|
75
|
+
return '0.0.1' unless modulefile?
|
76
|
+
evaluate_modulefile(modulefile).version
|
77
|
+
end
|
78
|
+
|
79
|
+
def evaluate_modulefile(modulefile)
|
80
|
+
metadata = ::Puppet::ModuleTool::Metadata.new
|
81
|
+
begin
|
82
|
+
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
83
|
+
rescue ArgumentError, SyntaxError => error
|
84
|
+
warn { "Unable to parse #{modulefile}, ignoring: #{error}" }
|
85
|
+
metadata.version = '0.0.1'
|
86
|
+
end
|
87
|
+
metadata
|
88
|
+
end
|
89
|
+
|
90
|
+
def modulefile
|
91
|
+
File.join(filesystem_path, 'Modulefile')
|
39
92
|
end
|
40
93
|
|
41
|
-
|
94
|
+
def modulefile?
|
95
|
+
File.exists?(modulefile)
|
96
|
+
end
|
97
|
+
|
98
|
+
def specfile
|
99
|
+
File.join(filesystem_path, environment.specfile_name)
|
100
|
+
end
|
101
|
+
|
102
|
+
def specfile?
|
103
|
+
File.exists?(specfile)
|
104
|
+
end
|
42
105
|
|
43
106
|
def install_perform_step_copy!(found_path, install_path)
|
44
107
|
debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" }
|
@@ -9,6 +9,9 @@ module Librarian
|
|
9
9
|
def info(*args, &block)
|
10
10
|
environment.logger.info(*args, &block)
|
11
11
|
end
|
12
|
+
def warn(*args, &block)
|
13
|
+
environment.logger.warn(*args, &block)
|
14
|
+
end
|
12
15
|
|
13
16
|
# workaround Issue #173 FileUtils.cp_r will fail if there is a symlink that points to a missing file
|
14
17
|
# or when the symlink is copied before the target file when preserve is true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarian-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: librarian
|