├── .github ├── CODEOWNERS ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .rubocop.yml ├── TESTING.md ├── CONTRIBUTING.md ├── .delivery └── project.toml ├── Berksfile ├── test ├── cookbooks │ └── test │ │ ├── metadata.rb │ │ └── recipes │ │ └── default.rb └── integration │ └── resources │ └── default_test.rb ├── spec ├── spec_helper.rb └── unit │ └── recipes │ └── default_spec.rb ├── Gemfile ├── kitchen.yml ├── metadata.rb ├── .gitignore ├── recipes └── default.rb ├── .travis.yml ├── kitchen.dokken.yml ├── chefignore ├── resources ├── package.rb └── extract.rb ├── CHANGELOG.md ├── README.md └── LICENSE /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @chef-cookbooks/cookbook_engineering_team 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # rubocop todo 2 | 3 | Lint/ParenthesesAsGroupedExpression: 4 | Exclude: 5 | - 'resources/extract.rb' 6 | -------------------------------------------------------------------------------- /TESTING.md: -------------------------------------------------------------------------------- 1 | Please refer to 2 | https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please refer to 2 | https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD 3 | -------------------------------------------------------------------------------- /.delivery/project.toml: -------------------------------------------------------------------------------- 1 | remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml" 2 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'test', path: 'test/cookbooks/test' 7 | end 8 | -------------------------------------------------------------------------------- /test/cookbooks/test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'test' 2 | maintainer 'Community Cookbook Team' 3 | maintainer_email 'cookbooks@chef.io' 4 | license 'Apache-2.0' 5 | description 'Installs/Configures test' 6 | version '0.1.0' 7 | 8 | depends 'tar' 9 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | 4 | RSpec.configure do |config| 5 | config.color = true # Use color in STDOUT 6 | config.formatter = :documentation # Use the specified formatter 7 | config.log_level = :error # Avoid deprecation notice SPAM 8 | end 9 | -------------------------------------------------------------------------------- /spec/unit/recipes/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'default recipe on ubuntu 16.04' do 4 | let(:runner) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') } 5 | let(:chef_run) { runner.converge('tar::default') } 6 | 7 | it 'converges successfully' do 8 | expect { :chef_run }.to_not raise_error 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # This gemfile provides additional gems for testing and releasing this cookbook 2 | # It is meant to be installed on top of ChefDK which provides the majority 3 | # of the necessary gems for testing this cookbook 4 | # 5 | # Run 'chef exec bundle install' to install these dependencies 6 | 7 | source 'https://rubygems.org' 8 | 9 | gem 'community_cookbook_releaser' 10 | -------------------------------------------------------------------------------- /kitchen.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: vagrant 3 | 4 | provisioner: 5 | name: chef_zero 6 | deprecations_as_errors: true 7 | 8 | verifier: 9 | name: inspec 10 | 11 | platforms: 12 | - name: amazonlinux 13 | driver_config: 14 | box: mvbcoding/awslinux 15 | - name: centos-6 16 | - name: centos-7 17 | - name: debian-8 18 | - name: debian-9 19 | - name: fedora-28 20 | - name: opensuse-leap-42.2 21 | - name: ubuntu-14.04 22 | - name: ubuntu-16.04 23 | - name: ubuntu-18.04 24 | - name: freebsd-11 25 | 26 | suites: 27 | - name: resources 28 | run_list: 29 | - recipe[test] 30 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | [Describe what this change achieves] 4 | 5 | ### Issues Resolved 6 | 7 | [List any existing issues this PR resolves] 8 | 9 | ### Check List 10 | 11 | - [ ] All tests pass. See 12 | - [ ] New functionality includes testing. 13 | - [ ] New functionality has been documented in the README if applicable 14 | - [ ] All commits have been signed for the Developer Certificate of Origin. See 15 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'tar' 2 | maintainer 'Chef Software, Inc.' 3 | maintainer_email 'cookbooks@chef.io' 4 | license 'Apache-2.0' 5 | description 'Installs tar and two resources to manage remote tar packages' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '2.2.0' 8 | 9 | %w(ubuntu debian redhat centos suse opensuse opensuseleap scientific oracle amazon zlinux freebsd).each do |os| 10 | supports os 11 | end 12 | 13 | source_url 'https://github.com/chef-cookbooks/tar' 14 | issues_url 'https://github.com/chef-cookbooks/tar/issues' 15 | chef_version '>= 12.7' if respond_to?(:chef_version) 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.rbc 2 | .config 3 | coverage 4 | InstalledFiles 5 | lib/bundler/man 6 | pkg 7 | rdoc 8 | spec/reports 9 | test/tmp 10 | test/version_tmp 11 | tmp 12 | _Store 13 | *~ 14 | *# 15 | .#* 16 | \#*# 17 | .*.sw[a-z] 18 | *.un~ 19 | *.tmp 20 | *.bk 21 | *.bkup 22 | 23 | # ruby/bundler files 24 | .ruby-version 25 | .ruby-gemset 26 | .rvmrc 27 | Gemfile.lock 28 | .bundle 29 | *.gem 30 | 31 | # YARD artifacts 32 | .yardoc 33 | _yardoc 34 | doc/ 35 | .idea 36 | 37 | # chef stuff 38 | Berksfile.lock 39 | .kitchen 40 | kitchen.local.yml 41 | vendor/ 42 | .coverage/ 43 | .zero-knife.rb 44 | Policyfile.lock.json 45 | 46 | # vagrant stuff 47 | .vagrant/ 48 | .vagrant.d/ 49 | .kitchen/ 50 | -------------------------------------------------------------------------------- /test/cookbooks/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: test 3 | # Recipe:: default 4 | # 5 | # Copyright:: 2016-2017, Chef Software, Inc. 6 | 7 | apt_update 'update' 8 | 9 | include_recipe 'tar::default' 10 | build_essential 'install compilation tools' 11 | 12 | package 'ncurses-devel' if platform_family?('suse') # needed for nano compile 13 | 14 | tar_package 'https://www.nano-editor.org/dist/v2.8/nano-2.8.7.tar.gz' do 15 | prefix '/usr/local' 16 | creates '/usr/local/bin/nano' 17 | end 18 | 19 | tar_extract 'https://www.nano-editor.org/dist/v2.8/nano-2.8.7.tar.gz' do 20 | target_dir '/usr/local/nano_tar_extract' 21 | creates '/usr/local/nano_tar_extract/configure' 22 | tar_flags ['-P', '--strip-components 1'] 23 | end 24 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: tar 3 | # Recipe:: default 4 | # 5 | # Author:: Nathan L Smith () 6 | # 7 | # Copyright:: 2011, Cramer Development, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | package 'tar' unless platform_family?('freebsd') 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Cookbook version 2 | [Version of the cookbook where you are encountering the issue] 3 | 4 | ### Chef-client version 5 | [Version of chef-client in your environment] 6 | 7 | ### Platform Details 8 | [Operating system distribution and release version. Cloud provider if running in the cloud] 9 | 10 | ### Scenario: 11 | [What you are trying to achieve and you can't?] 12 | 13 | ### Steps to Reproduce: 14 | [If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?] 15 | 16 | ### Expected Result: 17 | [What are you expecting to happen as the consequence of above reproduction steps?] 18 | 19 | ### Actual Result: 20 | [What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.] 21 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | addons: 2 | apt: 3 | sources: 4 | - chef-current-xenial 5 | packages: 6 | - chef-workstation 7 | 8 | # Don't `bundle install` which takes about 1.5 mins 9 | install: echo "skip bundle install" 10 | 11 | env: 12 | - CHEF_LICENSE=accept 13 | 14 | branches: 15 | only: 16 | - master 17 | 18 | services: docker 19 | 20 | env: 21 | matrix: 22 | - INSTANCE=resources-centos-6 23 | - INSTANCE=resources-centos-7 24 | - INSTANCE=resources-debian-8 25 | - INSTANCE=resources-debian-9 26 | - INSTANCE=resources-fedora-latest 27 | - INSTANCE=resources-opensuse-leap 28 | - INSTANCE=resources-ubuntu-1604 29 | 30 | before_script: 31 | - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) 32 | - eval "$(chef shell-init bash)" 33 | - chef --version 34 | - cookstyle --version 35 | - foodcritic --version 36 | 37 | script: KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen verify ${INSTANCE} 38 | 39 | matrix: 40 | include: 41 | - script: 42 | - chef exec delivery local all 43 | env: 44 | - UNIT_AND_LINT=1 45 | - CHEF_LICENSE=accept 46 | -------------------------------------------------------------------------------- /test/integration/resources/default_test.rb: -------------------------------------------------------------------------------- 1 | describe 'tar recipe' do 2 | it 'installs tar' do 3 | command('tar --help') do 4 | its('exit_status') { should eq 0 } 5 | end 6 | end 7 | end 8 | 9 | describe 'resource tar_package' do 10 | it 'creates a source directory to extract to if one doesn\'t exist.' do 11 | directory('/usr/local/src') do 12 | it { should exist } 13 | end 14 | end 15 | 16 | it 'downloads the archive file to the source directory.' do 17 | file('/usr/local/src/nano-2.8.7.tar.gz') do 18 | it { should exist } 19 | end 20 | end 21 | 22 | it 'extracts the contents of the archive file.' do 23 | directory('/usr/local/src/nano-2.8.7') do 24 | it { should exist } 25 | end 26 | end 27 | 28 | it 'compiles and install the executable.' do 29 | file('/usr/local/bin/nano') do 30 | it { should exist } 31 | end 32 | end 33 | end 34 | 35 | describe 'resource tar_extract' do 36 | it 'creates a target directory to extract to if one doesn\'t exist.' do 37 | directory('/usr/local/nano_tar_extract') do 38 | it { should exist } 39 | end 40 | end 41 | 42 | it 'extracts the contents of the archive file.' do 43 | file('/usr/local/nano_tar_extract/Makefile.am') do 44 | it { should exist } 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /kitchen.dokken.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: dokken 3 | privileged: true # because Docker and SystemD/Upstart 4 | chef_version: <%= ENV['CHEF_VERSION'] || 'current' %> 5 | 6 | transport: 7 | name: dokken 8 | 9 | provisioner: 10 | name: dokken 11 | deprecations_as_errors: true 12 | 13 | verifier: 14 | name: inspec 15 | 16 | platforms: 17 | - name: amazonlinux 18 | driver: 19 | image: dokken/amazonlinux 20 | pid_one_command: /sbin/init 21 | 22 | - name: debian-8 23 | driver: 24 | image: dokken/debian-8 25 | pid_one_command: /bin/systemd 26 | intermediate_instructions: 27 | - RUN /usr/bin/apt-get update 28 | 29 | - name: debian-9 30 | driver: 31 | image: dokken/debian-9 32 | pid_one_command: /bin/systemd 33 | intermediate_instructions: 34 | - RUN /usr/bin/apt-get update 35 | 36 | - name: centos-6 37 | driver: 38 | image: dokken/centos-6 39 | pid_one_command: /sbin/init 40 | 41 | - name: centos-7 42 | driver: 43 | image: dokken/centos-7 44 | pid_one_command: /usr/lib/systemd/systemd 45 | 46 | - name: fedora-latest 47 | driver: 48 | image: dokken/fedora-latest 49 | pid_one_command: /usr/lib/systemd/systemd 50 | 51 | - name: ubuntu-14.04 52 | driver: 53 | image: dokken/ubuntu-14.04 54 | pid_one_command: /sbin/init 55 | intermediate_instructions: 56 | - RUN /usr/bin/apt-get update 57 | 58 | - name: ubuntu-16.04 59 | driver: 60 | image: dokken/ubuntu-16.04 61 | pid_one_command: /bin/systemd 62 | intermediate_instructions: 63 | - RUN /usr/bin/apt-get update 64 | 65 | - name: opensuse-leap 66 | driver: 67 | image: dokken/opensuse-leap 68 | pid_one_command: /bin/systemd 69 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # to a chef-server or supermarket. 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 | examples/* 55 | Guardfile 56 | Procfile 57 | kitchen* 58 | .rubocop.yml 59 | spec/* 60 | Rakefile 61 | .travis.yml 62 | .foodcritic 63 | .codeclimate.yml 64 | 65 | # SCM # 66 | ####### 67 | .git 68 | */.git 69 | .gitignore 70 | .gitmodules 71 | .gitconfig 72 | .gitattributes 73 | .svn 74 | */.bzr/* 75 | */.hg/* 76 | */.svn/* 77 | 78 | # Berkshelf # 79 | ############# 80 | Berksfile 81 | Berksfile.lock 82 | cookbooks/* 83 | tmp 84 | 85 | # Policyfile # 86 | ############## 87 | Policyfile.rb 88 | Policyfile.lock.json 89 | 90 | # Cookbooks # 91 | ############# 92 | CONTRIBUTING* 93 | CHANGELOG* 94 | TESTING* 95 | 96 | # Strainer # 97 | ############ 98 | Colanderfile 99 | Strainerfile 100 | .colander 101 | .strainer 102 | 103 | # Vagrant # 104 | ########### 105 | .vagrant 106 | Vagrantfile 107 | -------------------------------------------------------------------------------- /resources/package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: tar 3 | # Resource:: package 4 | # 5 | # Author:: Nathan L Smith () 6 | # 7 | # Copyright:: 2011, Cramer Development, Inc. 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | property :source, String, name_property: true 23 | property :headers, Hash, default: {} 24 | property :prefix, String 25 | property :source_directory, String, default: '/usr/local/src' 26 | property :creates, String 27 | property :tar_binary, String, default: 'tar' 28 | property :configure_flags, Array, default: [] 29 | property :archive_name, String 30 | property :headers, Hash 31 | property :use_etag, [true, false], default: true 32 | property :use_last_modified, [true, false], default: true 33 | property :atomic_update, [true, false], default: true 34 | property :force_unlink, [true, false], default: false 35 | property :manage_symlink_source, [true, false] 36 | 37 | action :install do 38 | r = new_resource 39 | basename = r.archive_name || ::File.basename(r.name) 40 | dirname = basename.chomp('.tar.gz') # Assuming .tar.gz 41 | src_dir = r.source_directory 42 | 43 | directory src_dir do 44 | recursive true 45 | end 46 | 47 | remote_file basename do 48 | source r.name 49 | path "#{src_dir}/#{basename}" 50 | backup false 51 | headers r.headers unless r.headers.nil? 52 | use_etag r.use_etag 53 | use_last_modified r.use_last_modified 54 | atomic_update r.atomic_update 55 | force_unlink r.force_unlink 56 | manage_symlink_source r.manage_symlink_source 57 | action :create_if_missing 58 | end 59 | 60 | execute "extract #{basename}" do 61 | command "#{r.tar_binary} xfz #{basename}" 62 | cwd src_dir 63 | creates "#{src_dir}/#{dirname}" 64 | end 65 | 66 | execute "compile & install #{dirname}" do 67 | flags = [r.prefix ? "--prefix=#{r.prefix}" : nil, *r.configure_flags].compact.join(' ') 68 | command "./configure --quiet #{flags} && make -s && make -s install" 69 | cwd "#{src_dir}/#{dirname}" 70 | creates r.creates 71 | end 72 | end 73 | -------------------------------------------------------------------------------- /resources/extract.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: tar 3 | # Resource:: extract 4 | # 5 | # Author:: Nathan L Smith () 6 | # Author:: George Miranda () 7 | # Author:: Mark Van de Vyver () 8 | # 9 | # Copyright:: 2011, Cramer Development, Inc. 10 | # Copyright:: 2012-2016, Chef Software, Inc. 11 | # Copyright:: 2013, TAQTIQA LLC. 12 | # 13 | # Licensed under the Apache License, Version 2.0 (the "License"); 14 | # you may not use this file except in compliance with the License. 15 | # You may obtain a copy of the License at 16 | # 17 | # http://www.apache.org/licenses/LICENSE-2.0 18 | # 19 | # Unless required by applicable law or agreed to in writing, software 20 | # distributed under the License is distributed on an "AS IS" BASIS, 21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | # See the License for the specific language governing permissions and 23 | # limitations under the License. 24 | # 25 | 26 | property :source, String, name_property: true 27 | property :checksum, String 28 | property :download_dir, String, default: Chef::Config[:file_cache_path] 29 | property :group, String, default: node['root_group'] 30 | property :mode, String, default: '0755' 31 | property :target_dir, String 32 | property :creates, String 33 | property :compress_char, String, default: 'z' 34 | property :tar_binary, String, default: 'tar' 35 | property :tar_flags, [String, Array], default: [] 36 | property :user, String, default: 'root' 37 | property :headers, Hash 38 | property :use_etag, [true, false], default: true 39 | property :use_last_modified, [true, false], default: true 40 | property :atomic_update, [true, false], default: true 41 | property :force_unlink, [true, false], default: false 42 | property :manage_symlink_source, [true, false] 43 | 44 | require 'shellwords' 45 | 46 | action :extract do 47 | r = new_resource 48 | basename = ::File.basename(r.name) 49 | extname = ::File.extname(r.name) 50 | r.compress_char = '' if extname.casecmp('.xz') == 0 51 | local_archive = "#{r.download_dir}/#{basename}" 52 | 53 | directory r.download_dir do 54 | recursive true 55 | end 56 | 57 | remote_file basename do 58 | source r.source 59 | checksum r.checksum 60 | path local_archive 61 | backup false 62 | action :create 63 | group r.group 64 | owner r.user 65 | mode r.mode 66 | headers r.headers unless r.headers.nil? 67 | use_etag r.use_etag 68 | use_last_modified r.use_last_modified 69 | atomic_update r.atomic_update 70 | force_unlink r.force_unlink 71 | manage_symlink_source r.manage_symlink_source 72 | notifies :run, "execute[extract #{local_archive}]" 73 | end 74 | 75 | extract_tar(local_archive, new_resource) 76 | end 77 | 78 | action :extract_local do 79 | extract_tar(new_resource.name, new_resource) 80 | end 81 | 82 | action_class do 83 | def extract_tar(local_archive, r) 84 | directory r.target_dir 85 | execute "extract #{local_archive}" do 86 | flags = if r.tar_flags.is_a?(String) 87 | r.tar_flags 88 | else 89 | r.tar_flags.join(' ') 90 | end 91 | command "#{r.tar_binary} xf#{r.compress_char} #{local_archive.shellescape} #{flags}" 92 | cwd r.target_dir 93 | creates r.creates 94 | group r.group 95 | user r.user 96 | action (r.creates || r.not_if.any? || r.only_if.any? ? :run : :nothing) 97 | end 98 | end 99 | end 100 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # tar Cookbook CHANGELOG 2 | 3 | This file is used to list changes made in each version of the tar cookbook. 4 | 5 | ## 2.2.0 (2018-07-24) 6 | 7 | - Enable FC016 again 8 | - Use dokken and swap opensuse 13 testing for debian 9 9 | - GH-42 Fix opensuse image name in .kitchen.yml 10 | - GH-42 Add freebsd 10 and 11 to tested platforms 11 | - GH-42 Skip tar package install on freebsd 12 | - GH-42 Fix default group name in tar_extract 13 | - GH-42 Ensure src_dir exists in tar_package 14 | - GH-42 Use short options for make command 15 | - GH-42 Use latest nano for testing purposes 16 | - GH-42 Add freebsd to supported platforms list 17 | - Update creates parameter to reflect what gets extracted by resource. 18 | - Remove chefspec matchers that are autogenerated 19 | - Use build_essential resource instead of the recipe 20 | 21 | ## 2.1.1 (2017-06-13) 22 | 23 | - Fix metadata source and issues links. 24 | 25 | ## 2.1.0 (2017-05-30) 26 | 27 | - Test with Local Delivery instead of Rake 28 | - Update apache2 license string 29 | - Attribute -> Property in the custom resource 30 | - Remove class_eval and require Chef 12.7+ 31 | 32 | ## 2.0.0 (2017-02-16) 33 | 34 | - Converted the existing LWRPs to custom resources and bumped the minimum supported Chef release to 12.5 35 | - Add all supported platforms to the metadata 36 | - Add full testing of the resources in Travis CI 37 | 38 | ## 1.1.0 (2016-12-21) 39 | 40 | - added support for .xz compression type 41 | - Reformat the readme 42 | - Define both Chefspec matchers 43 | - Remove Chef 11 compatibility code 44 | 45 | ## 1.0.0 (2016-12-21) 46 | 47 | - This cookbook has been adopted by Chef and will be maintained by the Community Cookbook Team going forward. 48 | - This cookbook now requires Chef 12.1+ to align with the requirements of all Chef maintained cookbooks 49 | - Cookbook boilerplate has been updated 50 | 51 | - chefignore file added 52 | - gitignore file 53 | - Test Kitchen config added 54 | - Berksfile added 55 | - Gemfile added 56 | - Badges added to the readme 57 | - Add maintainers files 58 | - Add rakefile for simplified testing 59 | - Add github templates 60 | - Add license file 61 | - Update author in metadata and add supermarket metadata 62 | - Add contributing and testing docs 63 | - Cookstyle fixes 64 | - Add basic chefspec convergence test 65 | - Add a basic test cookbook 66 | - Add test kitchen testing in Travis 67 | 68 | ## v0.7.0 (2015-07-08) 69 | 70 | - Add adoption notice 71 | - Use `file_cache_path` instead of `file_backup_path` for downloaded artifact storage 72 | - Fix links to Chef documentation in README 73 | 74 | ## v0.6.0 (2014-12-03) 75 | 76 | - Allow either string or array for tar flags 77 | 78 | ## v0.5.0 (2014-07-28) 79 | 80 | - Add support for more attributes of `remote_file` 81 | - Escape downloaded file names 82 | 83 | ## v0.4.0 (2014-06-13) 84 | 85 | - Add `archive_name` option for when the file name is different from the package name 86 | 87 | ## v0.3.4 (2014-06-05) 88 | 89 | - Define ChefSpec::Runner method for tar_extract 90 | 91 | ## v0.3.3 (2014-06-03) 92 | 93 | - Add ChefSpec matchers 94 | 95 | ## v0.3.2 (2014-05-05) 96 | 97 | - Add checksum to remote file downloads 98 | 99 | ## v0.3.1 (2014-04-04) 100 | 101 | - Correct "notifies" definition in tar_extract's remote_file 102 | 103 | ## v0.3.0 (2014-03-21) 104 | 105 | - Add `:extract_local` action 106 | 107 | ## v0.2.0 (2013-12-31) 108 | 109 | - Make `tar_extract` only run if needed 110 | - Fix missing space in command line prefix 111 | - Ensure `file_backup_path` exists on initial chef-client run 112 | - Only add headers if needed 113 | 114 | ## v0.1.0 (2013-11-26) 115 | 116 | - Allow custom HTTP headers when downloading files 117 | - Allow the type of tar compression 118 | - Improve resource notifications 119 | 120 | ## v0.0.4 (2013-10-02) 121 | 122 | - Remove conditional download requests in favor of built-in functionality in Chef >= 11.6.0. 123 | - Fix readme example 124 | - Foodcritic fixes 125 | 126 | ## v0.0.3 (2013-01-30) 127 | 128 | - Conditional requests for downloads 129 | - Allow extract if non-root user 130 | - Formatting fixes 131 | 132 | ## v0.0.2 (2012-10-13) 133 | 134 | - Add `tar_extract` LWRP 135 | 136 | ## v0.0.1 (2011-09-15) 137 | 138 | Initial release 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tar Cookbook 2 | 3 | [![Build Status](https://travis-ci.org/chef-cookbooks/tar.svg?branch=master)](https://travis-ci.org/chef-cookbooks/tar) [![Cookbook Version](https://img.shields.io/cookbook/v/tar.svg)](https://supermarket.chef.io/cookbooks/tar) 4 | 5 | Installs tar and includes resources for managing remote tar files. `tar_package` handles remote source package compilation. `tar_extract` handles retrieving remote tar files and extracting them locally. 6 | 7 | ## Deprecated 8 | 9 | Chef 15 now ships with a built-in `archive_file` resource which handles many archive formats including tar. This new built-in resource should be used instead of this cookbook, which will no longer receive additional updates. 10 | 11 | ## Requirements 12 | 13 | ### Platforms 14 | 15 | - Debian / Ubuntu derivatives 16 | - RHEL and derivatives 17 | - openSUSE / SUSE Linux Enterprises 18 | - FreeBSD 19 | 20 | ### Chef 21 | 22 | - Chef 12.7+ 23 | 24 | ## Resources 25 | 26 | ### tar_package 27 | 28 | The `tar_package` resource provides an easy way to download remote files and compile and install them. This only works for the most basic Autoconf programs that can do `./configure && make && make install`. 29 | 30 | #### Actions 31 | 32 | - `install` Installs the package 33 | 34 | #### Properties 35 | 36 | - `source`: name attribute. The source remote URL. 37 | - `prefix`: Directory to be used as the `--prefix` configure flag. 38 | - `source_directory`: Directory to which source files are downloaded. 39 | - `creates`: prevent the command from running when the specified file already exists. 40 | - `configure_flags`: Array of additional flags to be passed to `./configure`. 41 | - `archive_name`: Specify a different name for the downloaded archive. Use it if the directory name inside the tar file is different than the name defined in the URL. Additionally, `tar_package` supports most `remote_file` [attributes](https://docs.chef.io/chef/resources.html#remote-file). 42 | - `tar_binary`: Specify the path to the tar binary, if "tar" is insufficient. 43 | 44 | #### Example 45 | 46 | ``` 47 | tar_package 'http://pgfoundry.org/frs/download.php/1446/pgpool-3.4.1.tar.gz' do 48 | prefix '/usr/local' 49 | creates '/usr/local/bin/pgpool' 50 | end 51 | ``` 52 | 53 | This will download, compile, and install the package from the given URL and install it into /usr/local. 54 | 55 | ### tar_extract 56 | 57 | The `tar_extract` resource provides an easy way to extract tar files from downloaded or local files. 58 | 59 | #### Actions 60 | 61 | - `extract` Extracts the tar file from a url 62 | - `extract_local` Extracts the tar file from a local file path 63 | 64 | #### Properties 65 | 66 | - `source`: name attribute. The source remote URL. 67 | - `target_dir`: Directory to extract into, e.g. tar xzf -C (target_dir) 68 | - `download_dir`: Directory to which tarball is downloaded (defaults to chef cache which requires root `group` and `user`). 69 | - `creates`: prevent the command from running when the specified file already exists. 70 | - `compress_char`: Flag for compression type, such as `z` for `gzip`. `man tar` for options. 71 | - `tar_flags`: Array of additional flags to be passed to tar xzf command. 72 | - `group`: Group name or group ID to extract the archive under. If set to non-root group, point to a `download_dir` the group has permission to access. 73 | - `user`: User name or user ID to extract the archive under. If set to non-root user, point to a `download_dir` the user has permission to access. Additionally, `tar_extract` supports most `remote_file` [attributes](https://docs.chef.io/chef/resources.html#remote-file). 74 | - `tar_binary`: Specify the path to the tar binary, if "tar" is insufficient. 75 | 76 | #### Example 77 | 78 | ``` 79 | tar_extract 'http://dev.mycoderepo.com/artifacts/mycode-1.2.3.tar.gz' do 80 | target_dir '/opt/myapp/mycode' 81 | creates '/opt/myapp/mycode/lib' 82 | tar_flags [ '-P', '--strip-components 1' ] 83 | end 84 | ``` 85 | 86 | This will download the tarball to cache, extract the contents to /opt/myapp/mycode, use the file '/opt/myapp/mycode/lib' to determine idempotency, and pass both '-P' and '--strip-components 1' flags to the tar xzf command. 87 | 88 | ``` 89 | tar_extract '/tmp/mycode-1.2.3.tar.gz' do 90 | action :extract_local 91 | target_dir '/opt/myapp/mycode' 92 | creates '/opt/myapp/mycode/lib' 93 | end 94 | ``` 95 | 96 | This will extract the contents of /tmp/mycode-1.2.3.tar.gz to /opt/myapp/mycode and use the file '/opt/myapp/mycode/lib' to determine idempotency. 97 | 98 | ## LICENSE AND AUTHOR 99 | 100 | - **Author:** Nathan L Smith ([nathan@cramerdev.com](mailto:nathan@cramerdev.com)) 101 | - **Author:** George Miranda ([gmiranda@chef.io](mailto:gmiranda@chef.io)) 102 | - **Author:** Mark Van de Vyver ([mark@@taqtiqa.com](mailto:mark@taqtiqa.com)) 103 | 104 | ```text 105 | 106 | Copyright: 2011, Cramer Development, Inc. 107 | Copyright: 2013, TAQTIQA LLC. 108 | Copyright: 2011-2017, Chef Software, Inc 109 | 110 | Licensed under the Apache License, Version 2.0 (the "License"); 111 | you may not use this file except in compliance with the License. 112 | You may obtain a copy of the License at 113 | 114 | http://www.apache.org/licenses/LICENSE-2.0 115 | 116 | Unless required by applicable law or agreed to in writing, software 117 | distributed under the License is distributed on an "AS IS" BASIS, 118 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 119 | See the License for the specific language governing permissions and 120 | limitations under the License. 121 | ``` 122 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------