mirror of
https://github.com/NixOS/nix
synced 2025-07-02 09:21:47 +02:00
Merge remote-tracking branch 'upstream/master' into support-hardlinks-in-tarballs
This commit is contained in:
commit
86420753ec
583 changed files with 11313 additions and 16547 deletions
|
@ -67,6 +67,17 @@ int getArchiveFilterCodeByName(const std::string & method)
|
|||
return code;
|
||||
}
|
||||
|
||||
static void enableSupportedFormats(struct archive * archive)
|
||||
{
|
||||
archive_read_support_format_tar(archive);
|
||||
archive_read_support_format_zip(archive);
|
||||
|
||||
/* Enable support for empty files so we don't throw an exception
|
||||
for empty HTTP 304 "Not modified" responses. See
|
||||
downloadTarball(). */
|
||||
archive_read_support_format_empty(archive);
|
||||
}
|
||||
|
||||
TarArchive::TarArchive(Source & source, bool raw, std::optional<std::string> compression_method)
|
||||
: archive{archive_read_new()}
|
||||
, source{&source}
|
||||
|
@ -78,9 +89,9 @@ TarArchive::TarArchive(Source & source, bool raw, std::optional<std::string> com
|
|||
archive_read_support_filter_by_code(archive, getArchiveFilterCodeByName(*compression_method));
|
||||
}
|
||||
|
||||
if (!raw) {
|
||||
archive_read_support_format_all(archive);
|
||||
} else {
|
||||
if (!raw)
|
||||
enableSupportedFormats(archive);
|
||||
else {
|
||||
archive_read_support_format_raw(archive);
|
||||
archive_read_support_format_empty(archive);
|
||||
}
|
||||
|
@ -96,7 +107,7 @@ TarArchive::TarArchive(const Path & path)
|
|||
, buffer(defaultBufferSize)
|
||||
{
|
||||
archive_read_support_filter_all(archive);
|
||||
archive_read_support_format_all(archive);
|
||||
enableSupportedFormats(archive);
|
||||
archive_read_set_option(archive, NULL, "mac-ext", NULL);
|
||||
check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s");
|
||||
}
|
||||
|
@ -176,6 +187,7 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
|
|||
auto path = archive_entry_pathname(entry);
|
||||
if (!path)
|
||||
throw Error("cannot get archive member name: %s", archive_error_string(archive.archive));
|
||||
auto cpath = CanonPath{path};
|
||||
if (r == ARCHIVE_WARN)
|
||||
warn(archive_error_string(archive.archive));
|
||||
else
|
||||
|
@ -191,11 +203,11 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
|
|||
switch (auto type = archive_entry_filetype(entry)) {
|
||||
|
||||
case AE_IFDIR:
|
||||
parseSink.createDirectory(path);
|
||||
parseSink.createDirectory(cpath);
|
||||
break;
|
||||
|
||||
case AE_IFREG: {
|
||||
parseSink.createRegularFile(path, [&](auto & crf) {
|
||||
parseSink.createRegularFile(cpath, [&](auto & crf) {
|
||||
if (archive_entry_mode(entry) & S_IXUSR)
|
||||
crf.isExecutable();
|
||||
|
||||
|
@ -219,7 +231,7 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
|
|||
case AE_IFLNK: {
|
||||
auto target = archive_entry_symlink(entry);
|
||||
|
||||
parseSink.createSymlink(path, target);
|
||||
parseSink.createSymlink(cpath, target);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue