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

Handle 7zip extraction separately #1548

Merged
merged 9 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 2 additions & 1 deletion include/vcpkg/archives.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace vcpkg
SevenZip,
Nupkg,
Msi,
Exe
Exe,
SelfExtracting7z
};

// Extract `archive` to `to_path` using `tar_tool`.
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg-test/archives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ TEST_CASE ("Testing guess_extraction_type", "[z-extract]")
REQUIRE(guess_extraction_type(Path("/path/to/archive.xz")) == ExtractionType::Tar);
REQUIRE(guess_extraction_type(Path("/path/to/archive.exe")) == ExtractionType::Exe);
REQUIRE(guess_extraction_type(Path("/path/to/archive.unknown")) == ExtractionType::Unknown);
REQUIRE(guess_extraction_type(Path("/path/to/archive.7z.exe")) == ExtractionType::SelfExtracting7z);
}
14 changes: 13 additions & 1 deletion src/vcpkg/archives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,16 @@ namespace vcpkg
}
else if (Strings::case_insensitive_ascii_equals(ext, ".exe"))
{
return ExtractionType::Exe;
// Special case to differentiate between self-extracting 7z archives and other exe files
const auto stem = archive.stem();
if (Strings::case_insensitive_ascii_equals(Path(stem).extension(), ".7z"))
{
return ExtractionType::SelfExtracting7z;
}
else
{
return ExtractionType::Exe;
}
}
else
{
Expand Down Expand Up @@ -188,6 +197,9 @@ namespace vcpkg
extract_tar(tools.get_tool_path(Tools::TAR, status_sink), archive, to_path);
break;
case ExtractionType::Exe:
win32_extract_with_seven_zip(tools.get_tool_path(Tools::SEVEN_ZIP, status_sink), archive, to_path);
break;
case ExtractionType::SelfExtracting7z:
const Path filename = archive.filename();
const Path stem = filename.stem();
const Path to_archive = Path(archive.parent_path()) / stem;
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-init/vcpkg-scripts-sha.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d033613d9021107e4a7b52c5fac1f87ae8a6fcc6
a1dc361588c31b746e20d0146649e67f01646bad