From b80bcd6712b2a0b07111a34260069618755b0f4a Mon Sep 17 00:00:00 2001 From: Tom Anderson Date: Tue, 4 Jun 2024 14:40:29 +1000 Subject: [PATCH] fix changedir when unpacking tar/tgz --- lib/instance_agent/platform/linux_util.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/instance_agent/platform/linux_util.rb b/lib/instance_agent/platform/linux_util.rb index 6b7e870..38b3ece 100644 --- a/lib/instance_agent/platform/linux_util.rb +++ b/lib/instance_agent/platform/linux_util.rb @@ -43,9 +43,7 @@ def self.extract_tar(bundle_file, dst) FileUtils.mkdir_p(dst) working_dir = FileUtils.pwd() absolute_bundle_path = File.expand_path(bundle_file) - FileUtils.cd(dst) do - execute_tar_command("/bin/tar -xpsf #{absolute_bundle_path}") - end + execute_tar_command("/bin/tar -xps -C #{dst} -f #{absolute_bundle_path}") end def self.extract_zip(bundle_file, dst) @@ -60,9 +58,7 @@ def self.extract_tgz(bundle_file, dst) FileUtils.mkdir_p(dst) working_dir = FileUtils.pwd() absolute_bundle_path = File.expand_path(bundle_file) - FileUtils.cd(dst) do - execute_tar_command("/bin/tar -zxpsf #{absolute_bundle_path}") - end + execute_tar_command("/bin/tar -zxpsC #{dst} -f #{absolute_bundle_path}") end def self.supports_process_groups?()