Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Archive::Tar::Minitar #122

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/puppet_forge/tar/mini.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'zlib'
require 'archive/tar/minitar'
require 'minitar'

module PuppetForge
class Tar
Expand All @@ -15,7 +15,7 @@ def unpack(sourcefile, destdir)
file_lists = {}
Zlib::GzipReader.open(sourcefile) do |reader|
file_lists = validate_files(reader)
Archive::Tar::Minitar.unpack(reader, destdir, file_lists[:valid]) do |action, name, stats|
Minitar.unpack(reader, destdir, file_lists[:valid]) do |action, name, stats|
case action
when :file_done
FileUtils.chmod('u+rw,g+r,a-st', "#{destdir}/#{name}")
Expand All @@ -33,7 +33,7 @@ def unpack(sourcefile, destdir)

def pack(sourcedir, destfile)
Zlib::GzipWriter.open(destfile) do |writer|
Archive::Tar::Minitar.pack(sourcedir, writer)
Minitar.pack(sourcedir, writer)
end
end

Expand All @@ -50,7 +50,7 @@ def pack(sourcedir, destfile)
# @return [Hash{:symbol => Array<String>}] a hash with file-category keys pointing to lists of filenames.
def validate_files(tarfile)
file_lists = {:valid => [], :invalid => [], :symlinks => []}
Archive::Tar::Minitar.open(tarfile).each do |entry|
Minitar.open(tarfile).each do |entry|
flag = entry.typeflag
if flag.nil? || flag =~ /[[:digit:]]/ && SYMLINK_FLAGS.include?(flag.to_i)
file_lists[:symlinks] << entry.full_name
Expand Down
2 changes: 1 addition & 1 deletion puppet_forge.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "faraday", "~> 2.0"
spec.add_runtime_dependency "faraday-follow_redirects", "~> 0.3.0"
spec.add_dependency "semantic_puppet", "~> 1.0"
spec.add_dependency "minitar", "< 1.0.0 "
spec.add_dependency "minitar", '~> 1.0', '>= 1.0.2'

spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0"
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/forge/tar/mini_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def initialize(name, full_name, typeflag)
writer = double('GzipWriter')

expect(Zlib::GzipWriter).to receive(:open).with(destfile).and_yield(writer)
expect(Archive::Tar::Minitar).to receive(:pack).with(sourcedir, writer)
expect(Minitar).to receive(:pack).with(sourcedir, writer)

minitar.pack(sourcedir, destfile)
end
Expand All @@ -66,8 +66,8 @@ def initialize(name, full_name, typeflag)
reader = double('GzipReader')

expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
expect(Archive::Tar::Minitar).to receive(:open).with(reader).and_return(tarfile_contents)
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, ['full_file']).and_yield(:file_start, 'thefile', nil)
expect(Minitar).to receive(:open).with(reader).and_return(tarfile_contents)
expect(Minitar).to receive(:unpack).with(reader, destdir, ['full_file']).and_yield(:file_start, 'thefile', nil)

file_lists = minitar.unpack(sourcefile, destdir)

Expand All @@ -81,6 +81,6 @@ def unpacks_the_entry(type, name)

expect(Zlib::GzipReader).to receive(:open).with(sourcefile).and_yield(reader)
expect(minitar).to receive(:validate_files).with(reader).and_return({:valid => [name]})
expect(Archive::Tar::Minitar).to receive(:unpack).with(reader, destdir, [name]).and_yield(type, name, nil)
expect(Minitar).to receive(:unpack).with(reader, destdir, [name]).and_yield(type, name, nil)
end
end
Loading