aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorras0219 <robertallenschumacher@gmail.com>2020-06-30 14:02:26 -0700
committerGitHub <noreply@github.com>2020-06-30 14:02:26 -0700
commit3f6342db6ded036422886da6ccf8191685dc2ccf (patch)
treec1377b8116c1ca8b8ef61fdbf6c8fa6b4dcc1dad
parent1d8f0acc9c3085d18152a3f639077a28109196b6 (diff)
downloadvcpkg-3f6342db6ded036422886da6ccf8191685dc2ccf.tar.gz
vcpkg-3f6342db6ded036422886da6ccf8191685dc2ccf.zip
[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>
-rw-r--r--scripts/cmake/vcpkg_find_acquire_program.cmake10
-rw-r--r--toolsrc/include/vcpkg/base/files.h11
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp23
-rw-r--r--toolsrc/src/vcpkg/export.cpp16
-rw-r--r--toolsrc/src/vcpkg/tools.cpp17
5 files changed, 42 insertions, 35 deletions
diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake
index 102e9c235..8ec9f4c9b 100644
--- a/scripts/cmake/vcpkg_find_acquire_program.cmake
+++ b/scripts/cmake/vcpkg_find_acquire_program.cmake
@@ -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)
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h
index 49a473091..dce9584fa 100644
--- a/toolsrc/include/vcpkg/base/files.h
+++ b/toolsrc/include/vcpkg/base/files.h
@@ -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;
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index 1ec9a19e4..9d9aecb69 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -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();
diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp
index 138c03b3f..48e9747b3 100644
--- a/toolsrc/src/vcpkg/export.cpp
+++ b/toolsrc/src/vcpkg/export.cpp
@@ -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);
diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp
index 717a7dbcf..687950096 100644
--- a/toolsrc/src/vcpkg/tools.cpp
+++ b/toolsrc/src/vcpkg/tools.cpp
@@ -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
}