mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-22 10:37:10 +01:00
[vcpkg] Fix vcpkg export --nuget
regressions (#12174)
* [vcpkg] Upgrade find_acquire_program(NUGET) to 5.5.1. Add partial SHA to temporary download paths to avoid collisions. * [vcpkg] Fix regression in `vcpkg export --nuget` due to file locking on .vcpkg-root Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
parent
1d8f0acc9c
commit
3f6342db6d
@ -219,12 +219,14 @@ function(vcpkg_find_acquire_program VAR)
|
||||
set(HASH a196e243c53daa1df9d287af658d6d38d6b830b614f2d5704e8c88ffc61f179a533ae71cdb6d0d383d1559d65dacccbaaab270fb2a33aa211e5dba42ff046f97)
|
||||
elseif(VAR MATCHES "NUGET")
|
||||
set(PROGNAME nuget)
|
||||
set(PATHS "${DOWNLOADS}/tools/nuget")
|
||||
set(SUBDIR "5.5.1")
|
||||
set(PATHS "${DOWNLOADS}/tools/nuget/${SUBDIR}")
|
||||
set(BREW_PACKAGE_NAME "nuget")
|
||||
set(URL "https://dist.nuget.org/win-x86-commandline/v4.8.1/nuget.exe")
|
||||
set(ARCHIVE "nuget.exe")
|
||||
set(URL "https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe")
|
||||
set(_vfa_RENAME "nuget.exe")
|
||||
set(ARCHIVE "nuget.5.5.1.exe")
|
||||
set(NOEXTRACT ON)
|
||||
set(HASH 42cb744338af8decc033a75bce5b4c4df28e102bafc45f9a8ba86d7bc010f5b43ebacae80d7b28c4f85ac900eefc2a349620ae65f27f6ca1c21c53b63b92924b)
|
||||
set(HASH 22ea847d8017cd977664d0b13c889cfb13c89143212899a511be217345a4e243d4d8d4099700114a11d26a087e83eb1a3e2b03bdb5e0db48f10403184cd26619)
|
||||
elseif(VAR MATCHES "MESON")
|
||||
set(PROGNAME meson)
|
||||
set(REQUIRED_INTERPRETER PYTHON3)
|
||||
|
@ -64,10 +64,7 @@ namespace fs
|
||||
using type = intptr_t; // HANDLE
|
||||
type system_handle = -1;
|
||||
|
||||
bool is_valid() const
|
||||
{
|
||||
return system_handle != -1;
|
||||
}
|
||||
bool is_valid() const { return system_handle != -1; }
|
||||
};
|
||||
|
||||
#else
|
||||
@ -87,10 +84,7 @@ namespace fs
|
||||
using type = int; // file descriptor
|
||||
type system_handle = -1;
|
||||
|
||||
bool is_valid() const
|
||||
{
|
||||
return system_handle != -1;
|
||||
}
|
||||
bool is_valid() const { return system_handle != -1; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -176,6 +170,7 @@ namespace vcpkg::Files
|
||||
const fs::path& newpath,
|
||||
fs::copy_options opts,
|
||||
std::error_code& ec) = 0;
|
||||
void copy_file(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts, LineInfo li);
|
||||
virtual void copy_symlink(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) = 0;
|
||||
virtual fs::file_status status(const fs::path& path, std::error_code& ec) const = 0;
|
||||
virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const = 0;
|
||||
|
@ -209,6 +209,14 @@ namespace vcpkg::Files
|
||||
std::error_code ec;
|
||||
return this->create_directories(path, ec);
|
||||
}
|
||||
void Filesystem::copy_file(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts, LineInfo li)
|
||||
{
|
||||
std::error_code ec;
|
||||
this->copy_file(oldpath, newpath, opts, ec);
|
||||
if (ec)
|
||||
vcpkg::Checks::exit_with_message(
|
||||
li, "error copying file from %s to %s: %s", oldpath.u8string(), newpath.u8string(), ec.message());
|
||||
}
|
||||
|
||||
fs::file_status Filesystem::status(vcpkg::LineInfo li, const fs::path& p) const noexcept
|
||||
{
|
||||
@ -848,14 +856,13 @@ namespace vcpkg::Files
|
||||
#if defined(WIN32)
|
||||
constexpr static auto busy_error = ERROR_BUSY;
|
||||
const auto system_try_take_file_lock = [&] {
|
||||
auto handle = CreateFileW(
|
||||
system_file_name.c_str(),
|
||||
GENERIC_READ,
|
||||
0 /* no sharing */,
|
||||
nullptr /* no security attributes */,
|
||||
OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr /* no template file */);
|
||||
auto handle = CreateFileW(system_file_name.c_str(),
|
||||
GENERIC_READ,
|
||||
0 /* no sharing */,
|
||||
nullptr /* no security attributes */,
|
||||
OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr /* no template file */);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
const auto err = GetLastError();
|
||||
|
@ -240,7 +240,6 @@ namespace vcpkg::Export
|
||||
void export_integration_files(const fs::path& raw_exported_dir_path, const VcpkgPaths& paths)
|
||||
{
|
||||
const std::vector<fs::path> integration_files_relative_to_root = {
|
||||
{".vcpkg-root"},
|
||||
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"},
|
||||
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"},
|
||||
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.props"},
|
||||
@ -249,17 +248,15 @@ namespace vcpkg::Export
|
||||
{fs::path{"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"},
|
||||
};
|
||||
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
for (const fs::path& file : integration_files_relative_to_root)
|
||||
{
|
||||
const fs::path source = paths.root / file;
|
||||
fs::path destination = raw_exported_dir_path / file;
|
||||
Files::Filesystem& fs = paths.get_filesystem();
|
||||
std::error_code ec;
|
||||
fs.create_directories(destination.parent_path(), ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !ec);
|
||||
fs.copy_file(source, destination, fs::copy_options::overwrite_existing, ec);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !ec);
|
||||
fs.create_directories(destination.parent_path(), ignore_errors);
|
||||
fs.copy_file(source, destination, fs::copy_options::overwrite_existing, VCPKG_LINE_INFO);
|
||||
}
|
||||
fs.write_contents(raw_exported_dir_path / fs::u8path(".vcpkg-root"), "", VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
struct ExportArguments
|
||||
@ -591,7 +588,10 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
|
||||
{
|
||||
if (paths.manifest_mode_enabled())
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "vcpkg export does not support manifest mode, in order to allow for future design considerations. You may use export in classic mode by running vcpkg outside of a manifest-based project.");
|
||||
Checks::exit_with_message(
|
||||
VCPKG_LINE_INFO,
|
||||
"vcpkg export does not support manifest mode, in order to allow for future design considerations. You "
|
||||
"may use export in classic mode by running vcpkg outside of a manifest-based project.");
|
||||
}
|
||||
const StatusParagraphs status_db = database_load_check(paths);
|
||||
const auto opts = handle_export_command_arguments(args, default_triplet, status_db);
|
||||
|
@ -108,14 +108,17 @@ namespace vcpkg
|
||||
const std::string tool_dir_name = Strings::format("%s-%s-%s", tool, version_as_string, OS_STRING);
|
||||
const fs::path tool_dir_path = paths.tools / tool_dir_name;
|
||||
const fs::path exe_path = tool_dir_path / exe_relative_path;
|
||||
fs::path download_path;
|
||||
if (auto a = archive_name.get())
|
||||
{
|
||||
download_path = paths.downloads / fs::u8path(a->to_string());
|
||||
}
|
||||
else
|
||||
{
|
||||
download_path = paths.downloads / fs::u8path(Strings::concat(sha512.substr(0, 8), '-', exe_relative_path));
|
||||
}
|
||||
|
||||
return ToolData{*version.get(),
|
||||
exe_path,
|
||||
url,
|
||||
paths.downloads / archive_name.value_or(exe_relative_path).to_string(),
|
||||
archive_name.has_value(),
|
||||
tool_dir_path,
|
||||
sha512};
|
||||
return ToolData{*version.get(), exe_path, url, download_path, archive_name.has_value(), tool_dir_path, sha512};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user