librarian-puppet-maestrodev 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/LICENSE +20 -0
- data/README.md +187 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +13 -0
- data/lib/librarian/puppet/cli.rb +85 -0
- data/lib/librarian/puppet/dsl.rb +16 -0
- data/lib/librarian/puppet/environment.rb +54 -0
- data/lib/librarian/puppet/extension.rb +41 -0
- data/lib/librarian/puppet/lockfile/parser.rb +53 -0
- data/lib/librarian/puppet/source.rb +4 -0
- data/lib/librarian/puppet/source/forge.rb +279 -0
- data/lib/librarian/puppet/source/git.rb +114 -0
- data/lib/librarian/puppet/source/githubtarball.rb +234 -0
- data/lib/librarian/puppet/source/local.rb +57 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +10 -0
- data/lib/librarian/puppet/version.rb +5 -0
- data/vendor/librarian/CHANGELOG.md +185 -0
- data/vendor/librarian/Gemfile +6 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +403 -0
- data/vendor/librarian/Rakefile +34 -0
- data/vendor/librarian/bin/librarian-chef +7 -0
- data/vendor/librarian/bin/librarian-mock +7 -0
- data/vendor/librarian/config/cucumber.yaml +1 -0
- data/vendor/librarian/features/chef/cli/init.feature +11 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +77 -0
- data/vendor/librarian/features/chef/cli/version.feature +11 -0
- data/vendor/librarian/features/support/env.rb +9 -0
- data/vendor/librarian/lib/librarian.rb +19 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +24 -0
- data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
- data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
- data/vendor/librarian/lib/librarian/action/install.rb +99 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
- data/vendor/librarian/lib/librarian/action/update.rb +78 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +48 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +446 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +205 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
- data/vendor/librarian/lib/librarian/config.rb +7 -0
- data/vendor/librarian/lib/librarian/config/database.rb +205 -0
- data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
- data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
- data/vendor/librarian/lib/librarian/config/source.rb +149 -0
- data/vendor/librarian/lib/librarian/dependency.rb +91 -0
- data/vendor/librarian/lib/librarian/dsl.rb +108 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +172 -0
- data/vendor/librarian/lib/librarian/environment.rb +134 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +100 -0
- data/vendor/librarian/lib/librarian/logger.rb +46 -0
- data/vendor/librarian/lib/librarian/manifest.rb +132 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
- data/vendor/librarian/lib/librarian/mock.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
- data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
- data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +44 -0
- data/vendor/librarian/lib/librarian/resolver.rb +78 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +118 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/git.rb +150 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
- data/vendor/librarian/lib/librarian/source/local.rb +61 -0
- data/vendor/librarian/lib/librarian/source/path.rb +74 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
- data/vendor/librarian/lib/librarian/specfile.rb +18 -0
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
- data/vendor/librarian/lib/librarian/ui.rb +64 -0
- data/vendor/librarian/lib/librarian/version.rb +3 -0
- data/vendor/librarian/librarian.gemspec +34 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
- data/vendor/librarian/spec/functional/source/git/repository_spec.rb +149 -0
- data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
- data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
- data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
- data/vendor/librarian/spec/unit/config/database_spec.rb +319 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +36 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
- data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
- data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
- data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
- metadata +227 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Tim Sharpe
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# Librarian-puppet
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
Librarian-puppet is a bundler for your puppet infrastructure. You can use
|
6
|
+
librarian-puppet to manage the puppet modules your infrastructure depends on.
|
7
|
+
It is based on [Librarian](https://github.com/applicationsonline/librarian), a
|
8
|
+
framework for writing bundlers, which are tools that resolve, fetch, install,
|
9
|
+
and isolate a project's dependencies.
|
10
|
+
|
11
|
+
Librarian-puppet manages your `modules/` directory for you based on your
|
12
|
+
`Puppetfile`. Your `Puppetfile` becomes the authoritative source for what
|
13
|
+
modules you require and at what version, tag or branch.
|
14
|
+
|
15
|
+
Once using Librarian-puppet you should not modify the contents of your `modules`
|
16
|
+
directory. The individual modules' repos should be updated, tagged with a new
|
17
|
+
release and the version bumped in your Puppetfile.
|
18
|
+
|
19
|
+
## The Puppetfile
|
20
|
+
|
21
|
+
Every Puppet repository that uses Librarian-puppet will have a file named
|
22
|
+
`Puppetfile` in the root directory of that repository. The full specification
|
23
|
+
for which modules your puppet infrastructure repository depends goes in here.
|
24
|
+
|
25
|
+
### Example Puppetfile
|
26
|
+
|
27
|
+
forge "http://forge.puppetlabs.com"
|
28
|
+
|
29
|
+
mod "puppetlabs/razor"
|
30
|
+
mod "puppetlabs/ntp", "0.0.3"
|
31
|
+
|
32
|
+
mod "apt",
|
33
|
+
:git => "git://github.com/puppetlabs/puppetlabs-apt.git"
|
34
|
+
|
35
|
+
mod "stdlib",
|
36
|
+
:git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"
|
37
|
+
|
38
|
+
*See [jenkins-appliance](https://github.com/aussielunix/jenkins-appliance) for
|
39
|
+
a puppet repo already setup to use librarian-puppet.*
|
40
|
+
|
41
|
+
### Puppetfile Breakdown
|
42
|
+
|
43
|
+
forge "http://forge.puppetlabs.com"
|
44
|
+
|
45
|
+
This declares that we want to use the official Puppet Labs Forge as our default
|
46
|
+
source when pulling down modules. If you run your own local forge, you may
|
47
|
+
want to change this.
|
48
|
+
|
49
|
+
mod "puppetlabs/razor"
|
50
|
+
|
51
|
+
Pull in the latest version of the Puppet Labs Razor module from the default
|
52
|
+
source.
|
53
|
+
|
54
|
+
mod "puppetlabs/ntp", "0.0.3"
|
55
|
+
|
56
|
+
Pull in version 0.0.3 of the Puppet Labs NTP module from the default source.
|
57
|
+
|
58
|
+
mod "apt",
|
59
|
+
:git => "git://github.com/puppetlabs/puppetlabs-apt.git"
|
60
|
+
|
61
|
+
Our puppet infrastructure repository depends on the `apt` module from the
|
62
|
+
Puppet Labs GitHub repos and checks out the `master` branch.
|
63
|
+
|
64
|
+
mod "apt",
|
65
|
+
:git => "git://github.com/puppetlabs/puppetlabs-apt.git",
|
66
|
+
:ref => '0.0.3'
|
67
|
+
|
68
|
+
Our puppet infrastructure repository depends on the `apt` module from the
|
69
|
+
Puppet Labs GitHub repos and checks out a tag of `0.0.3`.
|
70
|
+
|
71
|
+
mod "apt",
|
72
|
+
:git => "git://github.com/puppetlabs/puppetlabs-apt.git",
|
73
|
+
:ref => 'feature/master/dans_refactor'
|
74
|
+
|
75
|
+
Our puppet infrastructure repository depends on the `apt` module from the
|
76
|
+
Puppet Labs GitHub repos and checks out the `dans_refactor` branch.
|
77
|
+
|
78
|
+
When using a Git source, we do not have to use a `:ref =>`.
|
79
|
+
If we do not, then librarian-puppet will assume we meant the `master` branch.
|
80
|
+
|
81
|
+
If we use a `:ref =>`, we can use anything that Git will recognize as a ref.
|
82
|
+
This includes any branch name, tag name, SHA, or SHA unique prefix. If we use a
|
83
|
+
branch, we can later ask Librarian-pupet to update the modulek by fetching the
|
84
|
+
most recent version of the module from that same branch.
|
85
|
+
|
86
|
+
The Git source also supports a `:path =>` option. If we use the path option,
|
87
|
+
Librarian-puppet will navigate down into the Git repository and only use the
|
88
|
+
specified subdirectory. Some people have the habit of having a single repository
|
89
|
+
with many modules in it. If we need a module from such a repository, we can
|
90
|
+
use the `:path =>` option here to help Librarian-puppet drill down and find the
|
91
|
+
module subdirectory.
|
92
|
+
|
93
|
+
mod "apt",
|
94
|
+
:git => "git://github.com/fake/puppet-modules.git",
|
95
|
+
:path => "modules/apt"
|
96
|
+
|
97
|
+
Our puppet infrastructure repository depends on the `apt` module, which we have
|
98
|
+
stored as a directory under our `puppet-modules` git repos.
|
99
|
+
|
100
|
+
## How to Use
|
101
|
+
|
102
|
+
Install librarian-puppet:
|
103
|
+
|
104
|
+
$ gem install librarian-puppet
|
105
|
+
|
106
|
+
Prepare your puppet infrastructure repository:
|
107
|
+
|
108
|
+
$ cd ~/path/to/puppet-inf-repos
|
109
|
+
$ (git) rm -rf modules
|
110
|
+
$ librarian-puppet init
|
111
|
+
|
112
|
+
Librarian-puppet takes over your `modules/` directory, and will always
|
113
|
+
reinstall (if missing) the modules listed the `Puppetfile.lock` into your
|
114
|
+
`modules/` directory, therefore you do not need your `modules/` directory to be
|
115
|
+
tracked in Git.
|
116
|
+
|
117
|
+
Librarian-puppet uses a `.tmp/` directory for tempfiles and caches. You should
|
118
|
+
not track this directory in Git.
|
119
|
+
|
120
|
+
Running `librarian-puppet init` will create a skeleton Puppetfile for you as
|
121
|
+
well as adding `tmp/` and `modules/` to your `.gitignore`.
|
122
|
+
|
123
|
+
$ librarian-puppet install [--clean] [--verbose]
|
124
|
+
|
125
|
+
This command looks at each `mod` declaration and fetches the module from the
|
126
|
+
source specified. This command writes the complete resolution into
|
127
|
+
`Puppetfile.lock` and then copies all of the fetched modules into your
|
128
|
+
`modules/` directory, overwriting whatever was there before.
|
129
|
+
|
130
|
+
Get an overview of your `Puppetfile.lock` with:
|
131
|
+
|
132
|
+
$ librarian-puppet show
|
133
|
+
|
134
|
+
Inspect the details of specific resolved dependencies with:
|
135
|
+
|
136
|
+
$ librarian-puppet show NAME1 [NAME2, ...]
|
137
|
+
|
138
|
+
Find out which dependencies are outdated and may be updated:
|
139
|
+
|
140
|
+
$ librarian-puppet outdated [--verbose]
|
141
|
+
|
142
|
+
Update the version of a dependency:
|
143
|
+
|
144
|
+
$ librarian-puppet update apt [--verbose]
|
145
|
+
$ git diff Puppetfile.lock
|
146
|
+
$ git add Puppetfile.lock
|
147
|
+
$ git commit -m "bumped the version of apt up to 0.0.4."
|
148
|
+
|
149
|
+
## How to Contribute
|
150
|
+
|
151
|
+
* Pull requests please.
|
152
|
+
* Bonus points for feature branches.
|
153
|
+
|
154
|
+
## Reporting Issues
|
155
|
+
|
156
|
+
Bug reports to the github issue tracker please.
|
157
|
+
Please include:
|
158
|
+
|
159
|
+
* relevant `Puppetfile` and `Puppetfile.lock` files.
|
160
|
+
* version of ruby, librarian-puppet
|
161
|
+
* What distro
|
162
|
+
* Please run the `librarian-puppet` commands in verbose mode by using the
|
163
|
+
`--verbose` flag, and include the verbose output in the bug report as well.
|
164
|
+
|
165
|
+
## Changelog
|
166
|
+
|
167
|
+
### 0.9.0
|
168
|
+
|
169
|
+
* Initial release
|
170
|
+
|
171
|
+
### 0.9.1
|
172
|
+
|
173
|
+
* Proper error message when a module that is sourced from the forge does not
|
174
|
+
exist.
|
175
|
+
* Added support for annotated tags as git references.
|
176
|
+
* `librarian-puppet init` adds `.tmp/` to gitignore instead of `tmp/`.
|
177
|
+
* Fixed syntax error in the template Puppetfile created by `librarian-puppet
|
178
|
+
init`.
|
179
|
+
* Checks for `lib/puppet` as well as `manifests/` when checking if the git
|
180
|
+
repository is a valid module.
|
181
|
+
* When a user specifies `<foo>/<bar>` as the name of a module sources from a
|
182
|
+
git repository, assume the module name is actually `<bar>`.
|
183
|
+
* Fixed gem description and summary in gemspec.
|
184
|
+
|
185
|
+
## License
|
186
|
+
Please see the [LICENSE](https://github.com/rodjek/librarian-puppet/blob/master/LICENSE)
|
187
|
+
file.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path('../../lib', __FILE__)
|
4
|
+
vendor = File.expand_path('../../vendor/librarian/lib', __FILE__)
|
5
|
+
$:.unshift(lib) unless $:.include?(lib)
|
6
|
+
$:.unshift(vendor) unless $:.include?(vendor)
|
7
|
+
|
8
|
+
require 'librarian/puppet/cli'
|
9
|
+
Librarian::Puppet::Cli.bin!
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'librarian/helpers'
|
2
|
+
|
3
|
+
require 'librarian/cli'
|
4
|
+
require 'librarian/puppet'
|
5
|
+
|
6
|
+
module Librarian
|
7
|
+
module Puppet
|
8
|
+
class Cli < Librarian::Cli
|
9
|
+
|
10
|
+
module Particularity
|
11
|
+
def root_module
|
12
|
+
Puppet
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
include Particularity
|
17
|
+
extend Particularity
|
18
|
+
|
19
|
+
source_root Pathname.new(__FILE__).dirname.join("templates")
|
20
|
+
|
21
|
+
def init
|
22
|
+
copy_file environment.specfile_name
|
23
|
+
|
24
|
+
if File.exists? ".gitignore"
|
25
|
+
gitignore = File.read('.gitignore').split("\n")
|
26
|
+
else
|
27
|
+
gitignore = []
|
28
|
+
end
|
29
|
+
|
30
|
+
gitignore << ".tmp/" unless gitignore.include? ".tmp/"
|
31
|
+
gitignore << "modules/" unless gitignore.include? "modules/"
|
32
|
+
|
33
|
+
File.open(".gitignore", 'w') do |f|
|
34
|
+
f.puts gitignore.join("\n")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "install", "Resolves and installs all of the dependencies you specify."
|
39
|
+
option "quiet", :type => :boolean, :default => false
|
40
|
+
option "verbose", :type => :boolean, :default => false
|
41
|
+
option "line-numbers", :type => :boolean, :default => false
|
42
|
+
option "clean", :type => :boolean, :default => false
|
43
|
+
option "strip-dot-git", :type => :boolean
|
44
|
+
option "path", :type => :string
|
45
|
+
option "destructive", :type => :boolean, :default => false
|
46
|
+
option "local", :type => :boolean, :default => false
|
47
|
+
def install
|
48
|
+
ensure!
|
49
|
+
clean! if options["clean"]
|
50
|
+
unless options["destructive"].nil?
|
51
|
+
environment.config_db.local['destructive'] = options['destructive'].to_s
|
52
|
+
end
|
53
|
+
if options.include?("strip-dot-git")
|
54
|
+
strip_dot_git_val = options["strip-dot-git"] ? "1" : nil
|
55
|
+
environment.config_db.local["install.strip-dot-git"] = strip_dot_git_val
|
56
|
+
end
|
57
|
+
if options.include?("path")
|
58
|
+
environment.config_db.local["path"] = options["path"]
|
59
|
+
end
|
60
|
+
|
61
|
+
environment.config_db.local['mode'] = options['local'] ? 'local' : nil
|
62
|
+
|
63
|
+
resolve!
|
64
|
+
install!
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "package", "Cache the puppet modules in vendor/puppet/cache."
|
68
|
+
option "quiet", :type => :boolean, :default => false
|
69
|
+
option "verbose", :type => :boolean, :default => false
|
70
|
+
option "line-numbers", :type => :boolean, :default => false
|
71
|
+
option "clean", :type => :boolean, :default => false
|
72
|
+
option "strip-dot-git", :type => :boolean
|
73
|
+
option "path", :type => :string
|
74
|
+
option "destructive", :type => :boolean, :default => false
|
75
|
+
def package
|
76
|
+
environment.vendor!
|
77
|
+
install
|
78
|
+
end
|
79
|
+
|
80
|
+
def version
|
81
|
+
say "librarian-puppet v#{Librarian::Puppet::VERSION}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'librarian/dsl'
|
2
|
+
require 'librarian/puppet/source'
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
module Puppet
|
6
|
+
class Dsl < Librarian::Dsl
|
7
|
+
|
8
|
+
dependency :mod
|
9
|
+
|
10
|
+
source :forge => Source::Forge
|
11
|
+
source :git => Source::Git
|
12
|
+
source :path => Source::Path
|
13
|
+
source :github_tarball => Source::GitHubTarball
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "librarian/environment"
|
2
|
+
require "librarian/puppet/dsl"
|
3
|
+
require "librarian/puppet/source"
|
4
|
+
require "librarian/puppet/lockfile/parser"
|
5
|
+
|
6
|
+
module Librarian
|
7
|
+
module Puppet
|
8
|
+
class Environment < Librarian::Environment
|
9
|
+
|
10
|
+
def adapter_name
|
11
|
+
"puppet"
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_path
|
15
|
+
part = config_db["path"] || "modules"
|
16
|
+
project_path.join(part)
|
17
|
+
end
|
18
|
+
|
19
|
+
def vendor_path
|
20
|
+
project_path.join('vendor/puppet')
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_cache
|
24
|
+
vendor_path.join('cache')
|
25
|
+
end
|
26
|
+
|
27
|
+
def vendor_source
|
28
|
+
vendor_path.join('source')
|
29
|
+
end
|
30
|
+
|
31
|
+
def cache_path
|
32
|
+
project_path.join(".tmp/librarian/cache")
|
33
|
+
end
|
34
|
+
|
35
|
+
def scratch_path
|
36
|
+
project_path.join(".tmp/librarian/scratch")
|
37
|
+
end
|
38
|
+
|
39
|
+
def vendor!
|
40
|
+
vendor_cache.mkpath unless vendor_cache.exist?
|
41
|
+
vendor_source.mkpath unless vendor_source.exist?
|
42
|
+
end
|
43
|
+
|
44
|
+
def vendor?
|
45
|
+
vendor_path.exist?
|
46
|
+
end
|
47
|
+
|
48
|
+
def local?
|
49
|
+
config_db['mode'] == 'local'
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'librarian/puppet/environment'
|
2
|
+
|
3
|
+
module Librarian
|
4
|
+
module Puppet
|
5
|
+
extend self
|
6
|
+
extend Librarian
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Librarian
|
12
|
+
class Dependency
|
13
|
+
class Requirement
|
14
|
+
def initialize(*args)
|
15
|
+
args = initialize_normalize_args(args)
|
16
|
+
self.backing = Gem::Requirement.create(puppet_to_gem_versions(args))
|
17
|
+
end
|
18
|
+
|
19
|
+
def puppet_to_gem_versions(args)
|
20
|
+
args.map do |arg|
|
21
|
+
case arg
|
22
|
+
when Array
|
23
|
+
arg.map { |v| puppet_to_gem_version(v) }
|
24
|
+
when String
|
25
|
+
puppet_to_gem_version(arg)
|
26
|
+
else
|
27
|
+
# Gem::Requirement, do nothing
|
28
|
+
arg
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# convert Puppet '1.x' versions to gem supported versions '~>1.0'
|
34
|
+
# http://docs.puppetlabs.com/puppet/2.7/reference/modules_publishing.html
|
35
|
+
def puppet_to_gem_version(version)
|
36
|
+
matched = /(.*)\.x/.match(version)
|
37
|
+
matched.nil? ? version : "~>#{matched[1]}.0"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'librarian/manifest'
|
2
|
+
require 'librarian/dependency'
|
3
|
+
require 'librarian/manifest_set'
|
4
|
+
|
5
|
+
module Librarian
|
6
|
+
class Lockfile
|
7
|
+
class Parser
|
8
|
+
|
9
|
+
def parse(string)
|
10
|
+
string = string.dup
|
11
|
+
source_type_names_map = Hash[dsl_class.source_types.map{|t| [t[1].lock_name, t[1]]}]
|
12
|
+
source_type_names = dsl_class.source_types.map{|t| t[1].lock_name}
|
13
|
+
lines = string.split(/(\r|\n|\r\n)+/).select{|l| l =~ /\S/}
|
14
|
+
sources = []
|
15
|
+
while source_type_names.include?(lines.first)
|
16
|
+
source = {}
|
17
|
+
source_type_name = lines.shift
|
18
|
+
source[:type] = source_type_names_map[source_type_name]
|
19
|
+
options = {}
|
20
|
+
while lines.first =~ /^ {2}([\w\-\/]+):\s+(.+)$/
|
21
|
+
lines.shift
|
22
|
+
options[$1.to_sym] = $2
|
23
|
+
end
|
24
|
+
source[:options] = options
|
25
|
+
lines.shift # specs
|
26
|
+
manifests = {}
|
27
|
+
while lines.first =~ /^ {4}([\w\-\/]+) \((.*)\)$/ # This change allows forward slash
|
28
|
+
lines.shift
|
29
|
+
name = $1
|
30
|
+
manifests[name] = {:version => $2, :dependencies => {}}
|
31
|
+
while lines.first =~ /^ {6}([\w\-\/]+) \((.*)\)$/
|
32
|
+
lines.shift
|
33
|
+
manifests[name][:dependencies][$1] = $2.split(/,\s*/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
source[:manifests] = manifests
|
37
|
+
sources << source
|
38
|
+
end
|
39
|
+
manifests = compile(sources)
|
40
|
+
manifests_index = Hash[manifests.map{|m| [m.name, m]}]
|
41
|
+
raise StandardError, "Expected DEPENDENCIES topic!" unless lines.shift == "DEPENDENCIES"
|
42
|
+
dependencies = []
|
43
|
+
while lines.first =~ /^ {2}([\w\-\/]+)(?: \((.*)\))?$/ # This change allows forward slash
|
44
|
+
lines.shift
|
45
|
+
name, requirement = $1, $2.split(/,\s*/)
|
46
|
+
dependencies << Dependency.new(name, requirement, manifests_index[name].source)
|
47
|
+
end
|
48
|
+
Resolution.new(dependencies, manifests)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|