Skip to content

Commit

Permalink
Handle 7zip extraction separately (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierMatosD authored Dec 9, 2024
1 parent b4b372c commit 1005b78
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
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
0c4cf19224a049cf82f4521e29e39f7bd680440c

0 comments on commit 1005b78

Please sign in to comment.