vault-tree 0.1.0
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.
- data/.gitignore +26 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +22 -0
- data/README.md +118 -0
- data/Rakefile +17 -0
- data/VagrantFile +30 -0
- data/features/core.feature +44 -0
- data/features/exceptions.feature +41 -0
- data/features/steps/core.steps.rb +168 -0
- data/features/steps/exceptions.steps.rb +103 -0
- data/features/support/env.rb +1 -0
- data/features/world.rb +3 -0
- data/lib/vault-tree.rb +7 -0
- data/lib/vault-tree/config/dependencies.rb +4 -0
- data/lib/vault-tree/config/lib.rb +2 -0
- data/lib/vault-tree/config/path_helpers.rb +49 -0
- data/lib/vault-tree/config/string.rb +25 -0
- data/lib/vault-tree/contract/close_validator.rb +35 -0
- data/lib/vault-tree/contract/contract.rb +85 -0
- data/lib/vault-tree/contract/contract_presenter.rb +27 -0
- data/lib/vault-tree/contract/doorman.rb +112 -0
- data/lib/vault-tree/contract/null_vault.rb +16 -0
- data/lib/vault-tree/contract/open_validator.rb +20 -0
- data/lib/vault-tree/contract/vault.rb +96 -0
- data/lib/vault-tree/exceptions/empty_vault.rb +8 -0
- data/lib/vault-tree/exceptions/fill_attempt_master_password.rb +6 -0
- data/lib/vault-tree/exceptions/invalid_signature.rb +0 -0
- data/lib/vault-tree/exceptions/malformed_json.rb +0 -0
- data/lib/vault-tree/exceptions/missing_external_data.rb +6 -0
- data/lib/vault-tree/exceptions/missing_partner_decryption_key.rb +6 -0
- data/lib/vault-tree/exceptions/missing_passphrase.rb +6 -0
- data/lib/vault-tree/exceptions/non_unique_vault_id.rb +0 -0
- data/lib/vault-tree/exceptions/unsupported_keyword.rb +6 -0
- data/lib/vault-tree/exceptions/vault_does_not_exist.rb +6 -0
- data/lib/vault-tree/exceptions/vault_tree_exception.rb +6 -0
- data/lib/vault-tree/keywords/decryption_key.rb +14 -0
- data/lib/vault-tree/keywords/external_data.rb +13 -0
- data/lib/vault-tree/keywords/keyword.rb +19 -0
- data/lib/vault-tree/keywords/keyword_interpreter.rb +45 -0
- data/lib/vault-tree/keywords/master_passphrase.rb +9 -0
- data/lib/vault-tree/keywords/public_encryption_key.rb +27 -0
- data/lib/vault-tree/keywords/random_number.rb +9 -0
- data/lib/vault-tree/keywords/shared_key.rb +24 -0
- data/lib/vault-tree/keywords/unlocked.rb +9 -0
- data/lib/vault-tree/keywords/vault_contents.rb +13 -0
- data/lib/vault-tree/lock_smith/asymmetric_cipher.rb +31 -0
- data/lib/vault-tree/lock_smith/crypto_hash.rb +11 -0
- data/lib/vault-tree/lock_smith/digital_signature.rb +32 -0
- data/lib/vault-tree/lock_smith/encryption_key_pair.rb +25 -0
- data/lib/vault-tree/lock_smith/null_vault.rb +4 -0
- data/lib/vault-tree/lock_smith/random_number.rb +11 -0
- data/lib/vault-tree/lock_smith/shared_key_pair.rb +12 -0
- data/lib/vault-tree/lock_smith/signing_key_pair.rb +25 -0
- data/lib/vault-tree/lock_smith/symmetric_cipher.rb +25 -0
- data/lib/vault-tree/util/json.rb +16 -0
- data/lib/vault-tree/version.rb +3 -0
- data/spec/app/locksmith/asymmetric_cipher_spec.rb +25 -0
- data/spec/app/locksmith/signing_key_pair_spec.rb +22 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/fixtures/blank_simple_test_contract.json +14 -0
- data/spec/support/fixtures/broken_contract.json +55 -0
- data/spec/support/fixtures/one_two_three-0.5.0.EXP.json +105 -0
- data/spec/support/fixtures/reference_contract.1.0.0.json +227 -0
- data/spec/support/fixtures/simple_test_contract.json +14 -0
- data/support/cookbooks/ark/.gitignore +12 -0
- data/support/cookbooks/ark/.kitchen.yml +34 -0
- data/support/cookbooks/ark/.travis.yml +6 -0
- data/support/cookbooks/ark/Berksfile +9 -0
- data/support/cookbooks/ark/CHANGELOG.md +87 -0
- data/support/cookbooks/ark/CONTRIBUTING.md +257 -0
- data/support/cookbooks/ark/README.md +301 -0
- data/support/cookbooks/ark/Rakefile +36 -0
- data/support/cookbooks/ark/TESTING.md +25 -0
- data/support/cookbooks/ark/Toftfile +15 -0
- data/support/cookbooks/ark/attributes/default.rb +6 -0
- data/support/cookbooks/ark/chefignore +96 -0
- data/support/cookbooks/ark/files/default/foo.tar.gz +0 -0
- data/support/cookbooks/ark/files/default/foo.tbz +0 -0
- data/support/cookbooks/ark/files/default/foo.tgz +0 -0
- data/support/cookbooks/ark/files/default/foo.zip +0 -0
- data/support/cookbooks/ark/files/default/tests/minitest/default_test.rb +0 -0
- data/support/cookbooks/ark/files/default/tests/minitest/support/helpers.rb +0 -0
- data/support/cookbooks/ark/files/default/tests/minitest/test_test.rb +94 -0
- data/support/cookbooks/ark/libraries/default.rb +167 -0
- data/support/cookbooks/ark/metadata.rb +13 -0
- data/support/cookbooks/ark/providers/default.rb +370 -0
- data/support/cookbooks/ark/recipes/default.rb +31 -0
- data/support/cookbooks/ark/recipes/test.rb +138 -0
- data/support/cookbooks/ark/resources/default.rb +54 -0
- data/support/cookbooks/ark/templates/default/add_to_path.sh.erb +1 -0
- data/support/cookbooks/ark/test/support/Gemfile +4 -0
- data/support/cookbooks/build-essential/README.md +24 -0
- data/support/cookbooks/build-essential/metadata.rb +10 -0
- data/support/cookbooks/build-essential/recipes/default.rb +45 -0
- data/support/cookbooks/chruby/.gitignore +15 -0
- data/support/cookbooks/chruby/.kitchen.yml +26 -0
- data/support/cookbooks/chruby/.ruby_version +1 -0
- data/support/cookbooks/chruby/Berksfile +3 -0
- data/support/cookbooks/chruby/Gemfile +7 -0
- data/support/cookbooks/chruby/LICENSE +14 -0
- data/support/cookbooks/chruby/README.md +92 -0
- data/support/cookbooks/chruby/Rakefile +7 -0
- data/support/cookbooks/chruby/Thorfile +6 -0
- data/support/cookbooks/chruby/Vagrantfile +86 -0
- data/support/cookbooks/chruby/attributes/default.rb +10 -0
- data/support/cookbooks/chruby/chefignore +96 -0
- data/support/cookbooks/chruby/metadata.rb +11 -0
- data/support/cookbooks/chruby/recipes/default.rb +43 -0
- data/support/cookbooks/chruby/recipes/system.rb +25 -0
- data/support/cookbooks/chruby/templates/default/chruby.sh.erb +22 -0
- data/support/cookbooks/chruby/test/integration/default/bash/embedded_test.sh +1 -0
- data/support/cookbooks/git/.gitignore +14 -0
- data/support/cookbooks/git/.kitchen.yml +46 -0
- data/support/cookbooks/git/Berksfile +8 -0
- data/support/cookbooks/git/CHANGELOG.md +87 -0
- data/support/cookbooks/git/CONTRIBUTING +29 -0
- data/support/cookbooks/git/Gemfile +3 -0
- data/support/cookbooks/git/LICENSE +201 -0
- data/support/cookbooks/git/README.md +115 -0
- data/support/cookbooks/git/TESTING.md +25 -0
- data/support/cookbooks/git/attributes/default.rb +40 -0
- data/support/cookbooks/git/metadata.rb +35 -0
- data/support/cookbooks/git/recipes/default.rb +53 -0
- data/support/cookbooks/git/recipes/server.rb +58 -0
- data/support/cookbooks/git/recipes/source.rb +49 -0
- data/support/cookbooks/git/recipes/windows.rb +37 -0
- data/support/cookbooks/git/templates/default/git-xinetd.d.erb +10 -0
- data/support/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +2 -0
- data/support/cookbooks/git/templates/default/sv-git-daemon-run.erb +3 -0
- data/support/cookbooks/install_ruby/README.md +3 -0
- data/support/cookbooks/install_ruby/metadata.rb +10 -0
- data/support/cookbooks/install_ruby/recipes/default.rb +14 -0
- data/support/cookbooks/ruby_build/.gitignore +6 -0
- data/support/cookbooks/ruby_build/.kitchen.yml +31 -0
- data/support/cookbooks/ruby_build/.travis.yml +4 -0
- data/support/cookbooks/ruby_build/Berksfile +10 -0
- data/support/cookbooks/ruby_build/CHANGELOG.md +72 -0
- data/support/cookbooks/ruby_build/Gemfile +14 -0
- data/support/cookbooks/ruby_build/README.md +338 -0
- data/support/cookbooks/ruby_build/Rakefile +21 -0
- data/support/cookbooks/ruby_build/attributes/default.rb +67 -0
- data/support/cookbooks/ruby_build/chefignore +53 -0
- data/support/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +40 -0
- data/support/cookbooks/ruby_build/metadata.rb +18 -0
- data/support/cookbooks/ruby_build/providers/ruby.rb +88 -0
- data/support/cookbooks/ruby_build/recipes/default.rb +69 -0
- data/support/cookbooks/ruby_build/resources/ruby.rb +33 -0
- data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/metadata.rb +10 -0
- data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/recipes/default.rb +59 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/_verify_tests.bash +33 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.8.7.bats +29 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.2.bats +18 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.3.bats +18 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_2.0.0.bats +18 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_jruby.bats +20 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_rbx.bats +18 -0
- data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_ree.bats +19 -0
- data/support/cookbooks/ruby_build/test/integration/installation/bats/installation.bats +6 -0
- data/support/scripts/libsodium_ubuntu.sh +80 -0
- data/support/tasks/.gitkeep +0 -0
- data/support/tasks/libsodium_install.rb +57 -0
- data/vault-tree.gemspec +26 -0
- metadata +305 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
|
|
3
|
+
@cookbook = "ark"
|
|
4
|
+
|
|
5
|
+
desc "Runs foodcritc linter"
|
|
6
|
+
task :foodcritic do
|
|
7
|
+
if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
|
|
8
|
+
sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic}, @cookbook)
|
|
9
|
+
prepare_foodcritic_sandbox(sandbox)
|
|
10
|
+
|
|
11
|
+
sh "foodcritic --epic-fail any #{File.dirname(sandbox)} -t ~FC017"
|
|
12
|
+
else
|
|
13
|
+
puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
task :default => 'foodcritic'
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def prepare_foodcritic_sandbox(sandbox)
|
|
22
|
+
files = %w{*.md *.rb attributes definitions files providers
|
|
23
|
+
recipes resources templates}
|
|
24
|
+
|
|
25
|
+
rm_rf sandbox
|
|
26
|
+
mkdir_p sandbox
|
|
27
|
+
cp_r Dir.glob("{#{files.join(',')}}"), sandbox
|
|
28
|
+
puts "\n\n"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
require 'kitchen/rake_tasks'
|
|
33
|
+
Kitchen::RakeTasks.new
|
|
34
|
+
rescue LoadError
|
|
35
|
+
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
|
|
36
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
|
|
2
|
+
|
|
3
|
+
1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
|
|
4
|
+
2. You must have Vagrant 1.1 installed.
|
|
5
|
+
3. You must have a "sane" Ruby 1.9.3 environment.
|
|
6
|
+
|
|
7
|
+
Once the above requirements are met, install the additional requirements:
|
|
8
|
+
|
|
9
|
+
Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
|
|
10
|
+
|
|
11
|
+
vagrant plugin install vagrant-berkshelf
|
|
12
|
+
gem install berkshelf
|
|
13
|
+
|
|
14
|
+
Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
|
|
15
|
+
|
|
16
|
+
gem install test-kitchen --pre
|
|
17
|
+
|
|
18
|
+
Install the Vagrant driver for Test Kitchen.
|
|
19
|
+
|
|
20
|
+
gem install kitchen-vagrant
|
|
21
|
+
|
|
22
|
+
Once the above are installed, you should be able to run Test Kitchen:
|
|
23
|
+
|
|
24
|
+
kitchen list
|
|
25
|
+
kitchen test
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'toft'
|
|
3
|
+
|
|
4
|
+
include Toft
|
|
5
|
+
|
|
6
|
+
n1 = create_node "n1", {:ip => '192.168.20.2'}
|
|
7
|
+
|
|
8
|
+
n1.start
|
|
9
|
+
|
|
10
|
+
n1.run_chef [ "recipe[chef_handler]", "recipe[minitest-handler::recipes]", "recipe[ark::test]" ]
|
|
11
|
+
|
|
12
|
+
n1.stop
|
|
13
|
+
|
|
14
|
+
n1.destroy
|
|
15
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Put files/directories that should be ignored in this file when uploading
|
|
2
|
+
# or sharing to the community site.
|
|
3
|
+
# Lines that start with '# ' are comments.
|
|
4
|
+
|
|
5
|
+
# OS generated files #
|
|
6
|
+
######################
|
|
7
|
+
.DS_Store
|
|
8
|
+
Icon?
|
|
9
|
+
nohup.out
|
|
10
|
+
ehthumbs.db
|
|
11
|
+
Thumbs.db
|
|
12
|
+
|
|
13
|
+
# SASS #
|
|
14
|
+
########
|
|
15
|
+
.sass-cache
|
|
16
|
+
|
|
17
|
+
# EDITORS #
|
|
18
|
+
###########
|
|
19
|
+
\#*
|
|
20
|
+
.#*
|
|
21
|
+
*~
|
|
22
|
+
*.sw[a-z]
|
|
23
|
+
*.bak
|
|
24
|
+
REVISION
|
|
25
|
+
TAGS*
|
|
26
|
+
tmtags
|
|
27
|
+
*_flymake.*
|
|
28
|
+
*_flymake
|
|
29
|
+
*.tmproj
|
|
30
|
+
.project
|
|
31
|
+
.settings
|
|
32
|
+
mkmf.log
|
|
33
|
+
|
|
34
|
+
## COMPILED ##
|
|
35
|
+
##############
|
|
36
|
+
a.out
|
|
37
|
+
*.o
|
|
38
|
+
*.pyc
|
|
39
|
+
*.so
|
|
40
|
+
*.com
|
|
41
|
+
*.class
|
|
42
|
+
*.dll
|
|
43
|
+
*.exe
|
|
44
|
+
*/rdoc/
|
|
45
|
+
|
|
46
|
+
# Testing #
|
|
47
|
+
###########
|
|
48
|
+
.watchr
|
|
49
|
+
.rspec
|
|
50
|
+
spec/*
|
|
51
|
+
spec/fixtures/*
|
|
52
|
+
test/*
|
|
53
|
+
features/*
|
|
54
|
+
Guardfile
|
|
55
|
+
Procfile
|
|
56
|
+
|
|
57
|
+
# SCM #
|
|
58
|
+
#######
|
|
59
|
+
.git
|
|
60
|
+
*/.git
|
|
61
|
+
.gitignore
|
|
62
|
+
.gitmodules
|
|
63
|
+
.gitconfig
|
|
64
|
+
.gitattributes
|
|
65
|
+
.svn
|
|
66
|
+
*/.bzr/*
|
|
67
|
+
*/.hg/*
|
|
68
|
+
*/.svn/*
|
|
69
|
+
|
|
70
|
+
# Berkshelf #
|
|
71
|
+
#############
|
|
72
|
+
Berksfile
|
|
73
|
+
Berksfile.lock
|
|
74
|
+
cookbooks/*
|
|
75
|
+
tmp
|
|
76
|
+
|
|
77
|
+
# Cookbooks #
|
|
78
|
+
#############
|
|
79
|
+
CONTRIBUTING
|
|
80
|
+
CHANGELOG*
|
|
81
|
+
|
|
82
|
+
# Strainer #
|
|
83
|
+
############
|
|
84
|
+
Colanderfile
|
|
85
|
+
Strainerfile
|
|
86
|
+
.colander
|
|
87
|
+
.strainer
|
|
88
|
+
|
|
89
|
+
# Vagrant #
|
|
90
|
+
###########
|
|
91
|
+
.vagrant
|
|
92
|
+
Vagrantfile
|
|
93
|
+
|
|
94
|
+
# Travis #
|
|
95
|
+
##########
|
|
96
|
+
.travis.yml
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require 'minitest/spec'
|
|
2
|
+
|
|
3
|
+
describe_recipe 'ark::test' do
|
|
4
|
+
|
|
5
|
+
# It's often convenient to load these includes in a separate
|
|
6
|
+
# helper along with
|
|
7
|
+
# your own helper methods, but here we just include them directly:
|
|
8
|
+
include MiniTest::Chef::Assertions
|
|
9
|
+
include MiniTest::Chef::Context
|
|
10
|
+
include MiniTest::Chef::Resources
|
|
11
|
+
|
|
12
|
+
it "installed the unzip package" do
|
|
13
|
+
package("unzip").must_be_installed
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if RUBY_PLATFORM =~ /freebsd/
|
|
17
|
+
it "installs the gnu tar package on freebsc" do
|
|
18
|
+
package("gtar").must_be_installed
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "puts an ark in the desired directory w/out symlinks" do
|
|
23
|
+
directory("/usr/local/test_put").must_exist
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "dumps the correct files into place with correct owner and group" do
|
|
27
|
+
file("/usr/local/foo_dump/foo1.txt").must_have(:owner, "foobarbaz").and(:group, "foobarbaz")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "cherrypicks the mysql connector and set the correct owner and group" do
|
|
31
|
+
file("/usr/local/foo_cherry_pick/foo1.txt").must_have(:owner, "foobarbaz").and(:group, "foobarbaz")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "cherrypicks the file from a zip" do
|
|
35
|
+
file("/usr/local/foo_cherry_pick_from_zip/foo1.txt").must_exist
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "creates directory and symlink properly for the full ark install" do
|
|
39
|
+
directory("/usr/local/foo-2").must_have(:owner, "foobarbaz").and(:group, "foobarbaz")
|
|
40
|
+
link("/usr/local/foo").must_exist.with(:link_type, :symbolic).and(:to, "/usr/local/foo-2")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "symlinks multiple binary commands" do
|
|
44
|
+
link("/usr/local/bin/do_foo").must_exist.with(:link_type, :symbolic).and(:to, "/usr/local/foo-2/bin/do_foo")
|
|
45
|
+
link("/usr/local/bin/do_more_foo").must_exist.with(:link_type, :symbolic).and(:to, "/usr/local/foo-2/bin/do_more_foo")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "appends to the environment PATH" do
|
|
49
|
+
unless RUBY_PLATFORM =~ /freebsd/
|
|
50
|
+
file("/etc/profile.d/foo_append_env.sh").must_include '/usr/local/foo_append_env-7.0.26/bin'
|
|
51
|
+
|
|
52
|
+
bin_path_present = !ENV['PATH'].scan( '/usr/local/foo_append_env-7.0.26/bin').empty?
|
|
53
|
+
assert bin_path_present
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "doesn't strip top-level directory if specified" do
|
|
58
|
+
directory( "/usr/local/foo_dont_strip/foo_sub").must_exist
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "does strip for zip file" do
|
|
62
|
+
file("/usr/local/foo_zip_strip/foo1.txt").must_exist
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
it "successfully compiles haproxy" do
|
|
67
|
+
file("/usr/local/haproxy-1.5/haproxy").must_exist
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
unless RUBY_PLATFORM =~ /freebsd/
|
|
71
|
+
it "installs haproxy binary" do
|
|
72
|
+
file("/usr/local/sbin/haproxy").must_exist
|
|
73
|
+
directory("/usr/local/doc/haproxy").must_exist
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "creates an alternate prefix_bin" do
|
|
78
|
+
link("/opt/bin/do_foo").must_exist.with(:link_type, :symbolic).and(:to, "/opt/foo_alt_bin-3/bin/do_foo")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "properly unpacks .tbz and .tgz archives" do
|
|
82
|
+
file("/usr/local/foo_tbz/foo1.txt").must_exist
|
|
83
|
+
file("/usr/local/foo_tgz/foo1.txt").must_exist
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "sends notification when resource updated" do
|
|
87
|
+
file("/tmp/foobarbaz/notification_successful.txt").must_exist
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "uses autogen.sh to generate configure script" do
|
|
91
|
+
file("/usr/local/test_autogen-1/configure").must_exist
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# libs
|
|
2
|
+
|
|
3
|
+
module Opscode
|
|
4
|
+
module Ark
|
|
5
|
+
module ProviderHelpers
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def unpack_type
|
|
9
|
+
case parse_file_extension
|
|
10
|
+
when /tar.gz|tgz/ then "tar_xzf"
|
|
11
|
+
when /tar.bz2|tbz/ then "tar_xjf"
|
|
12
|
+
when /zip|war|jar/ then "unzip"
|
|
13
|
+
else raise "Don't know how to expand #{new_resource.url}"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def parse_file_extension
|
|
18
|
+
if new_resource.extension.nil?
|
|
19
|
+
# purge any trailing redirect
|
|
20
|
+
url = new_resource.url.clone
|
|
21
|
+
url =~ /^https?:\/\/.*(.gz|bz2|bin|zip|jar|tgz|tbz)(\/.*\/)/
|
|
22
|
+
url.gsub!($2, '') unless $2.nil?
|
|
23
|
+
# remove tailing query string
|
|
24
|
+
release_basename = ::File.basename(url.gsub(/\?.*\z/, '')).gsub(/-bin\b/, '')
|
|
25
|
+
# (\?.*)? accounts for a trailing querystring
|
|
26
|
+
Chef::Log.debug("DEBUG: release_basename is #{release_basename}")
|
|
27
|
+
release_basename =~ %r{^(.+?)\.(tar\.gz|tar\.bz2|zip|war|jar|tgz|tbz)(\?.*)?}
|
|
28
|
+
Chef::Log.debug("DEBUG: file_extension is #{$2}")
|
|
29
|
+
new_resource.extension = $2
|
|
30
|
+
end
|
|
31
|
+
new_resource.extension
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def unpack_command
|
|
35
|
+
case unpack_type
|
|
36
|
+
when "tar_xzf"
|
|
37
|
+
cmd = node['ark']['tar']
|
|
38
|
+
cmd = cmd + " xzf "
|
|
39
|
+
cmd = cmd + new_resource.release_file
|
|
40
|
+
cmd = cmd + tar_strip_args
|
|
41
|
+
when "tar_xjf"
|
|
42
|
+
cmd = node['ark']['tar']
|
|
43
|
+
cmd = cmd + " xjf "
|
|
44
|
+
cmd = cmd + " #{new_resource.release_file}"
|
|
45
|
+
cmd = cmd + tar_strip_args
|
|
46
|
+
when "unzip"
|
|
47
|
+
cmd = unzip_command
|
|
48
|
+
end
|
|
49
|
+
Chef::Log.debug("DEBUG: cmd: #{cmd}")
|
|
50
|
+
cmd
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def unzip_command
|
|
54
|
+
if new_resource.strip_leading_dir
|
|
55
|
+
require 'tmpdir'
|
|
56
|
+
tmpdir = Dir.mktmpdir
|
|
57
|
+
cmd = "unzip -q -u -o #{new_resource.release_file} -d #{tmpdir}"
|
|
58
|
+
cmd = cmd + "&& rsync -a #{tmpdir}/*/ #{new_resource.path}"
|
|
59
|
+
cmd = cmd + "&& rm -rf #{tmpdir}"
|
|
60
|
+
else
|
|
61
|
+
cmd = "unzip -q -u -o #{new_resource.release_file} -d #{new_resource.path}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def dump_command
|
|
66
|
+
case unpack_type
|
|
67
|
+
when "tar_xzf", "tar_xjf"
|
|
68
|
+
cmd = "tar -mxf \"#{new_resource.release_file}\" -C \"#{new_resource.path}\""
|
|
69
|
+
when "unzip"
|
|
70
|
+
cmd = "unzip -j -q -u -o \"#{new_resource.release_file}\" -d \"#{new_resource.path}\""
|
|
71
|
+
end
|
|
72
|
+
Chef::Log.debug("DEBUG: cmd: #{cmd}")
|
|
73
|
+
cmd
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def cherry_pick_command
|
|
77
|
+
cmd = node['ark']['tar']
|
|
78
|
+
|
|
79
|
+
case unpack_type
|
|
80
|
+
when "tar_xzf"
|
|
81
|
+
cmd = cmd + " xzf "
|
|
82
|
+
cmd = cmd + " #{new_resource.release_file}"
|
|
83
|
+
cmd = cmd + " -C"
|
|
84
|
+
cmd = cmd + " #{new_resource.path}"
|
|
85
|
+
cmd = cmd + " #{new_resource.creates}"
|
|
86
|
+
cmd = cmd + tar_strip_args
|
|
87
|
+
when "tar_xjf"
|
|
88
|
+
cmd = cmd + "xjf #{new_resource.release_file}"
|
|
89
|
+
cmd = cmd + "-C #{new_resource.path} #{new_resource.creates}"
|
|
90
|
+
cmd = cmd + tar_strip_args
|
|
91
|
+
when "unzip"
|
|
92
|
+
cmd = "unzip -t #{new_resource.release_file} \"*/#{new_resource.creates}\" ; stat=$? ;"
|
|
93
|
+
cmd = cmd + "if [ $stat -eq 11 ] ; then "
|
|
94
|
+
cmd = cmd + "unzip -j -o #{new_resource.release_file} \"#{new_resource.creates}\" -d #{new_resource.path} ;"
|
|
95
|
+
cmd = cmd + "elif [ $stat -ne 0 ] ; then false ;"
|
|
96
|
+
cmd = cmd + "else "
|
|
97
|
+
cmd = cmd + "unzip -j -o #{new_resource.release_file} \"*/#{new_resource.creates}\" -d #{new_resource.path} ;"
|
|
98
|
+
cmd = cmd + "fi"
|
|
99
|
+
end
|
|
100
|
+
Chef::Log.debug("DEBUG: cmd: #{cmd}")
|
|
101
|
+
cmd
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def set_paths
|
|
105
|
+
release_ext = parse_file_extension
|
|
106
|
+
prefix_bin = new_resource.prefix_bin.nil? ? new_resource.run_context.node['ark']['prefix_bin'] : new_resource.prefix_bin
|
|
107
|
+
prefix_root = new_resource.prefix_root.nil? ? new_resource.run_context.node['ark']['prefix_root'] : new_resource.prefix_root
|
|
108
|
+
if new_resource.prefix_home.nil?
|
|
109
|
+
default_home_dir = ::File.join(new_resource.run_context.node['ark']['prefix_home'], new_resource.name)
|
|
110
|
+
else
|
|
111
|
+
default_home_dir = ::File.join(new_resource.prefix_home, new_resource.name)
|
|
112
|
+
end
|
|
113
|
+
# set effective paths
|
|
114
|
+
new_resource.prefix_bin = prefix_bin
|
|
115
|
+
new_resource.version ||= "1" # initialize to one if nil
|
|
116
|
+
new_resource.path = ::File.join(prefix_root, "#{new_resource.name}-#{new_resource.version}")
|
|
117
|
+
new_resource.home_dir ||= default_home_dir
|
|
118
|
+
Chef::Log.debug("path is #{new_resource.path}")
|
|
119
|
+
new_resource.release_file = ::File.join(Chef::Config[:file_cache_path], "#{new_resource.name}.#{release_ext}")
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def set_put_paths
|
|
123
|
+
release_ext = parse_file_extension
|
|
124
|
+
path = new_resource.path.nil? ? new_resource.run_context.node['ark']['prefix_root'] : new_resource.path
|
|
125
|
+
new_resource.path = ::File.join(path, new_resource.name)
|
|
126
|
+
Chef::Log.debug("DEBUG: path is #{new_resource.path}")
|
|
127
|
+
new_resource.release_file = ::File.join(Chef::Config[:file_cache_path], "#{new_resource.name}.#{release_ext}")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def set_dump_paths
|
|
131
|
+
release_ext = parse_file_extension
|
|
132
|
+
new_resource.release_file = ::File.join(Chef::Config[:file_cache_path], "#{new_resource.name}.#{release_ext}")
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def set_apache_url(url_ref)
|
|
136
|
+
raise "Missing required resource attribute url" unless url_ref
|
|
137
|
+
url_ref.gsub!(/:name:/, name.to_s)
|
|
138
|
+
url_ref.gsub!(/:version:/, version.to_s)
|
|
139
|
+
url_ref.gsub!(/:apache_mirror:/, node['install_from']['apache_mirror'])
|
|
140
|
+
url_ref
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def tar_strip_args
|
|
144
|
+
new_resource.strip_leading_dir ? " --strip-components=1" : ""
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# def unpacked?(path)
|
|
148
|
+
# if new_resource.creates
|
|
149
|
+
# full_path = ::File.join(new_resource.path, new_resource.creates)
|
|
150
|
+
# else
|
|
151
|
+
# full_path = path
|
|
152
|
+
# end
|
|
153
|
+
# if ::File.directory? full_path
|
|
154
|
+
# if ::File.stat(full_path).nlink == 2
|
|
155
|
+
# false
|
|
156
|
+
# else
|
|
157
|
+
# true
|
|
158
|
+
# end
|
|
159
|
+
# elsif ::File.exists? full_path
|
|
160
|
+
# true
|
|
161
|
+
# else
|
|
162
|
+
# false
|
|
163
|
+
# end
|
|
164
|
+
# end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|