Use long/readable tar flags.
Also, use `--no-same-permissions` instead of `-o` (which does nothing without `-p` being passed and run as `root`) for the more explicit description of the behaviour we want.
This commit is contained in:
parent
96cd1c058e
commit
b57fe84f81
@ -32,7 +32,7 @@ describe UnpackStrategy do
|
|||||||
(mktmpdir/"file.tar").tap do |path|
|
(mktmpdir/"file.tar").tap do |path|
|
||||||
mktmpdir do |dir|
|
mktmpdir do |dir|
|
||||||
(dir/directories).mkpath
|
(dir/directories).mkpath
|
||||||
system "tar", "-c", "-f", path, "-C", dir, "A/"
|
system "tar", "--create", "--file", path, "--directory", dir, "A/"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ describe UnpackStrategy do
|
|||||||
(mktmpdir/basename).tap do |path|
|
(mktmpdir/basename).tap do |path|
|
||||||
mktmpdir do |dir|
|
mktmpdir do |dir|
|
||||||
FileUtils.touch dir/"file.txt"
|
FileUtils.touch dir/"file.txt"
|
||||||
system "tar", "-c", "-f", path, "-C", dir, "file.txt"
|
system "tar", "--create", "--file", path, "--directory", dir, "file.txt"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ module UnpackStrategy
|
|||||||
return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) }
|
return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) }
|
||||||
|
|
||||||
# Check if `tar` can list the contents, then it can also extract it.
|
# Check if `tar` can list the contents, then it can also extract it.
|
||||||
stdout, _, status = system_command("tar", args: ["tf", path], print_stderr: false)
|
stdout, _, status = system_command("tar", args: ["--list", "--file", path], print_stderr: false)
|
||||||
status.success? && !stdout.empty?
|
status.success? && !stdout.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -48,7 +48,9 @@ module UnpackStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
system_command! "tar",
|
system_command! "tar",
|
||||||
args: ["xof", tar_path, "-C", unpack_dir],
|
args: ["--extract", "--no-same-owner",
|
||||||
|
"--file", tar_path,
|
||||||
|
"--directory", unpack_dir],
|
||||||
verbose: verbose
|
verbose: verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,7 @@ module Utils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def file_from_bottle(bottle_file, file_path)
|
def file_from_bottle(bottle_file, file_path)
|
||||||
Utils.popen_read("tar", "--extract", "--stdout", "--file", bottle_file, file_path)
|
Utils.popen_read("tar", "--extract", "--to-stdout", "--file", bottle_file, file_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_formula_names(bottle_file)
|
def resolve_formula_names(bottle_file)
|
||||||
|
@ -26,7 +26,7 @@ module Utils
|
|||||||
|
|
||||||
path = Pathname.new(path)
|
path = Pathname.new(path)
|
||||||
return unless TAR_FILE_EXTENSIONS.include? path.extname
|
return unless TAR_FILE_EXTENSIONS.include? path.extname
|
||||||
return if Utils.popen_read(executable, "-tf", path).match?(%r{/.*\.})
|
return if Utils.popen_read(executable, "--list", "--file", path).match?(%r{/.*\.})
|
||||||
|
|
||||||
odie "#{path} is not a valid tar file!"
|
odie "#{path} is not a valid tar file!"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user