Skip to content

Commit 69f0fa5

Browse files
authored
use gnu tar compatible minitar to generate tar artifact (#16432)
Using VERSION_QUALIFIER when building the tarball distribution will fail since Ruby's TarWriter implements the older POSIX88 version of tar and paths will be longer than 100 characters. For the long paths being used in Logstash's plugins, mainly due to nested folders from jar-dependencies, we need the tarball to follow either the 2001 ustar format or gnu tar, which is implemented by the minitar gem.
1 parent bb7ecc2 commit 69f0fa5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Gemfile.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ gem "logstash-output-elasticsearch", ">= 11.14.0"
1414
gem "polyglot", require: false
1515
gem "treetop", require: false
1616
gem "faraday", "~> 1", :require => false # due elasticsearch-transport (elastic-transport) depending faraday '~> 1'
17+
gem "minitar", :group => :build
1718
gem "childprocess", "~> 4", :group => :build
1819
gem "fpm", "~> 1", ">= 1.14.1", :group => :build # compound due to bugfix https://github.com/jordansissel/fpm/pull/1856
1920
gem "gems", "~> 1", :group => :build

rakelib/artifacts.rake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ namespace "artifact" do
492492
require "zlib"
493493
require 'rubygems'
494494
require 'rubygems/package'
495+
require 'minitar'
495496
ensure_logstash_version_constant_defined
496497
tarpath = "build/logstash#{tar_suffix}-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}#{platform}.tar.gz"
497498
if File.exist?(tarpath) && ENV['SKIP_PREPARE'] == "1" && !source_modified_since?(File.mtime(tarpath))
@@ -500,7 +501,7 @@ namespace "artifact" do
500501
end
501502
puts("[artifact:tar] building #{tarpath}")
502503
gz = Zlib::GzipWriter.new(File.new(tarpath, "wb"), Zlib::BEST_COMPRESSION)
503-
Gem::Package::TarWriter.new(gz) do |tar|
504+
Minitar::Writer.open(gz) do |tar|
504505
files(exclude_paths).each do |path|
505506
write_to_tar(tar, path, "logstash-#{LOGSTASH_VERSION}#{PACKAGE_SUFFIX}/#{path}")
506507
end
@@ -520,11 +521,11 @@ namespace "artifact" do
520521
def write_to_tar(tar, path, path_in_tar)
521522
stat = File.lstat(path)
522523
if stat.directory?
523-
tar.mkdir(path_in_tar, stat.mode)
524+
tar.mkdir(path_in_tar, :mode => stat.mode)
524525
elsif stat.symlink?
525-
tar.add_symlink(path_in_tar, File.readlink(path), stat.mode)
526+
tar.symlink(path_in_tar, File.readlink(path), :mode => stat.mode)
526527
else
527-
tar.add_file_simple(path_in_tar, stat.mode, stat.size) do |io|
528+
tar.add_file_simple(path_in_tar, :mode => stat.mode, :size => stat.size) do |io|
528529
File.open(path, 'rb') do |fd|
529530
chunk = nil
530531
size = 0

0 commit comments

Comments
 (0)