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

mixlib-archive-tar create corrupt archives on Windows #37

Merged
merged 2 commits into from
Jan 13, 2019
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
1 change: 1 addition & 0 deletions lib/mixlib/archive/tar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def extract(destination, perms: true, ignore: [])
def create(files, gzip: false)
tgt_dir = File.dirname(archive)
target = Tempfile.new(File.basename(archive), tgt_dir)
target.binmode

Gem::Package::TarWriter.new(target) do |tar|
files.each do |fn|
Expand Down
Binary file added spec/fixtures/fixture_binary
Binary file not shown.
3 changes: 2 additions & 1 deletion spec/mixlib/lib_archive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
describe "#create" do
let(:test_root) { Dir.mktmpdir(nil) }
let(:archive_path) { File.join(test_root, "test.tar.gz") }
let(:file_paths) { %w{ . .. fixture_a fixture_b fixture_c } }
let(:file_paths) { %w{ . .. fixture_a fixture_b fixture_c fixture_binary } }

context "using the correct options" do
it "requests the correct tar format" do
Expand All @@ -51,6 +51,7 @@
target = File.join(test_root, "target")
Mixlib::Archive::LibArchive.new(archive_path).extract(target)
expect(Dir.entries(target)).to match_array file_paths
expect(File.size("#{target}/fixture_binary")).to eql 6
end

end
Expand Down
3 changes: 2 additions & 1 deletion spec/mixlib/tar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
describe "#create" do
let(:test_root) { Dir.mktmpdir(nil) }
let(:archive_path) { File.join(test_root, "test.tar.gz") }
let(:file_paths) { %w{ . .. fixture_a fixture_b fixture_c } }
let(:file_paths) { %w{ . .. fixture_a fixture_b fixture_c fixture_binary } }

it "creates a tarball" do
Dir.chdir(fixtures_path) do
Expand All @@ -71,6 +71,7 @@
target = File.join(test_root, "target")
Mixlib::Archive::LibArchive.new(archive_path).extract(target, ignore: %w{ . .. })
expect(Dir.entries(target)).to match_array file_paths
expect(File.size("#{target}/fixture_binary")).to eql 6
end

end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "mixlib/archive"
require "mixlib/archive/tar"
require "mixlib/archive/lib_archive"
require "pathname"

module Fixtures
def fixtures_path
Expand Down