From b954a4f6b05f1f9e815a091c8f020c2f39536579 Mon Sep 17 00:00:00 2001 From: treydock Date: Thu, 18 Apr 2024 10:54:10 -0400 Subject: [PATCH] Fix handling of symlinks when creating tar file (#270) * Fix handling of symlinks when creating tar file * Also add --hard-dereference --- Gemfile.lock | 2 +- lib/ood_packaging/package.rb | 2 +- lib/ood_packaging/version.rb | 2 +- spec/ood_packaging/package_spec.rb | 9 ++++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b4357df..ea55890 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ood_packaging (0.14.0) + ood_packaging (0.14.1) rake (~> 13.0.1) GEM diff --git a/lib/ood_packaging/package.rb b/lib/ood_packaging/package.rb index 97d3f27..1cf466f 100644 --- a/lib/ood_packaging/package.rb +++ b/lib/ood_packaging/package.rb @@ -238,7 +238,7 @@ def tar! end tar_file = "#{dir}/#{tar_name}.tar.gz" cmd.concat ["--transform 's,^,#{tar_name}/,'"] - cmd.concat ['-T', '-', '|', "gzip > #{tar_file}"] + cmd.concat ['-h', '--hard-dereference', '-T', '-', '|', "gzip > #{tar_file}"] sh "rm #{tar_file}" if File.exist?(tar_file) puts "Create tar archive #{tar_file}".blue diff --git a/lib/ood_packaging/version.rb b/lib/ood_packaging/version.rb index b8a4287..b498879 100644 --- a/lib/ood_packaging/version.rb +++ b/lib/ood_packaging/version.rb @@ -2,7 +2,7 @@ # Version code for OodPackaging module OodPackaging - VERSION = '0.14.0' + VERSION = '0.14.1' PACKAGE_VERSION = { 'ondemand-release' => { '(ubuntu|debian)' => '3.1.1', diff --git a/spec/ood_packaging/package_spec.rb b/spec/ood_packaging/package_spec.rb index 6074bec..c8e6d0f 100644 --- a/spec/ood_packaging/package_spec.rb +++ b/spec/ood_packaging/package_spec.rb @@ -78,7 +78,8 @@ expected_cmd = [ 'git', 'ls-files', '.', '|', 'tar', '-c', "--transform 's,^,package-0.0.1/,'", - '-T', '-', '|', 'gzip >', File.join(config[:package], 'packaging/rpm', 'package-0.0.1.tar.gz') + '-h', '--hard-dereference', '-T', '-', '|', + 'gzip >', File.join(config[:package], 'packaging/rpm', 'package-0.0.1.tar.gz') ] expect(package).to receive(:sh).with(expected_cmd.join(' '), verbose: false) package.tar! @@ -93,7 +94,8 @@ 'git', 'ls-files', '.', '|', 'tar', '-c', "--transform 'flags=r;s,packaging/deb,debian,'", "--transform 's,^,package-0.0.1/,'", - '-T', '-', '|', 'gzip >', File.join(config[:package], 'build', 'package-0.0.1.tar.gz') + '-h', '--hard-dereference', '-T', '-', '|', + 'gzip >', File.join(config[:package], 'build', 'package-0.0.1.tar.gz') ] FileUtils.mkdir_p(File.join(config[:package], 'build')) expect(package).to receive(:sh).with("mkdir -p #{File.join(config[:package], 'build')}") @@ -107,7 +109,8 @@ 'git', 'ls-files', '.', '|', 'tar', '-c', "--transform 'flags=r;s,packaging/deb,debian,'", "--transform 's,^,package-0.0.1/,'", - '-T', '-', '|', 'gzip >', File.join(config[:package], 'deb/build', 'package-0.0.1.tar.gz') + '-h', '--hard-dereference', '-T', '-', '|', + 'gzip >', File.join(config[:package], 'deb/build', 'package-0.0.1.tar.gz') ] FileUtils.mkdir_p(File.join(config[:package], 'deb', 'build')) expect(package).to receive(:sh).with("mkdir -p #{File.join(config[:package], 'deb', 'build')}")