simple-dependency-manager 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +3 -0
- data/LICENSE +13 -0
- data/README.md +69 -0
- data/bin/simple-dependency-manager +8 -0
- data/lib/bodepd/simple.rb +9 -0
- data/lib/bodepd/simple/cli.rb +169 -0
- data/lib/bodepd/simple/installer.rb +111 -0
- data/lib/bodepd/simple/iterator.rb +54 -0
- data/lib/bodepd/simple/util.rb +49 -0
- data/lib/bodepd/simple/version.rb +5 -0
- data/simple-dependency-manager.gemspec +23 -0
- data/spec/fixtures/Puppetfile +13 -0
- data/spec/functional/clean_spec.rb +42 -0
- data/spec/functional/install_spec.rb +74 -0
- data/spec/spec_helper.rb +25 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 168b18a544c62918825cd2b742b1a9b41ee16dbb
|
4
|
+
data.tar.gz: 7536abc891fbf95d392bf0e8dd3bbb5b5cc4e547
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 07ba46c5356dc317bf89ff8db420221fa102ca2c229949f04f38110947ad69f2e27c8412a7b4a60df55787f5dd36f764f4776bbf0d37ec982d6f21cc72a3a368
|
7
|
+
data.tar.gz: 12269ec9a17deb076a7a5c2bf6be6493a112c7c020f3507522ba257ff7c4606407fb60c4e8853f0862c01f0dfd95392cac933a41b36abb1e5bd324f46f1e3438
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2013-2014 Dan Bode
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# librarian-puppet-simple
|
2
|
+
|
3
|
+
This project was created out of my frustration with dependency management in librarian-puppet, some people need external dependencies, I just need to be able to pin revisions for a collection of modules, and I found the dependency managment features of librarian-puppet too heavy for my simple use case.
|
4
|
+
|
5
|
+
This project just has fewer commands, but they should be compatible with the original librarian-puppet:
|
6
|
+
|
7
|
+
### Clean
|
8
|
+
Remove the directory where the modules will be installed. At the moment the supported options are:
|
9
|
+
* `--verbose` display progress messages
|
10
|
+
* `--path` override the default `./modules` where modules will be installed
|
11
|
+
|
12
|
+
```
|
13
|
+
librarian-puppet clean [--verbose] [--path]
|
14
|
+
```
|
15
|
+
|
16
|
+
### Install
|
17
|
+
Iterates through your Puppetfile and installs git sources. At the moment the supported options are:
|
18
|
+
* `--verbose` display progress messages
|
19
|
+
* `--clean` remove the directory before installing modules
|
20
|
+
* `--path` override the default `./modules` where modules will be installed
|
21
|
+
* `--puppetfile` override the default `./Puppetfile` used to find the modules
|
22
|
+
|
23
|
+
```
|
24
|
+
librarian-puppet install [--verbose] [--clean] [--path] [--puppetfile]
|
25
|
+
```
|
26
|
+
|
27
|
+
### Update
|
28
|
+
Iterates through your Puppetfile and updates git sources. If a SHA-1 hash is specified in the `:ref`, the module will not be updated.
|
29
|
+
|
30
|
+
Supported options are:<br/>
|
31
|
+
<li>`--verbose` display progress messages</li>
|
32
|
+
<li>`--path` override the default `./modules` where modules will be installed</li>
|
33
|
+
<li> `--puppetfile` override the default `./Puppetfile` used to find the modules</li>
|
34
|
+
|
35
|
+
```
|
36
|
+
librarian-puppet update [--verbose] [--path] [--puppetfile]
|
37
|
+
```
|
38
|
+
|
39
|
+
## Puppetfile
|
40
|
+
The processed Puppetfile may contain two different types of modules, `git` and `tarball`. The `git` option accepts an optional `ref` parameter.
|
41
|
+
|
42
|
+
The module names can be namespaced, but the created directory will only contain the last part of the name. For example, a module named `puppetlabs/ntp` will generate a directory `ntp`, and so will a module simply named `ntp`.
|
43
|
+
|
44
|
+
Here's an example of a valid Puppetfile showcasing all valid options:
|
45
|
+
|
46
|
+
```
|
47
|
+
mod "puppetlabs/ntp",
|
48
|
+
:git => "git://github.com/puppetlabs/puppetlabs-ntp.git",
|
49
|
+
:ref => "99bae40f225db0dd052efbf1d4078a21f0333331"
|
50
|
+
|
51
|
+
mod "apache",
|
52
|
+
:tarball => "https://forge.puppetlabs.com/puppetlabs/apache/0.6.0.tar.gz"
|
53
|
+
```
|
54
|
+
|
55
|
+
## Setting up for development and running the specs
|
56
|
+
Just clone the repo and run the following commands:
|
57
|
+
```
|
58
|
+
bundle exec install --path=vendor
|
59
|
+
bundle exec rspec
|
60
|
+
```
|
61
|
+
|
62
|
+
Beware that the functional tests will download files from GitHub and PuppetForge and will break if either is unavailable.
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
See [LICENSE](/LICENSE)
|
67
|
+
|
68
|
+
## Credits
|
69
|
+
The untar and ungzip methods came from https://gist.github.com/sinisterchipmunk/1335041
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'bodepd/simple/installer'
|
2
|
+
require 'bodepd/simple/iterator'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Bodepd
|
6
|
+
module Simple
|
7
|
+
class CLI < Thor
|
8
|
+
|
9
|
+
include Bodepd::Simple::Util
|
10
|
+
include Bodepd::Simple::Installer
|
11
|
+
include Bodepd::Simple::Iterator
|
12
|
+
|
13
|
+
class_option :verbose, :type => :boolean,
|
14
|
+
:desc => 'verbose output for executed commands'
|
15
|
+
|
16
|
+
class_option :path, :type => :string,
|
17
|
+
:desc => "overrides target directory, default is ./modules"
|
18
|
+
class_option :depfile, :type => :string,
|
19
|
+
:desc => "overrides used Depfile",
|
20
|
+
:default => './Depfile'
|
21
|
+
|
22
|
+
|
23
|
+
def self.bin!
|
24
|
+
start
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'install', 'installs all git sources from your Depfile'
|
28
|
+
method_option :clean, :type => :boolean, :desc => "calls clean before executing install"
|
29
|
+
def install
|
30
|
+
@verbose = options[:verbose]
|
31
|
+
clean if options[:clean]
|
32
|
+
@custom_module_path = options[:path]
|
33
|
+
# evaluate the file to populate @modules
|
34
|
+
eval(File.read(File.expand_path(options[:depfile])))
|
35
|
+
install!
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'update', 'updates all git sources from your Depfile'
|
39
|
+
method_option :update, :type => :boolean, :desc => "Updates git sources"
|
40
|
+
def update
|
41
|
+
@verbose = options[:verbose]
|
42
|
+
@custom_module_path = options[:path]
|
43
|
+
eval(File.read(File.expand_path(options[:depfile])))
|
44
|
+
each_module_of_type(:git) do |repo|
|
45
|
+
if Dir.exists?(File.join(module_path, repo[:name]))
|
46
|
+
Dir.chdir(File.join(module_path, repo[:name])) do
|
47
|
+
remote = repo[:git]
|
48
|
+
# if no ref is given, assume master
|
49
|
+
branch = repo[:ref] || 'master'
|
50
|
+
if branch =~ /^origin\/(.*)$/
|
51
|
+
branch = $1
|
52
|
+
end
|
53
|
+
co_cmd = 'git checkout FETCH_HEAD'
|
54
|
+
update_cmd = "git fetch #{repo[:git]} #{branch} && #{co_cmd}"
|
55
|
+
print_verbose "\n\n#{repo[:name]} -- #{update_cmd}"
|
56
|
+
git_pull_cmd = system_cmd(update_cmd)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
install_git module_path, repo[:name], repo[:git], repo[:ref]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'clean', 'clean modules directory'
|
65
|
+
def clean
|
66
|
+
target_directory = options[:path] || File.expand_path("./modules")
|
67
|
+
puts "Target Directory: #{target_directory}" if options[:verbose]
|
68
|
+
FileUtils.rm_rf target_directory
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'git_status', 'determine the current status of checked out git repos'
|
72
|
+
def git_status
|
73
|
+
@custom_module_path = options[:path]
|
74
|
+
# populate @modules
|
75
|
+
eval(File.read(File.expand_path(options[:depfile])))
|
76
|
+
each_module_of_type(:git) do |repo|
|
77
|
+
Dir.chdir(File.join(module_path, repo[:name])) do
|
78
|
+
status = system_cmd('git status')
|
79
|
+
if status.include?('nothing to commit (working directory clean)')
|
80
|
+
puts "Module #{repo[:name]} has not changed" if options[:verbose]
|
81
|
+
else
|
82
|
+
puts "Uncommitted changes for: #{repo[:name]}"
|
83
|
+
puts " #{status.join("\n ")}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'dev_setup', 'adds development r/w remotes to each repo (assumes remote has the same name as current repo)'
|
90
|
+
def dev_setup(remote_name)
|
91
|
+
@custom_module_path = options[:path]
|
92
|
+
# populate @modules
|
93
|
+
eval(File.read(File.expand_path(options[:depfile])))
|
94
|
+
each_module_of_type(:git) do |repo|
|
95
|
+
Dir.chdir(File.join((options[:path] || 'modules'), repo[:name])) do
|
96
|
+
print_verbose "Adding development remote for git repo #{repo[:name]}"
|
97
|
+
remotes = system_cmd('git remote')
|
98
|
+
if remotes.include?(remote_name)
|
99
|
+
puts "Did not have to add remote #{remote_name} to #{repo[:name]}"
|
100
|
+
elsif ! remotes.include?('origin')
|
101
|
+
raise(TestException, "Repo #{repo[:name]} has no remote called origin, failing")
|
102
|
+
else
|
103
|
+
remote_url = system_cmd('git remote show origin').detect {|x| x =~ /\s+Push\s+URL: / }
|
104
|
+
if remote_url =~ /(git|https?):\/\/(.+)\/(.+)?\/(.+)/
|
105
|
+
url = "git@#{$2}:#{remote_name}/#{$4}"
|
106
|
+
puts "Adding remote #{remote_name} as #{url}"
|
107
|
+
system_cmd("git remote add #{remote_name} #{url}")
|
108
|
+
elsif remote_url =~ /^git@/
|
109
|
+
puts "Origin is already a read/write remote, skipping b/c this is unexpected"
|
110
|
+
else
|
111
|
+
puts "remote_url #{remote_url} did not have the expected format. weird..."
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
desc 'generate_depfile', 'generates a static version of the Depfile'
|
119
|
+
method_option :out_file,
|
120
|
+
:desc => 'output file where static depfile should be written to'
|
121
|
+
def generate_depfile
|
122
|
+
eval(File.read(File.expand_path(options[:depfile])))
|
123
|
+
if options[:out_file]
|
124
|
+
File.open(options[:out_file], 'w') do |fh|
|
125
|
+
print_puppet_file(fh)
|
126
|
+
end
|
127
|
+
else
|
128
|
+
print_puppet_file(STDOUT)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def print_dep_file(stream)
|
135
|
+
each_module do |repo|
|
136
|
+
repo.delete(:name)
|
137
|
+
out_str = repo.delete(:full_name)
|
138
|
+
repo.each do |k,v|
|
139
|
+
out_str << ", :#{k} => #{v}"
|
140
|
+
end
|
141
|
+
stream.puts(out_str)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# builds out a certain type of repo
|
146
|
+
def build_depfile(name, perform_installation=false)
|
147
|
+
repo_hash = {}
|
148
|
+
# set environment variable to determine what version of modules to install
|
149
|
+
# this assumes that the environment variable repos_to_use has been coded in
|
150
|
+
# your Depfile to allow installation of different versions of modules
|
151
|
+
ENV['repos_to_use'] = name
|
152
|
+
# parse Depfile and install modules in our tmp directory.
|
153
|
+
eval(File.read(File.expand_path(options[:depfile])))
|
154
|
+
# install modules if desired
|
155
|
+
install! if perform_installation
|
156
|
+
|
157
|
+
# iterate through all git modules
|
158
|
+
each_module_of_type(:git) do |git_repo|
|
159
|
+
abort("Module git_repo[:name] was defined multiple times in same Depfile") if repo_hash[git_repo[:name]]
|
160
|
+
repo_hash[git_repo[:name]] = git_repo
|
161
|
+
end
|
162
|
+
# clear out the modules once finished
|
163
|
+
clear_modules
|
164
|
+
repo_hash
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems/package'
|
3
|
+
require 'zlib'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'bodepd/simple/util'
|
6
|
+
require 'bodepd/simple/iterator'
|
7
|
+
|
8
|
+
# This is an extremely simple file that can consume
|
9
|
+
# a Puppet file with git references
|
10
|
+
#
|
11
|
+
# It does absolutely no dependency resolution by design.
|
12
|
+
#
|
13
|
+
module Bodepd
|
14
|
+
module Simple
|
15
|
+
module Installer
|
16
|
+
|
17
|
+
include Bodepd::Simple::Util
|
18
|
+
include Bodepd::Simple::Iterator
|
19
|
+
|
20
|
+
# installs modules using the each_module method from our
|
21
|
+
# iterator mixin
|
22
|
+
def install!
|
23
|
+
each_module do |repo|
|
24
|
+
|
25
|
+
print_verbose "\n##### processing module #{repo[:name]}..."
|
26
|
+
|
27
|
+
module_dir = File.join(module_path, repo[:name])
|
28
|
+
|
29
|
+
unless File.exists?(module_dir)
|
30
|
+
case
|
31
|
+
when repo[:git]
|
32
|
+
install_git module_path, repo[:name], repo[:git], repo[:ref]
|
33
|
+
when repo[:tarball]
|
34
|
+
install_tarball module_path, repo[:name], repo[:tarball]
|
35
|
+
else
|
36
|
+
abort('only the :git and :tarball provider are currently supported')
|
37
|
+
end
|
38
|
+
else
|
39
|
+
print_verbose "\nModule #{repo[:name]} already installed in #{module_path}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# installs sources that are git repos
|
47
|
+
def install_git(module_path, module_name, repo, ref = nil)
|
48
|
+
module_dir = File.join(module_path, module_name)
|
49
|
+
|
50
|
+
Dir.chdir(module_path) do
|
51
|
+
print_verbose "cloning #{repo}"
|
52
|
+
system_cmd("git clone #{repo} #{module_name}")
|
53
|
+
Dir.chdir(module_dir) do
|
54
|
+
system_cmd('git branch -r')
|
55
|
+
system_cmd("git checkout #{ref}") if ref
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def install_tarball(module_path, module_name, remote_tarball)
|
61
|
+
Dir.mktmpdir do |tmp|
|
62
|
+
temp_file = File.join(tmp,"downloaded_module.tar.gz")
|
63
|
+
File.open(temp_file, "w+b") do |saved_file|
|
64
|
+
print_verbose "Downloading #{remote_tarball}..."
|
65
|
+
open(remote_tarball, 'rb') do |read_file|
|
66
|
+
saved_file.write(read_file.read)
|
67
|
+
end
|
68
|
+
saved_file.rewind
|
69
|
+
|
70
|
+
target_directory = File.join(module_path, module_name)
|
71
|
+
print_verbose "Extracting #{remote_tarball} to #{target_directory}..."
|
72
|
+
unzipped_target = ungzip(saved_file)
|
73
|
+
tarfile_full_name = untar(unzipped_target, module_path)
|
74
|
+
FileUtils.mv File.join(module_path, tarfile_full_name), target_directory
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# un-gzips the given IO, returning the
|
80
|
+
# decompressed version as a StringIO
|
81
|
+
def ungzip(tarfile)
|
82
|
+
z = Zlib::GzipReader.new(tarfile)
|
83
|
+
unzipped = StringIO.new(z.read)
|
84
|
+
z.close
|
85
|
+
unzipped
|
86
|
+
end
|
87
|
+
|
88
|
+
# untars the given IO into the specified
|
89
|
+
# directory
|
90
|
+
def untar(io, destination)
|
91
|
+
tarfile_full_name = nil
|
92
|
+
Gem::Package::TarReader.new io do |tar|
|
93
|
+
tar.each do |tarfile|
|
94
|
+
tarfile_full_name ||= tarfile.full_name
|
95
|
+
destination_file = File.join destination, tarfile.full_name
|
96
|
+
if tarfile.directory?
|
97
|
+
FileUtils.mkdir_p destination_file
|
98
|
+
else
|
99
|
+
destination_directory = File.dirname(destination_file)
|
100
|
+
FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)
|
101
|
+
File.open destination_file, "wb" do |f|
|
102
|
+
f.write tarfile.read
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
tarfile_full_name
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'bodepd/simple/util'
|
2
|
+
|
3
|
+
module Bodepd
|
4
|
+
module Simple
|
5
|
+
module Iterator
|
6
|
+
|
7
|
+
# evaluate a module and add it our @modules instance variable
|
8
|
+
def mod(name, options = {})
|
9
|
+
@modules ||= {}
|
10
|
+
full_name = name
|
11
|
+
module_name = name.split('/', 2).last
|
12
|
+
|
13
|
+
case
|
14
|
+
when options[:git]
|
15
|
+
@modules[:git] ||= {}
|
16
|
+
@modules[:git][module_name] = options.merge(:name => module_name, :full_name => full_name)
|
17
|
+
when options[:tarball]
|
18
|
+
@modules[:tarball] ||= {}
|
19
|
+
@modules[:tarball][module_name] = options.merge(:name => module_name, :full_name => full_name)
|
20
|
+
else
|
21
|
+
@modules[:forge] ||= {}
|
22
|
+
@modules[:forge][module_name] = options.merge(:name => module_name, :full_name => full_name)
|
23
|
+
#abort('only the :git and :tarball providers are currently supported')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def modules
|
28
|
+
@modules
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear_modules
|
32
|
+
@modules = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# iterate through all modules
|
36
|
+
def each_module(&block)
|
37
|
+
(@modules || {}).each do |type, repos|
|
38
|
+
(repos || {}).values.each do |repo|
|
39
|
+
yield repo
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# loop over each module of a certain type
|
45
|
+
def each_module_of_type(type, &block)
|
46
|
+
abort("undefined type #{type}") unless [:git, :tarball].include?(type)
|
47
|
+
((@modules || {})[type] || {}).values.each do |repo|
|
48
|
+
yield repo
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# this module contains all of the base helper methods
|
3
|
+
# used by the other actions
|
4
|
+
#
|
5
|
+
module Bodepd
|
6
|
+
module Simple
|
7
|
+
module Util
|
8
|
+
|
9
|
+
def forge(repo)
|
10
|
+
# this does nothing atm
|
11
|
+
end
|
12
|
+
# figure out what directory we are working out og
|
13
|
+
def base_dir
|
14
|
+
@base_dir ||= Dir.pwd
|
15
|
+
end
|
16
|
+
|
17
|
+
# figure out what the modulepath is
|
18
|
+
def module_path(dir=base_dir)
|
19
|
+
unless @module_path
|
20
|
+
if @custom_module_path
|
21
|
+
@module_path = File.expand_path @custom_module_path
|
22
|
+
else
|
23
|
+
@module_path = File.join(dir, 'modules')
|
24
|
+
end
|
25
|
+
Dir.mkdir(@module_path) unless File.exists?(@module_path)
|
26
|
+
end
|
27
|
+
@module_path
|
28
|
+
end
|
29
|
+
|
30
|
+
# run a command on the system
|
31
|
+
def system_cmd (cmd, print_output=false)
|
32
|
+
print_verbose "Running cmd: #{cmd}"
|
33
|
+
output = `#{cmd}`.split("\n")
|
34
|
+
if print_output
|
35
|
+
puts output
|
36
|
+
else
|
37
|
+
print_verbose output
|
38
|
+
end
|
39
|
+
raise(StandardError, "Cmd #{cmd} failed") unless $?.success?
|
40
|
+
output
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_verbose(text)
|
44
|
+
puts text if @verbose
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require 'bodepd/simple/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'simple-dependency-manager'
|
7
|
+
s.version = Bodepd::Simple::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Dan Bode']
|
10
|
+
s.email = ['bodepd@gmail.com']
|
11
|
+
s.homepage = 'https://github.com/bodepd/simple-dependency-manager'
|
12
|
+
s.summary = 'Language agnostic dependency file'
|
13
|
+
s.description = 'Simply grabs things from a Dependencies file and installs them. Simple.'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency "thor", "~> 0.15"
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec", "~> 2.13"
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
mod 'puppetlabs/ntp',
|
2
|
+
:git => 'git://github.com/puppetlabs/puppetlabs-ntp.git',
|
3
|
+
:ref => '99bae40f225db0dd052efbf1d4078a21f0333331'
|
4
|
+
|
5
|
+
mod 'apache',
|
6
|
+
:tarball => 'https://forge.puppetlabs.com/puppetlabs/apache/0.6.0.tar.gz'
|
7
|
+
|
8
|
+
mod 'ghoneycutt/testlps',
|
9
|
+
:git => 'git://github.com/ghoneycutt/testlps.git'
|
10
|
+
|
11
|
+
mod 'ghoneycutt/dnsclient',
|
12
|
+
:git => 'git://github.com/ghoneycutt/puppet-module-dnsclient.git',
|
13
|
+
:ref => 'v3.0.4'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
describe "Functional - Clean" do
|
6
|
+
it "displays install help message" do
|
7
|
+
output, status = execute_captured("bin/librarian-puppet help clean")
|
8
|
+
output.should_not include("ERROR")
|
9
|
+
output.should_not include("Could not find command")
|
10
|
+
status.should == 0
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "when running 'librarian-puppet clean'" do
|
14
|
+
temp_directory = nil
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
temp_directory = Dir.mktmpdir
|
18
|
+
Dir.entries(temp_directory).should =~ ['.', '..']
|
19
|
+
FileUtils.touch File.join(temp_directory, 'trashfile')
|
20
|
+
Dir.entries(temp_directory).should =~ ['.', '..', 'trashfile']
|
21
|
+
end
|
22
|
+
|
23
|
+
after :each do
|
24
|
+
FileUtils.rm_rf temp_directory if File.exist?(temp_directory)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "with --path it cleans the directory" do
|
28
|
+
output, status = execute_captured("bin/librarian-puppet clean --path=#{temp_directory}")
|
29
|
+
|
30
|
+
status.should == 0
|
31
|
+
# Using File.exist? to be compatible with Ruby 1.8.7
|
32
|
+
File.exist?(temp_directory).should be_false
|
33
|
+
end
|
34
|
+
|
35
|
+
it "with --verbose it shows progress messages" do
|
36
|
+
output, status = execute_captured("bin/librarian-puppet clean --verbose --path=#{temp_directory}")
|
37
|
+
|
38
|
+
status.should == 0
|
39
|
+
output.should include("Target Directory: #{temp_directory}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
describe "Functional - Install" do
|
6
|
+
before :all do
|
7
|
+
warning_message = "ATTENTION: these tests download information from github.com and forge.puppetlabs.com"
|
8
|
+
puts '*' * warning_message.length
|
9
|
+
puts warning_message
|
10
|
+
puts '*' * warning_message.length
|
11
|
+
end
|
12
|
+
|
13
|
+
it "displays install help message" do
|
14
|
+
output, status = execute_captured("bin/librarian-puppet help install")
|
15
|
+
output.should_not include("ERROR")
|
16
|
+
output.should_not include("Could not find command")
|
17
|
+
status.should == 0
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "when running 'librarian-puppet install'" do
|
21
|
+
temp_directory = nil
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
temp_directory = Dir.mktmpdir
|
25
|
+
Dir.entries(temp_directory).should =~ ['.', '..']
|
26
|
+
FileUtils.touch File.join(temp_directory, 'trashfile')
|
27
|
+
Dir.entries(temp_directory).should =~ ['.', '..', 'trashfile']
|
28
|
+
end
|
29
|
+
|
30
|
+
after :each do
|
31
|
+
FileUtils.rm_rf temp_directory
|
32
|
+
end
|
33
|
+
|
34
|
+
it "install the modules in a temp directory" do
|
35
|
+
output, status = execute_captured("bin/librarian-puppet install --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
|
36
|
+
|
37
|
+
status.should == 0
|
38
|
+
Dir.entries(temp_directory).should =~ %w|. .. apache ntp trashfile dnsclient testlps|
|
39
|
+
end
|
40
|
+
|
41
|
+
it "with --clean it cleans the directory before installing the modules in a temp directory" do
|
42
|
+
output, status = execute_captured("bin/librarian-puppet install --clean --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
|
43
|
+
|
44
|
+
status.should == 0
|
45
|
+
Dir.entries(temp_directory).should =~ %w|. .. apache ntp dnsclient testlps|
|
46
|
+
end
|
47
|
+
|
48
|
+
it "with --verbose it outputs progress messages" do
|
49
|
+
output, status = execute_captured("bin/librarian-puppet install --verbose --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
|
50
|
+
|
51
|
+
status.should == 0
|
52
|
+
output.should include('##### processing module apache')
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'when modules are already installed' do
|
56
|
+
temp_directory = nil
|
57
|
+
|
58
|
+
before :each do
|
59
|
+
temp_directory = Dir.mktmpdir
|
60
|
+
Dir.entries(temp_directory).should =~ ['.', '..']
|
61
|
+
FileUtils.touch File.join(temp_directory, 'apache')
|
62
|
+
Dir.entries(temp_directory).should =~ ['.', '..', 'apache']
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'without clean it should only install ntp' do
|
66
|
+
output, status = execute_captured("bin/librarian-puppet install --verbose --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
|
67
|
+
status.should == 0
|
68
|
+
output.should include('Module apache already installed')
|
69
|
+
Dir.entries(temp_directory).should =~ %w|. .. apache ntp dnsclient testlps|
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'open3'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
|
14
|
+
# Run specs in random order to surface order dependencies. If you find an
|
15
|
+
# order dependency and want to debug it, you can fix the order by providing
|
16
|
+
# the seed, which is printed after each run.
|
17
|
+
# --seed 1234
|
18
|
+
config.order = 'random'
|
19
|
+
|
20
|
+
def execute_captured(command)
|
21
|
+
stdin, stdout, stderr = Open3.popen3(command)
|
22
|
+
condensed = stdout.readlines.join + stderr.readlines.join
|
23
|
+
[condensed, $?.exitstatus]
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple-dependency-manager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan Bode
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.13'
|
41
|
+
description: Simply grabs things from a Dependencies file and installs them. Simple.
|
42
|
+
email:
|
43
|
+
- bodepd@gmail.com
|
44
|
+
executables:
|
45
|
+
- simple-dependency-manager
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- bin/simple-dependency-manager
|
54
|
+
- lib/bodepd/simple.rb
|
55
|
+
- lib/bodepd/simple/cli.rb
|
56
|
+
- lib/bodepd/simple/installer.rb
|
57
|
+
- lib/bodepd/simple/iterator.rb
|
58
|
+
- lib/bodepd/simple/util.rb
|
59
|
+
- lib/bodepd/simple/version.rb
|
60
|
+
- simple-dependency-manager.gemspec
|
61
|
+
- spec/fixtures/Puppetfile
|
62
|
+
- spec/functional/clean_spec.rb
|
63
|
+
- spec/functional/install_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: https://github.com/bodepd/simple-dependency-manager
|
66
|
+
licenses: []
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.0.14
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Language agnostic dependency file
|
88
|
+
test_files:
|
89
|
+
- spec/fixtures/Puppetfile
|
90
|
+
- spec/functional/clean_spec.rb
|
91
|
+
- spec/functional/install_spec.rb
|
92
|
+
- spec/spec_helper.rb
|