Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ mod "puppetlabs/ntp",

mod "apache",
:tarball => "https://forge.puppetlabs.com/puppetlabs/apache/0.6.0.tar.gz"
```

#Deploy mysql module into modules/databases/mysql with the :subdir param
mod "mysql",
:git => "[email protected]:mysql.git",
:subdir => "databases"
```
## Setting up for development and running the specs
Just clone the repo and run the following commands:
```
Expand All @@ -66,4 +70,4 @@ Beware that the functional tests will download files from GitHub and PuppetForge
See [LICENSE](/LICENSE)

## Credits
The untar and ungzip methods came from https://gist.github.com/sinisterchipmunk/1335041
The untar and ungzip methods came from https://gist.github.com/sinisterchipmunk/1335041
18 changes: 10 additions & 8 deletions lib/librarian/puppet/simple/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ module Installer
# iterator mixin
def install!
each_module do |repo|

print_verbose "\n##### processing module #{repo[:name]}..."

module_dir = File.join(module_path, repo[:name])
# module path is where ALL the modules go, not this particular one
module_path = module_path()
module_dir = File.join(module_path, repo[:subdir] || repo[:name])

unless File.exists?(module_dir)
case
when repo[:git]
install_git module_path, repo[:name], repo[:git], repo[:ref]
install_git module_path, repo[:name], repo[:git], repo[:ref], repo[:subdir]
when repo[:tarball]
install_tarball module_path, repo[:name], repo[:tarball]
else
Expand All @@ -45,15 +45,17 @@ def install!
private

# installs sources that are git repos
def install_git(module_path, module_name, repo, ref = nil)
module_dir = File.join(module_path, module_name)
def install_git(module_path, module_name, repo, ref = nil, subdir = nil)
folder_name = subdir || module_name
module_dir = File.join(module_path, folder_name)

Dir.chdir(module_path) do
print_verbose "cloning #{repo}"
system_cmd("git clone #{repo} #{module_name}")
Dir.chdir(module_dir) do
system_cmd("git clone #{repo} #{folder_name}")
Dir.chdir(folder_name) do
system_cmd('git branch -r')
system_cmd("git checkout #{ref}") if ref
system_cmd("git filter-branch --subdirectory-filter #{subdir}") if subdir
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/librarian/puppet/simple/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Util
def forge(repo)
# this does nothing atm
end
# figure out what directory we are working out og
# figure out what directory we are working out of
def base_dir
@base_dir ||= Dir.pwd
end
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ mod 'ghoneycutt/testlps',
mod 'ghoneycutt/dnsclient',
:git => 'git://github.com/ghoneycutt/puppet-module-dnsclient.git',
:ref => 'v3.0.4'

mod 'haf/empty-repository',
:git => 'git://github.com/haf/empty-repository.git',
:subdir => 'subdir-A'

26 changes: 14 additions & 12 deletions spec/functional/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,33 @@

before :each do
temp_directory = Dir.mktmpdir
Dir.entries(temp_directory).should =~ ['.', '..']
Dir.entries(temp_directory).should =~ %w|. ..|
FileUtils.touch File.join(temp_directory, 'trashfile')
Dir.entries(temp_directory).should =~ ['.', '..', 'trashfile']
Dir.entries(temp_directory).should =~ %w|. .. trashfile|
end

after :each do
FileUtils.rm_rf temp_directory
end

it "install the modules in a temp directory" do
it "install the modules in a temp directory", :type => 'integration' do
output, status = execute_captured("bin/librarian-puppet install --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")

status.should == 0
Dir.entries(temp_directory).should =~ ['.', '..', 'apache', 'ntp', 'trashfile']
Dir.entries(temp_directory).should =~ %w|. .. apache ntp trashfile dnsclient testlps subdir-A|
Dir.entries(File.join(temp_directory, 'subdir-A')).should =~ %w|. .. .git Hello.txt|
end

it "with --clean it cleans the directory before installing the modules in a temp directory" do


it "with --clean it cleans the directory before installing the modules in a temp directory", :type => 'integration' do
output, status = execute_captured("bin/librarian-puppet install --clean --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")

status.should == 0
Dir.entries(temp_directory).should =~ ['.', '..', 'apache', 'ntp']
Dir.entries(temp_directory).should =~ %w|. .. apache ntp dnsclient testlps subdir-A|
end

it "with --verbose it outputs progress messages" do
it "with --verbose it outputs progress messages", :type => 'integration' do
output, status = execute_captured("bin/librarian-puppet install --verbose --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")

status.should == 0
Expand All @@ -57,18 +60,17 @@

before :each do
temp_directory = Dir.mktmpdir
Dir.entries(temp_directory).should =~ ['.', '..']
Dir.entries(temp_directory).should =~ %w|. ..|
FileUtils.touch File.join(temp_directory, 'apache')
Dir.entries(temp_directory).should =~ ['.', '..', 'apache']
Dir.entries(temp_directory).should =~ %w|. .. apache|
end

it 'without clean it should only install ntp' do
it 'without clean it should only install ntp', :type => 'integration' do
output, status = execute_captured("bin/librarian-puppet install --verbose --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
status.should == 0
output.should include('Module apache already installed')
Dir.entries(temp_directory).should =~ ['.', '..', 'apache', 'ntp']
Dir.entries(temp_directory).should =~ %w|. .. apache ntp dnsclient testlps subdir-A|
end

end
end

Expand Down
9 changes: 7 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus

# if ENV['INTEGRATION']
# config.filter_run :type => 'integration'
# else
# config.filter_run_excluding :type => 'integration'
# end

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
Expand All @@ -22,4 +27,4 @@ def execute_captured(command)
condensed = stdout.readlines.join + stderr.readlines.join
[condensed, $?.exitstatus]
end
end
end