From 1f3ddddc98fcc15fb18a2d11ff2787c3b9c0e376 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 24 Oct 2021 22:59:47 +0100 Subject: [PATCH] Convert some archive unpacking to use archive_file --- cookbooks/civicrm/recipes/default.rb | 25 ++++++++++++------------- cookbooks/forum/recipes/default.rb | 12 ++++++------ cookbooks/imagery/recipes/default.rb | 7 +++---- cookbooks/kibana/recipes/default.rb | 9 +++++---- cookbooks/osmosis/recipes/default.rb | 11 +++++------ cookbooks/piwik/recipes/default.rb | 9 ++++----- 6 files changed, 35 insertions(+), 38 deletions(-) diff --git a/cookbooks/civicrm/recipes/default.rb b/cookbooks/civicrm/recipes/default.rb index ced22c5f4..6309efcf4 100644 --- a/cookbooks/civicrm/recipes/default.rb +++ b/cookbooks/civicrm/recipes/default.rb @@ -24,7 +24,6 @@ package %w[ php-xml php-curl rsync - unzip wkhtmltopdf php-bcmath ] @@ -102,22 +101,22 @@ remote_file "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do backup false end -execute "#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" do +archive_file "#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" do action :nothing - command "unzip -o -qq #{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" - cwd "/opt/civicrm-#{civicrm_version}" - user "wordpress" + destination "/opt/civicrm-#{civicrm_version}" + overwrite true + owner "wordpress" group "wordpress" - subscribes :run, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately + subscribes :extract, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately end -execute "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do +archive_file "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do action :nothing - command "tar -zxf #{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" - cwd "/opt/civicrm-#{civicrm_version}/civicrm" - user "wordpress" + destination "/opt/civicrm-#{civicrm_version}/civicrm" + overwrite true + owner "wordpress" group "wordpress" - subscribes :run, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately + subscribes :extract, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately end execute "/opt/civicrm-#{civicrm_version}/civicrm" do @@ -125,8 +124,8 @@ execute "/opt/civicrm-#{civicrm_version}/civicrm" do command "rsync --archive --delete /opt/civicrm-#{civicrm_version}/civicrm/ #{civicrm_directory}" user "wordpress" group "wordpress" - subscribes :run, "execute[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately - subscribes :run, "execute[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately + subscribes :run, "archive_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately + subscribes :run, "archive_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately end directory "/srv/join.osmfoundation.org/wp-content/uploads" do diff --git a/cookbooks/forum/recipes/default.rb b/cookbooks/forum/recipes/default.rb index c081dd3d2..ae32e4d01 100644 --- a/cookbooks/forum/recipes/default.rb +++ b/cookbooks/forum/recipes/default.rb @@ -32,7 +32,6 @@ package %w[ php-mysql php-xml php-apcu - unzip ] apache_module "env" @@ -78,13 +77,14 @@ remote_file "#{cache_dir}/air3_v0.8.tar.gz" do backup false end -execute "#{cache_dir}/air3_v0.8.tar.gz" do +archive_file "#{cache_dir}/air3_v0.8.tar.gz" do action :nothing - command "tar --gunzip --extract --file=#{cache_dir}/air3_v0.8.tar.gz --strip-components=1 --wildcards air3-0.8/Air3.css 'air3-0.8/Air3/*'" - cwd "/srv/forum.openstreetmap.org/html/style" - user "forum" + destination "/srv/forum.openstreetmap.org/html/style" + strip_components 1 + overwrite true + owner "forum" group "forum" - subscribes :run, "remote_file[#{cache_dir}/air3_v0.8.tar.gz]", :immediately + subscribes :extract, "remote_file[#{cache_dir}/air3_v0.8.tar.gz]", :immediately end directory "/srv/forum.openstreetmap.org/html/cache/" do diff --git a/cookbooks/imagery/recipes/default.rb b/cookbooks/imagery/recipes/default.rb index 63b33b70f..7a5b55057 100644 --- a/cookbooks/imagery/recipes/default.rb +++ b/cookbooks/imagery/recipes/default.rb @@ -71,10 +71,9 @@ remote_file "#{Chef::Config[:file_cache_path]}/ostn02-ntv2-data.zip" do not_if { ::File.exist?("/srv/imagery/common/ostn02-ntv2-data/OSTN02_NTv2.gsb") } end -execute "unzip-ostn02-ntv2-data" do - command "unzip -q #{Chef::Config[:file_cache_path]}/ostn02-ntv2-data.zip" - cwd "/srv/imagery/common/ostn02-ntv2-data" - user "root" +archive_file "#{Chef::Config[:file_cache_path]}/ostn02-ntv2-data.zip" do + destination "/srv/imagery/common/ostn02-ntv2-data" + owner "root" group "root" not_if { ::File.exist?("/srv/imagery/common/ostn02-ntv2-data/OSTN02_NTv2.gsb") } end diff --git a/cookbooks/kibana/recipes/default.rb b/cookbooks/kibana/recipes/default.rb index 1a8c7712a..2f2fc6f28 100644 --- a/cookbooks/kibana/recipes/default.rb +++ b/cookbooks/kibana/recipes/default.rb @@ -37,10 +37,11 @@ directory "/opt/kibana-#{version}" do mode "755" end -execute "unzip-kibana-#{version}" do - command "tar --gunzip --extract --strip-components=1 --file=#{Chef::Config[:file_cache_path]}/kibana-#{version}.tar.gz" - cwd "/opt/kibana-#{version}" - user "root" +archive_file "#{Chef::Config[:file_cache_path]}/kibana-#{version}.tar.gz" do + destination "/opt/kibana-#{version}" + overwrite true + strip_components 1 + owner "root" group "root" not_if { ::File.exist?("/opt/kibana-#{version}/bin/kibana") } end diff --git a/cookbooks/osmosis/recipes/default.rb b/cookbooks/osmosis/recipes/default.rb index ff38e90e0..b5b0b60b6 100644 --- a/cookbooks/osmosis/recipes/default.rb +++ b/cookbooks/osmosis/recipes/default.rb @@ -19,7 +19,6 @@ include_recipe "chef" -package "unzip" package "default-jre" cache_dir = Chef::Config[:file_cache_path] @@ -52,13 +51,13 @@ remote_file "#{cache_dir}/#{osmosis_package}" do backup false end -execute "#{cache_dir}/#{osmosis_package}" do +archive_file "#{cache_dir}/#{osmosis_package}" do action :nothing - command "unzip -q #{cache_dir}/#{osmosis_package}" - cwd osmosis_directory - user "root" + destination osmosis_directory + overwrite true + owner "root" group "root" - subscribes :run, "remote_file[#{cache_dir}/#{osmosis_package}]" + subscribes :extract, "remote_file[#{cache_dir}/#{osmosis_package}]" end link "/usr/local/bin/osmosis" do diff --git a/cookbooks/piwik/recipes/default.rb b/cookbooks/piwik/recipes/default.rb index 0bd3ede87..997048308 100644 --- a/cookbooks/piwik/recipes/default.rb +++ b/cookbooks/piwik/recipes/default.rb @@ -32,7 +32,6 @@ package %w[ php-gd php-xml php-apcu - unzip ] apache_module "expires" @@ -51,10 +50,10 @@ remote_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do not_if { ::File.exist?("/opt/piwik-#{version}/piwik") } end -execute "unzip-piwik-#{version}" do - command "unzip -q #{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" - cwd "/opt/piwik-#{version}" - user "root" +archive_file "#{Chef::Config[:file_cache_path]}/piwik-#{version}.zip" do + destination "/opt/piwik-#{version}" + overwrite true + owner "root" group "root" not_if { ::File.exist?("/opt/piwik-#{version}/piwik") } end -- 2.39.5