From 731163934ac28ed3aba2ccfb6555a7b03b691c74 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 30 Oct 2024 13:57:22 -0700 Subject: [PATCH 01/11] Add parsing for overlay-port-dirs to the command line, environment, and manifest. --- docs/vcpkg-configuration.schema.json | 7 +++++++ include/vcpkg/base/contractual-constants.h | 3 +++ include/vcpkg/base/message-data.inc.h | 9 +++++++- include/vcpkg/commands.find.h | 3 ++- include/vcpkg/configuration.h | 1 + include/vcpkg/fwd/portfileprovider.h | 1 + include/vcpkg/portfileprovider.h | 21 ++++++++++++++++--- include/vcpkg/vcpkgcmdarguments.h | 2 ++ include/vcpkg/vcpkgpaths.h | 4 +++- src/vcpkg/commands.build-external.cpp | 2 +- src/vcpkg/commands.find.cpp | 2 +- src/vcpkg/commands.install.cpp | 8 +++----- src/vcpkg/configuration.cpp | 12 +++++++++++ src/vcpkg/portfileprovider.cpp | 24 +++++++++++++--------- src/vcpkg/vcpkgcmdarguments.cpp | 16 +++++++++++++-- src/vcpkg/vcpkgpaths.cpp | 15 +++++++++----- 16 files changed, 100 insertions(+), 30 deletions(-) diff --git a/docs/vcpkg-configuration.schema.json b/docs/vcpkg-configuration.schema.json index eb0aa2461d..949d61d1d6 100644 --- a/docs/vcpkg-configuration.schema.json +++ b/docs/vcpkg-configuration.schema.json @@ -21,6 +21,13 @@ "type": "string", "description": "A message to print if this entry is evaluated." }, + "overlay-port-dirs": { + "type": "array", + "description": "An array of port overlay directory paths.", + "items": { + "type": "string" + } + }, "overlay-ports": { "type": "array", "description": "An array of port overlay paths.", diff --git a/include/vcpkg/base/contractual-constants.h b/include/vcpkg/base/contractual-constants.h index 202b09bada..c9d35876ee 100644 --- a/include/vcpkg/base/contractual-constants.h +++ b/include/vcpkg/base/contractual-constants.h @@ -69,6 +69,7 @@ namespace vcpkg inline constexpr StringLiteral JsonIdMicrosoft = "microsoft"; inline constexpr StringLiteral JsonIdName = "name"; inline constexpr StringLiteral JsonIdOverlayPorts = "overlay-ports"; + inline constexpr StringLiteral JsonIdOverlayPortDirs = "overlay-port-dirs"; inline constexpr StringLiteral JsonIdOverlayTriplets = "overlay-triplets"; inline constexpr StringLiteral JsonIdOverrides = "overrides"; inline constexpr StringLiteral JsonIdPackages = "packages"; @@ -250,6 +251,7 @@ namespace vcpkg inline constexpr StringLiteral SwitchOutput = "output"; inline constexpr StringLiteral SwitchOutputDir = "output-dir"; inline constexpr StringLiteral SwitchOutputHashes = "output-hashes"; + inline constexpr StringLiteral SwitchOverlayPortDirs = "overlay-port-dirs"; inline constexpr StringLiteral SwitchOverlayPorts = "overlay-ports"; inline constexpr StringLiteral SwitchOverlayTriplets = "overlay-triplets"; inline constexpr StringLiteral SwitchOverwriteVersion = "overwrite-version"; @@ -534,6 +536,7 @@ namespace vcpkg inline constexpr StringLiteral EnvironmentVariableVcpkgMaxConcurrency = "VCPKG_MAX_CONCURRENCY"; inline constexpr StringLiteral EnvironmentVariableVcpkgNoCi = "VCPKG_NO_CI"; inline constexpr StringLiteral EnvironmentVariableVcpkgNuGetRepository = "VCPKG_NUGET_REPOSITORY"; + inline constexpr StringLiteral EnvironmentVariableVcpkgOverlayPortDirs = "VCPKG_OVERLAY_PORT_DIRS"; inline constexpr StringLiteral EnvironmentVariableVcpkgOverlayPorts = "VCPKG_OVERLAY_PORTS"; inline constexpr StringLiteral EnvironmentVariableVcpkgRoot = "VCPKG_ROOT"; inline constexpr StringLiteral EnvironmentVariableVcpkgUseNuGetCache = "VCPKG_USE_NUGET_CACHE"; diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index 4de9ddb69a..7dc9c634c8 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -2195,7 +2195,14 @@ DECLARE_MESSAGE(Options, (), "Printed just before a list of options for a comman DECLARE_MESSAGE(OriginalBinParagraphHeader, (), "", "\nOriginal Binary Paragraph") DECLARE_MESSAGE(OtherCommandsHeader, (), "", "Other") DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must exist and must be a directory.") -DECLARE_MESSAGE(OverlayPortsDirectoriesHelp, (msg::env_var), "", "Directories of overlay ports (also: {env_var})") +DECLARE_MESSAGE(OverlayPortDirsHelp, + (msg::env_var), + "", + "Directories containing overlay-port directories (also: {env_var})") +DECLARE_MESSAGE(OverlayPortsHelp, + (msg::env_var), + "", + "Overlay-port directories, or directories containing overlay-port directories (also: {env_var})") DECLARE_MESSAGE(OverlayTripletDirectoriesHelp, (msg::env_var), "", "Directories of overlay triplets (also: {env_var})") DECLARE_MESSAGE(OverlayTriplets, (msg::path), "", "Overlay Triplets from \"{path}\":") DECLARE_MESSAGE(OverwritingFile, (msg::path), "", "File {path} was already present and will be overwritten") diff --git a/include/vcpkg/commands.find.h b/include/vcpkg/commands.find.h index f363f60ab0..ed6baac1c1 100644 --- a/include/vcpkg/commands.find.h +++ b/include/vcpkg/commands.find.h @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -15,7 +16,7 @@ namespace vcpkg bool full_description, bool enable_json, Optional filter, - View overlay_ports); + const OverlayPortPaths& overlay_ports); extern const CommandMetadata CommandFindMetadata; void command_find_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } diff --git a/include/vcpkg/configuration.h b/include/vcpkg/configuration.h index 79d4d0fe9f..ac9c416e79 100644 --- a/include/vcpkg/configuration.h +++ b/include/vcpkg/configuration.h @@ -51,6 +51,7 @@ namespace vcpkg std::vector registries; Json::Object ce_metadata; Json::Object extra_info; + std::vector overlay_port_dirs; std::vector overlay_ports; std::vector overlay_triplets; diff --git a/include/vcpkg/fwd/portfileprovider.h b/include/vcpkg/fwd/portfileprovider.h index 22869bb90e..a09dbd9863 100644 --- a/include/vcpkg/fwd/portfileprovider.h +++ b/include/vcpkg/fwd/portfileprovider.h @@ -2,6 +2,7 @@ namespace vcpkg { + struct OverlayPortPaths; struct PortFileProvider; struct PathsPortFileProvider; struct IVersionedPortfileProvider; diff --git a/include/vcpkg/portfileprovider.h b/include/vcpkg/portfileprovider.h index 25a87ebff7..ebb867743d 100644 --- a/include/vcpkg/portfileprovider.h +++ b/include/vcpkg/portfileprovider.h @@ -5,12 +5,26 @@ #include #include +#include #include -#include +#include + +#include +#include +#include +#include namespace vcpkg { + struct OverlayPortPaths + { + std::vector overlay_port_dirs; + std::vector overlay_ports; + + bool empty() const noexcept; + }; + struct PortFileProvider { virtual ~PortFileProvider() = default; @@ -76,9 +90,10 @@ namespace vcpkg std::unique_ptr make_baseline_provider(const RegistrySet& registry_set); std::unique_ptr make_versioned_portfile_provider(const RegistrySet& registry_set); - std::unique_ptr make_overlay_provider(const ReadOnlyFilesystem& fs, View overlay_ports); + std::unique_ptr make_overlay_provider(const ReadOnlyFilesystem& fs, + const OverlayPortPaths& overlay_ports); std::unique_ptr make_manifest_provider(const ReadOnlyFilesystem& fs, - View overlay_ports, + const OverlayPortPaths& overlay_ports, const Path& manifest_path, std::unique_ptr&& manifest_scf); } diff --git a/include/vcpkg/vcpkgcmdarguments.h b/include/vcpkg/vcpkgcmdarguments.h index bb1967c505..5d929030c1 100644 --- a/include/vcpkg/vcpkgcmdarguments.h +++ b/include/vcpkg/vcpkgcmdarguments.h @@ -227,6 +227,8 @@ namespace vcpkg Optional triplet; Optional host_triplet; + std::vector cli_overlay_port_dirs; + std::vector env_overlay_port_dirs; std::vector cli_overlay_ports; std::vector env_overlay_ports; std::vector cli_overlay_triplets; diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 0639a5b8cc..d1309723c7 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -21,6 +21,8 @@ #include #include +#include + #include #include #include @@ -101,7 +103,7 @@ namespace vcpkg std::vector overlay_triplets; public: - std::vector overlay_ports; + OverlayPortPaths overlay_ports; std::string get_toolver_diagnostics() const; diff --git a/src/vcpkg/commands.build-external.cpp b/src/vcpkg/commands.build-external.cpp index 28720fa55b..3bf6987067 100644 --- a/src/vcpkg/commands.build-external.cpp +++ b/src/vcpkg/commands.build-external.cpp @@ -43,7 +43,7 @@ namespace vcpkg .value_or_exit(VCPKG_LINE_INFO); auto overlays = paths.overlay_ports; - overlays.insert(overlays.begin(), options.command_arguments[1]); + overlays.overlay_ports.insert(overlays.overlay_ports.begin(), options.command_arguments[1]); auto& fs = paths.get_filesystem(); auto registry_set = paths.make_registry_set(); diff --git a/src/vcpkg/commands.find.cpp b/src/vcpkg/commands.find.cpp index d40a307193..a996f83309 100644 --- a/src/vcpkg/commands.find.cpp +++ b/src/vcpkg/commands.find.cpp @@ -133,7 +133,7 @@ namespace vcpkg bool full_description, bool enable_json, Optional filter, - View overlay_ports) + const OverlayPortPaths& overlay_ports) { Checks::check_exit(VCPKG_LINE_INFO, msg::default_output_stream == OutputStream::StdErr); auto& fs = paths.get_filesystem(); diff --git a/src/vcpkg/commands.install.cpp b/src/vcpkg/commands.install.cpp index bbe18da7fe..c591faab0b 100644 --- a/src/vcpkg/commands.install.cpp +++ b/src/vcpkg/commands.install.cpp @@ -1238,16 +1238,14 @@ namespace vcpkg auto verprovider = make_versioned_portfile_provider(*registry_set); auto baseprovider = make_baseline_provider(*registry_set); - std::vector extended_overlay_ports; - extended_overlay_ports.reserve(paths.overlay_ports.size() + add_builtin_ports_directory_as_overlay); - extended_overlay_ports = paths.overlay_ports; + auto extended_overlay_port_directories = paths.overlay_ports; if (add_builtin_ports_directory_as_overlay) { - extended_overlay_ports.emplace_back(paths.builtin_ports_directory()); + extended_overlay_port_directories.overlay_ports.emplace_back(paths.builtin_ports_directory()); } auto oprovider = - make_manifest_provider(fs, extended_overlay_ports, manifest->path, std::move(manifest_scf)); + make_manifest_provider(fs, extended_overlay_port_directories, manifest->path, std::move(manifest_scf)); auto install_plan = create_versioned_install_plan(*verprovider, *baseprovider, *oprovider, diff --git a/src/vcpkg/configuration.cpp b/src/vcpkg/configuration.cpp index 9aa32cd370..61a43bcf0a 100644 --- a/src/vcpkg/configuration.cpp +++ b/src/vcpkg/configuration.cpp @@ -548,6 +548,8 @@ namespace } r.optional_object_field(obj, JsonIdOverlayPorts, ret.overlay_ports, OverlayPathArrayDeserializer::instance); + r.optional_object_field( + obj, JsonIdOverlayPortDirs, ret.overlay_port_dirs, OverlayPathArrayDeserializer::instance); r.optional_object_field( obj, JsonIdOverlayTriplets, ret.overlay_triplets, OverlayTripletsPathArrayDeserializer::instance); @@ -771,6 +773,7 @@ namespace vcpkg JsonIdDefaultRegistry, JsonIdRegistries, JsonIdOverlayPorts, + JsonIdOverlayPortDirs, JsonIdOverlayTriplets, JsonIdMessage, JsonIdWarning, @@ -959,6 +962,15 @@ namespace vcpkg } } + if (!overlay_port_dirs.empty()) + { + auto& opd_arr = obj.insert(JsonIdOverlayPortDirs, Json::Array()); + for (const auto& port : overlay_port_dirs) + { + opd_arr.push_back(port); + } + } + if (!overlay_ports.empty()) { auto& op_arr = obj.insert(JsonIdOverlayPorts, Json::Array()); diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index 8d9c904c20..3edc6e2e49 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -14,6 +15,8 @@ using namespace vcpkg; namespace vcpkg { + bool OverlayPortPaths::empty() const noexcept { return overlay_port_dirs.empty() && overlay_ports.empty(); } + MapPortFileProvider::MapPortFileProvider(const std::unordered_map& map) : ports(map) { @@ -211,10 +214,10 @@ namespace vcpkg struct OverlayProviderImpl : IFullOverlayProvider { - OverlayProviderImpl(const ReadOnlyFilesystem& fs, View overlay_ports) - : m_fs(fs), m_overlay_ports(overlay_ports.begin(), overlay_ports.end()) + OverlayProviderImpl(const ReadOnlyFilesystem& fs, const OverlayPortPaths& overlay_port_paths) + : m_fs(fs), m_overlay_port_paths(overlay_port_paths) { - for (auto&& overlay : m_overlay_ports) + for (auto&& overlay : m_overlay_port_paths.overlay_ports) { Debug::println("Using overlay: ", overlay); @@ -232,7 +235,7 @@ namespace vcpkg { auto s_port_name = port_name.to_string(); - for (auto&& ports_dir : m_overlay_ports) + for (auto&& ports_dir : m_overlay_port_paths.overlay_ports) { // Try loading individual port if (Paragraphs::is_port_directory(m_fs, ports_dir)) @@ -301,8 +304,8 @@ namespace vcpkg virtual void load_all_control_files( std::map& out) const override { - auto first = std::make_reverse_iterator(m_overlay_ports.end()); - const auto last = std::make_reverse_iterator(m_overlay_ports.begin()); + auto first = std::make_reverse_iterator(m_overlay_port_paths.overlay_ports.end()); + const auto last = std::make_reverse_iterator(m_overlay_port_paths.overlay_ports.begin()); for (; first != last; ++first) { auto&& ports_dir = *first; @@ -355,14 +358,14 @@ namespace vcpkg private: const ReadOnlyFilesystem& m_fs; - const std::vector m_overlay_ports; + const OverlayPortPaths m_overlay_port_paths; mutable std::map, std::less<>> m_overlay_cache; }; struct ManifestProviderImpl : IFullOverlayProvider { ManifestProviderImpl(const ReadOnlyFilesystem& fs, - View overlay_ports, + const OverlayPortPaths& overlay_ports, const Path& manifest_path, std::unique_ptr&& manifest_scf) : m_overlay_ports{fs, overlay_ports} @@ -404,13 +407,14 @@ namespace vcpkg return std::make_unique(registry_set); } - std::unique_ptr make_overlay_provider(const ReadOnlyFilesystem& fs, View overlay_ports) + std::unique_ptr make_overlay_provider(const ReadOnlyFilesystem& fs, + const OverlayPortPaths& overlay_ports) { return std::make_unique(fs, overlay_ports); } std::unique_ptr make_manifest_provider(const ReadOnlyFilesystem& fs, - View overlay_ports, + const OverlayPortPaths& overlay_ports, const Path& manifest_path, std::unique_ptr&& manifest_scf) { diff --git a/src/vcpkg/vcpkgcmdarguments.cpp b/src/vcpkg/vcpkgcmdarguments.cpp index 8cdcd62312..26d398c6cb 100644 --- a/src/vcpkg/vcpkgcmdarguments.cpp +++ b/src/vcpkg/vcpkgcmdarguments.cpp @@ -373,11 +373,17 @@ namespace vcpkg } } + args.parser.parse_multi_option( + SwitchOverlayPortDirs, + StabilityTag::Standard, + args.cli_overlay_port_dirs, + msg::format(msgOverlayPortDirsHelp, + msg::env_var = format_environment_variable(EnvironmentVariableVcpkgOverlayPortDirs))); args.parser.parse_multi_option( SwitchOverlayPorts, StabilityTag::Standard, args.cli_overlay_ports, - msg::format(msgOverlayPortsDirectoriesHelp, + msg::format(msgOverlayPortsHelp, msg::env_var = format_environment_variable(EnvironmentVariableVcpkgOverlayPorts))); args.parser.parse_multi_option( SwitchOverlayTriplets, @@ -603,7 +609,13 @@ namespace vcpkg ignore_lock_failures = true; } } - + { + const auto vcpkg_overlay_port_dirs_env = get_env(EnvironmentVariableVcpkgOverlayPortDirs); + if (const auto unpacked = vcpkg_overlay_port_dirs_env.get()) + { + env_overlay_port_dirs = Strings::split_paths(*unpacked); + } + } { const auto vcpkg_overlay_ports_env = get_env(EnvironmentVariableVcpkgOverlayPorts); if (const auto unpacked = vcpkg_overlay_ports_env.get()) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 4742e76c9c..bb350aad50 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -685,11 +685,16 @@ namespace vcpkg std::move(maybe_json_config), m_pimpl->m_config_dir, *this); - overlay_ports = merge_overlays(args.cli_overlay_ports, - args.env_overlay_ports, - original_cwd, - m_pimpl->m_config.config.overlay_ports, - m_pimpl->m_config.directory); + overlay_ports.overlay_port_dirs = merge_overlays(args.cli_overlay_port_dirs, + args.env_overlay_port_dirs, + original_cwd, + m_pimpl->m_config.config.overlay_port_dirs, + m_pimpl->m_config.directory); + overlay_ports.overlay_ports = merge_overlays(args.cli_overlay_ports, + args.env_overlay_ports, + original_cwd, + m_pimpl->m_config.config.overlay_ports, + m_pimpl->m_config.directory); overlay_triplets = merge_overlays(args.cli_overlay_triplets, args.env_overlay_triplets, original_cwd, From ade3d6313ac44322a01f817c602021eda5d47f60 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Thu, 31 Oct 2024 14:56:40 -0700 Subject: [PATCH 02/11] Implement overlay-port-dirs. Behavior change: "shadowed" overlay port dirs are not loaded in 'load all' scenarios anymore. --- include/vcpkg/base/message-data.inc.h | 5 +- include/vcpkg/fwd/portfileprovider.h | 8 + include/vcpkg/paragraphs.h | 3 - include/vcpkg/portfileprovider.h | 38 +++ locales/messages.json | 10 +- src/vcpkg/commands.portsdiff.cpp | 17 +- src/vcpkg/paragraphs.cpp | 36 --- src/vcpkg/portfileprovider.cpp | 412 ++++++++++++++++++-------- 8 files changed, 357 insertions(+), 172 deletions(-) diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index 7dc9c634c8..c6eef0f8ff 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -2060,7 +2060,8 @@ DECLARE_MESSAGE(MismatchedManifestAfterReserialize, DECLARE_MESSAGE(MismatchedNames, (msg::package_name, msg::actual), "{actual} is the port name found", - "names did not match: '{package_name}' != '{actual}'") + "the port name declared in the metadata file did not match the directory. Expected the port to be " + "named {package_name}, but the file declares {actual}.") DECLARE_MESSAGE(MismatchedSpec, (msg::path, msg::expected, msg::actual), "{expected} and {actual} are package specs like 'zlib:x64-windows'", @@ -2194,7 +2195,7 @@ DECLARE_MESSAGE(OptionRequiresOption, DECLARE_MESSAGE(Options, (), "Printed just before a list of options for a command", "Options") DECLARE_MESSAGE(OriginalBinParagraphHeader, (), "", "\nOriginal Binary Paragraph") DECLARE_MESSAGE(OtherCommandsHeader, (), "", "Other") -DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must exist and must be a directory.") +DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must be an existing directory.") DECLARE_MESSAGE(OverlayPortDirsHelp, (msg::env_var), "", diff --git a/include/vcpkg/fwd/portfileprovider.h b/include/vcpkg/fwd/portfileprovider.h index a09dbd9863..2c93a1b66e 100644 --- a/include/vcpkg/fwd/portfileprovider.h +++ b/include/vcpkg/fwd/portfileprovider.h @@ -3,9 +3,17 @@ namespace vcpkg { struct OverlayPortPaths; + struct OverlayPortIndexEntry; struct PortFileProvider; struct PathsPortFileProvider; struct IVersionedPortfileProvider; struct IBaselineProvider; struct IOverlayProvider; + + enum class OverlayPortKind + { + Unknown, // We have not tested yet + Port, // The overlay directory is itself a port + Directory, // The overlay directory itself contains port directories + }; } diff --git a/include/vcpkg/paragraphs.h b/include/vcpkg/paragraphs.h index fc6515a184..fb1b2f5210 100644 --- a/include/vcpkg/paragraphs.h +++ b/include/vcpkg/paragraphs.h @@ -60,7 +60,4 @@ namespace vcpkg::Paragraphs LoadResults try_load_all_registry_ports(const RegistrySet& registries); std::vector load_all_registry_ports(const RegistrySet& registries); - - LoadResults try_load_overlay_ports(const ReadOnlyFilesystem& fs, const Path& dir); - std::vector load_overlay_ports(const ReadOnlyFilesystem& fs, const Path& dir); } diff --git a/include/vcpkg/portfileprovider.h b/include/vcpkg/portfileprovider.h index ebb867743d..e194fa202a 100644 --- a/include/vcpkg/portfileprovider.h +++ b/include/vcpkg/portfileprovider.h @@ -25,6 +25,44 @@ namespace vcpkg bool empty() const noexcept; }; + struct OverlayPortIndexEntry + { + OverlayPortIndexEntry(OverlayPortKind kind, const Path& directory); + OverlayPortIndexEntry(const OverlayPortIndexEntry&) = delete; + OverlayPortIndexEntry(OverlayPortIndexEntry&&); + + const ExpectedL* try_load_port(const ReadOnlyFilesystem& fs, + StringView port_name); + + ExpectedL try_load_all_ports(const ReadOnlyFilesystem& fs, + std::map& out); + + private: + OverlayPortKind m_kind; + Path m_directory; + + using MapT = std::map, std::less<>>; + // If kind == OverlayPortKind::Unknown, empty + // Otherwise, if kind == OverlayPortKind::Port, + // upon load success, contains exactly one entry with the loaded name of the port + // upon load failure, contains exactly one entry with a key of empty string, value being the load error + // Otherwise, if kind == OverlayPortKind::Directory, contains an entry for each loaded overlay-port in the + // directory + MapT m_loaded_ports; + + OverlayPortKind determine_kind(const ReadOnlyFilesystem& fs); + const ExpectedL* try_load_port_cached_port(StringView port_name); + + MapT::iterator try_load_port_subdirectory_uncached(MapT::iterator hint, + const ReadOnlyFilesystem& fs, + StringView port_name); + + ExpectedL load_all_port_subdirectories(const ReadOnlyFilesystem& fs); + + const ExpectedL* try_load_port_subdirectory_with_cache( + const ReadOnlyFilesystem& fs, StringView port_name); + }; + struct PortFileProvider { virtual ~PortFileProvider() = default; diff --git a/locales/messages.json b/locales/messages.json index ba6282e831..fc32521486 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -1132,7 +1132,7 @@ "MismatchedFiles": "file to store does not match hash", "MismatchedManifestAfterReserialize": "The serialized manifest was different from the original manifest. Please open an issue at https://github.com/microsoft/vcpkg, with the following output:", "_MismatchedManifestAfterReserialize.comment": "The original file output and generated output are printed after this line, in English as it's intended to be used in the issue submission and read by devs. This message indicates an internal error in vcpkg.", - "MismatchedNames": "names did not match: '{package_name}' != '{actual}'", + "MismatchedNames": "the port name declared in the metadata file did not match the directory. Expected the port to be named {package_name}, but the file declares {actual}.", "_MismatchedNames.comment": "{actual} is the port name found An example of {package_name} is zlib.", "MismatchedSpec": "Mismatched spec in port {path}: expected {expected}, actual {actual}", "_MismatchedSpec.comment": "{expected} and {actual} are package specs like 'zlib:x64-windows' An example of {path} is /foo/bar.", @@ -1217,10 +1217,12 @@ "_Options.comment": "Printed just before a list of options for a command", "OriginalBinParagraphHeader": "\nOriginal Binary Paragraph", "OtherCommandsHeader": "Other", - "OverlayPatchDir": "Overlay path \"{path}\" must exist and must be a directory.", + "OverlayPatchDir": "Overlay path \"{path}\" must be an existing directory.", "_OverlayPatchDir.comment": "An example of {path} is /foo/bar.", - "OverlayPortsDirectoriesHelp": "Directories of overlay ports (also: {env_var})", - "_OverlayPortsDirectoriesHelp.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", + "OverlayPortDirsHelp": "Directories containing overlay-port directories (also: {env_var})", + "_OverlayPortDirsHelp.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", + "OverlayPortsHelp": "Overlay-port directories, or directories containing overlay-port directories (also: {env_var})", + "_OverlayPortsHelp.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "OverlayTripletDirectoriesHelp": "Directories of overlay triplets (also: {env_var})", "_OverlayTripletDirectoriesHelp.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "OverlayTriplets": "Overlay Triplets from \"{path}\":", diff --git a/src/vcpkg/commands.portsdiff.cpp b/src/vcpkg/commands.portsdiff.cpp index d8fdd046fc..5eddf09d10 100644 --- a/src/vcpkg/commands.portsdiff.cpp +++ b/src/vcpkg/commands.portsdiff.cpp @@ -54,16 +54,15 @@ namespace paths.git_cmd_builder(dot_git_dir, temp_checkout_path).string_arg("reset"), settings), Tools::GIT) .value_or_exit(VCPKG_LINE_INFO); - const auto ports_at_commit = Paragraphs::load_overlay_ports(fs, temp_checkout_path / ports_dir_name); - fs.remove_all(temp_checkout_path, VCPKG_LINE_INFO); - - auto results = Util::fmap(ports_at_commit, [](const SourceControlFileAndLocation& scfl) { - return scfl.source_control_file->to_version_spec(); - }); - Util::sort(results, - [](const VersionSpec& lhs, const VersionSpec& rhs) { return lhs.port_name < rhs.port_name; }); - return results; + OverlayPortIndexEntry ports_at_commit_index(OverlayPortKind::Directory, temp_checkout_path / ports_dir_name); + std::map ports_at_commit; + ports_at_commit_index.try_load_all_ports(fs, ports_at_commit).value_or_exit(VCPKG_LINE_INFO); + fs.remove_all(temp_checkout_path, VCPKG_LINE_INFO); + return Util::fmap(ports_at_commit, + [](const std::pair& cache_entry) { + return cache_entry.second->source_control_file->to_version_spec(); + }); } void check_commit_exists(const VcpkgPaths& paths, StringView git_commit_id) diff --git a/src/vcpkg/paragraphs.cpp b/src/vcpkg/paragraphs.cpp index cd6b512ca7..46efcf3aea 100644 --- a/src/vcpkg/paragraphs.cpp +++ b/src/vcpkg/paragraphs.cpp @@ -578,41 +578,5 @@ namespace vcpkg::Paragraphs return std::move(results.paragraphs); } - LoadResults try_load_overlay_ports(const ReadOnlyFilesystem& fs, const Path& directory) - { - LoadResults ret; - - auto port_dirs = fs.get_directories_non_recursive(directory, VCPKG_LINE_INFO); - Util::sort(port_dirs); - - Util::erase_remove_if(port_dirs, - [&](auto&& port_dir_entry) { return port_dir_entry.filename() == FileDotDsStore; }); - - for (auto&& path : port_dirs) - { - auto port_name = path.filename(); - auto maybe_spgh = try_load_port_required(fs, port_name, PortLocation{path}).maybe_scfl; - if (const auto spgh = maybe_spgh.get()) - { - ret.paragraphs.push_back(std::move(*spgh)); - } - else - { - ret.errors.emplace_back(std::piecewise_construct, - std::forward_as_tuple(port_name.data(), port_name.size()), - std::forward_as_tuple(std::move(maybe_spgh).error())); - } - } - - return ret; - } - - std::vector load_overlay_ports(const ReadOnlyFilesystem& fs, const Path& directory) - { - auto results = try_load_overlay_ports(fs, directory); - load_results_print_error(results); - return std::move(results.paragraphs); - } - uint64_t get_load_ports_stats() { return g_load_ports_stats.load(); } } diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index 3edc6e2e49..bda0bab686 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -11,10 +11,286 @@ #include #include +#include +#include + using namespace vcpkg; namespace vcpkg { + OverlayPortIndexEntry::OverlayPortIndexEntry(OverlayPortKind kind, const Path& directory) + : m_kind(kind), m_directory(directory), m_loaded_ports() + { + if (m_kind == OverlayPortKind::Port) + { + Checks::unreachable(VCPKG_LINE_INFO); + } + } + + OverlayPortIndexEntry::OverlayPortIndexEntry(OverlayPortIndexEntry&&) = default; + + OverlayPortKind OverlayPortIndexEntry::determine_kind(const ReadOnlyFilesystem& fs) + { + if (m_kind == OverlayPortKind::Unknown) + { + if (!m_loaded_ports.empty()) + { + Checks::unreachable(VCPKG_LINE_INFO, "OverlayPortKind::Unknown empty cache constraint violated"); + } + + auto maybe_scfl = Paragraphs::try_load_port(fs, PortLocation{m_directory}).maybe_scfl; + if (auto scfl = maybe_scfl.get()) + { + if (scfl->source_control_file) + { + // succeeded in loading it, so this must be a port + m_kind = OverlayPortKind::Port; + auto name_copy = scfl->to_name(); // copy name before moving maybe_scfl + m_loaded_ports.emplace(name_copy, std::move(maybe_scfl)); + } + else + { + // the directory didn't look like a port at all, consider it an overlay-port-dir + m_kind = OverlayPortKind::Directory; + } + } + else + { + // it looked like a port but we failed to load it for some reason + // succeeded in loading it, so this must be a port + m_kind = OverlayPortKind::Port; + m_loaded_ports.emplace(std::string(), std::move(maybe_scfl)); + } + } + + return m_kind; + } + + const ExpectedL* OverlayPortIndexEntry::try_load_port_cached_port( + StringView port_name) + { + if (m_kind != OverlayPortKind::Port) + { + Checks::unreachable(VCPKG_LINE_INFO); + } + + const auto& this_overlay = *m_loaded_ports.begin(); + if (auto scfl = this_overlay.second.get()) + { + if (scfl->to_name() != port_name) + { + return nullptr; // this overlay-port is OK, but this isn't the right one + } + } + + return &this_overlay.second; + } + + OverlayPortIndexEntry::MapT::iterator OverlayPortIndexEntry::try_load_port_subdirectory_uncached( + MapT::iterator hint, const ReadOnlyFilesystem& fs, StringView port_name) + { + if (m_kind != OverlayPortKind::Directory) + { + Checks::unreachable(VCPKG_LINE_INFO); + } + + auto port_directory = m_directory / port_name; + auto load_result = Paragraphs::try_load_port(fs, PortLocation{port_directory}); + auto& maybe_scfl = load_result.maybe_scfl; + if (auto scfl = maybe_scfl.get()) + { + if (auto scf = scfl->source_control_file.get()) + { + const auto& actual_name = scf->to_name(); + if (actual_name != port_name) + { + maybe_scfl = + LocalizedString::from_raw(scfl->control_path) + .append_raw(": ") + .append_raw(ErrorPrefix) + .append(msgMismatchedNames, msg::package_name = port_name, msg::actual = actual_name); + } + } + else + { + return m_loaded_ports.end(); + } + } + + return m_loaded_ports.emplace_hint(hint, port_name.to_string(), std::move(maybe_scfl)); + } + + const ExpectedL* OverlayPortIndexEntry::try_load_port_subdirectory_with_cache( + const ReadOnlyFilesystem& fs, StringView port_name) + { + if (m_kind != OverlayPortKind::Directory) + { + Checks::unreachable(VCPKG_LINE_INFO); + } + + auto already_loaded = m_loaded_ports.lower_bound(port_name); + if (already_loaded == m_loaded_ports.end() || already_loaded->first != port_name) + { + already_loaded = try_load_port_subdirectory_uncached(already_loaded, fs, port_name); + } + + if (already_loaded == m_loaded_ports.end()) + { + return nullptr; + } + + return &already_loaded->second; + } + + const ExpectedL* OverlayPortIndexEntry::try_load_port(const ReadOnlyFilesystem& fs, + StringView port_name) + { + switch (determine_kind(fs)) + { + case OverlayPortKind::Port: return try_load_port_cached_port(port_name); + case OverlayPortKind::Directory: return try_load_port_subdirectory_with_cache(fs, port_name); + case OverlayPortKind::Unknown: + default: Checks::unreachable(VCPKG_LINE_INFO); + } + } + + ExpectedL OverlayPortIndexEntry::try_load_all_ports( + const ReadOnlyFilesystem& fs, std::map& out) + { + switch (determine_kind(fs)) + { + case OverlayPortKind::Port: + { + auto& maybe_this_port = *m_loaded_ports.begin(); + if (auto this_port = maybe_this_port.second.get()) + { + auto already_in_out = out.lower_bound(maybe_this_port.first); + if (already_in_out == out.end() || already_in_out->first != maybe_this_port.first) + { + out.emplace_hint(already_in_out, maybe_this_port.first, this_port); + } + + return Unit{}; + } + + return maybe_this_port.second.error(); + } + case OverlayPortKind::Directory: + { + auto maybe_subdirectories = fs.try_get_directories_non_recursive(m_directory); + if (auto subdirectories = maybe_subdirectories.get()) + { + std::vector errors; + Util::sort(*subdirectories); + auto first_loaded = m_loaded_ports.begin(); + const auto last_loaded = m_loaded_ports.end(); + auto first_out = out.begin(); + const auto last_out = out.end(); + for (const auto& full_subdirectory : *subdirectories) + { + auto subdirectory = full_subdirectory.filename(); + while (first_out != last_out && first_out->first < subdirectory) + { + ++first_out; + } + + if (first_out != last_out && first_out->first == subdirectory) + { + // this subdirectory is already in the output; we shouldn't replace or attempt to load it + ++first_out; + continue; + } + + while (first_loaded != last_loaded && first_loaded->first < subdirectory) + { + ++first_loaded; + } + + if (first_loaded == last_loaded || first_loaded->first != subdirectory) + { + // the subdirectory isn't cached, load it into the cache + first_loaded = try_load_port_subdirectory_uncached(first_loaded, fs, subdirectory); + } // else: the subdirectory is already loaded + + if (auto this_port = first_loaded->second.get()) + { + first_out = out.emplace_hint(first_out, first_loaded->first, this_port); + ++first_out; + } + else + { + errors.push_back(first_loaded->second.error()); + } + + ++first_loaded; + } + + if (errors.empty()) + { + return Unit{}; + } + + return LocalizedString::from_raw(Strings::join("\n", errors)); + } + + return maybe_subdirectories.error(); + } + case OverlayPortKind::Unknown: + default: Checks::unreachable(VCPKG_LINE_INFO); + } + } + + struct OverlayPortIndex + { + OverlayPortIndex() = delete; + OverlayPortIndex(const OverlayPortIndex&) = delete; + OverlayPortIndex(OverlayPortIndex&&) = default; + + OverlayPortIndex(const OverlayPortPaths& paths) + { + for (auto&& overlay_port_dir : paths.overlay_port_dirs) + { + m_entries.emplace_back(OverlayPortKind::Directory, overlay_port_dir); + } + + for (auto&& overlay_port : paths.overlay_ports) + { + m_entries.emplace_back(OverlayPortKind::Unknown, overlay_port); + } + } + + const ExpectedL* try_load_port(const ReadOnlyFilesystem& fs, StringView port_name) + { + for (auto&& entry : m_entries) + { + auto result = entry.try_load_port(fs, port_name); + if (result) + { + return result; + } + } + + return nullptr; + } + + ExpectedL try_load_all_ports(const ReadOnlyFilesystem& fs, + std::map& out) + { + for (auto&& entry : m_entries) + { + auto result = entry.try_load_all_ports(fs, out); + if (!result) + { + return result; + } + } + + return Unit{}; + } + + std::vector m_entries; + }; + bool OverlayPortPaths::empty() const noexcept { return overlay_port_dirs.empty() && overlay_ports.empty(); } MapPortFileProvider::MapPortFileProvider(const std::unordered_map& map) @@ -215,151 +491,51 @@ namespace vcpkg struct OverlayProviderImpl : IFullOverlayProvider { OverlayProviderImpl(const ReadOnlyFilesystem& fs, const OverlayPortPaths& overlay_port_paths) - : m_fs(fs), m_overlay_port_paths(overlay_port_paths) + : m_fs(fs), m_overlay_index(overlay_port_paths) { - for (auto&& overlay : m_overlay_port_paths.overlay_ports) + for (auto&& overlay : overlay_port_paths.overlay_port_dirs) { - Debug::println("Using overlay: ", overlay); + Debug::println("Using overlay-dir: ", overlay); Checks::msg_check_exit(VCPKG_LINE_INFO, vcpkg::is_directory(m_fs.status(overlay, VCPKG_LINE_INFO)), msgOverlayPatchDir, msg::path = overlay); } - } - - OverlayProviderImpl(const OverlayProviderImpl&) = delete; - OverlayProviderImpl& operator=(const OverlayProviderImpl&) = delete; - - Optional load_port(StringView port_name) const - { - auto s_port_name = port_name.to_string(); - for (auto&& ports_dir : m_overlay_port_paths.overlay_ports) + for (auto&& overlay : overlay_port_paths.overlay_ports) { - // Try loading individual port - if (Paragraphs::is_port_directory(m_fs, ports_dir)) - { - auto maybe_scfl = - Paragraphs::try_load_port_required(m_fs, port_name, PortLocation{ports_dir}).maybe_scfl; - if (auto scfl = maybe_scfl.get()) - { - if (scfl->to_name() == port_name) - { - return std::move(*scfl); - } - } - else - { - print_error_message(maybe_scfl.error()); - msg::println(); - Checks::exit_maybe_upgrade(VCPKG_LINE_INFO); - } - - continue; - } - - auto ports_spec = ports_dir / port_name; - if (Paragraphs::is_port_directory(m_fs, ports_spec)) - { - auto found_scfl = - Paragraphs::try_load_port_required(m_fs, port_name, PortLocation{ports_spec}).maybe_scfl; - if (auto scfl = found_scfl.get()) - { - auto& scfl_name = scfl->to_name(); - if (scfl_name == port_name) - { - return std::move(*scfl); - } + Debug::println("Using overlay: ", overlay); - Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, - LocalizedString::from_raw(ports_spec) - .append_raw(": ") - .append_raw(ErrorPrefix) - .append(msgMismatchedNames, - msg::package_name = port_name, - msg::actual = scfl_name)); - } - else - { - print_error_message(found_scfl.error()); - msg::println(); - Checks::exit_maybe_upgrade(VCPKG_LINE_INFO); - } - } + Checks::msg_check_exit(VCPKG_LINE_INFO, + vcpkg::is_directory(m_fs.status(overlay, VCPKG_LINE_INFO)), + msgOverlayPatchDir, + msg::path = overlay); } - return nullopt; } + OverlayProviderImpl(const OverlayProviderImpl&) = delete; + OverlayProviderImpl& operator=(const OverlayProviderImpl&) = delete; virtual Optional get_control_file(StringView port_name) const override { - auto it = m_overlay_cache.find(port_name); - if (it == m_overlay_cache.end()) + auto loaded = m_overlay_index.try_load_port(m_fs, port_name); + if (loaded) { - it = m_overlay_cache.emplace(port_name.to_string(), load_port(port_name)).first; + return loaded->value_or_exit(VCPKG_LINE_INFO); } - return it->second; + + return nullopt; } virtual void load_all_control_files( std::map& out) const override { - auto first = std::make_reverse_iterator(m_overlay_port_paths.overlay_ports.end()); - const auto last = std::make_reverse_iterator(m_overlay_port_paths.overlay_ports.begin()); - for (; first != last; ++first) - { - auto&& ports_dir = *first; - // Try loading individual port - if (Paragraphs::is_port_directory(m_fs, ports_dir)) - { - auto maybe_scfl = - Paragraphs::try_load_port_required(m_fs, ports_dir.filename(), PortLocation{ports_dir}) - .maybe_scfl; - if (auto scfl = maybe_scfl.get()) - { - // copy name before moving *scfl - auto name = scfl->to_name(); - auto it = m_overlay_cache.emplace(std::move(name), std::move(*scfl)).first; - Checks::check_exit(VCPKG_LINE_INFO, it->second.get()); - out.emplace(it->first, it->second.get()); - } - else - { - print_error_message(maybe_scfl.error()); - msg::println(); - Checks::exit_maybe_upgrade(VCPKG_LINE_INFO); - } - - continue; - } - - // Try loading all ports inside ports_dir - auto results = Paragraphs::try_load_overlay_ports(m_fs, ports_dir); - if (!results.errors.empty()) - { - print_error_message(LocalizedString::from_raw(Strings::join( - "\n", - results.errors, - [](const std::pair& err) -> const LocalizedString& { - return err.second; - }))); - Checks::exit_maybe_upgrade(VCPKG_LINE_INFO); - } - - for (auto&& scfl : results.paragraphs) - { - auto name = scfl.to_name(); - auto it = m_overlay_cache.emplace(std::move(name), std::move(scfl)).first; - Checks::check_exit(VCPKG_LINE_INFO, it->second.get()); - out.emplace(it->first, it->second.get()); - } - } + m_overlay_index.try_load_all_ports(m_fs, out).value_or_exit(VCPKG_LINE_INFO); } private: const ReadOnlyFilesystem& m_fs; - const OverlayPortPaths m_overlay_port_paths; - mutable std::map, std::less<>> m_overlay_cache; + mutable OverlayPortIndex m_overlay_index; }; struct ManifestProviderImpl : IFullOverlayProvider From a0e15201ebd0cf01a18a8ad4b177059baad6630c Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 1 Nov 2024 19:25:49 -0700 Subject: [PATCH 03/11] Add e2e tests. --- .../a/portfile.cmake | 1 + .../overlays-malformed-shadowing/a/vcpkg.json | 4 +++ .../malformed/a/portfile.cmake | 2 ++ .../malformed/a/vcpkg.json | 5 ++++ .../vcpkg-configuration.json | 4 +++ .../overlays-malformed-shadowing/vcpkg.json | 5 ++++ .../another-vcpkg-empty-port/portfile.cmake | 1 + .../another-vcpkg-empty-port/vcpkg.json | 4 +++ .../cli-overlays/portfile.cmake | 1 + .../cli-overlays/vcpkg.json | 4 +++ .../config-overlays/beicode/portfile.cmake | 21 ++++++++++++++ .../config-overlays/beicode/vcpkg.json | 6 ++++ .../config-overlays/portfile.cmake | 1 + .../config-overlays/vcpkg.json | 4 +++ .../env-overlays/portfile.cmake | 1 + .../vcpkg-empty-port/portfile.cmake | 1 + .../env-overlays/vcpkg-empty-port/vcpkg.json | 4 +++ .../env-overlays/vcpkg.json | 4 +++ .../my-triplets/fancy-triplet.cmake | 18 ++++++++++++ .../vcpkg-configuration.json | 4 +++ .../vcpkg.json | 7 +++++ .../end-to-end-tests-dir/overlays.ps1 | 28 ++++++++++++++++--- 22 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json create mode 100644 azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json create mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/portfile.cmake b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/portfile.cmake new file mode 100644 index 0000000000..065116c276 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/vcpkg.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/vcpkg.json new file mode 100644 index 0000000000..dcd0298dbe --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "a", + "version": "0" +} diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/portfile.cmake b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/portfile.cmake new file mode 100644 index 0000000000..c48b693754 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/portfile.cmake @@ -0,0 +1,2 @@ +# This port is intentionally malformed and should not be loaded, because ../../a should be loaded instead +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/vcpkg.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/vcpkg.json new file mode 100644 index 0000000000..4383ff0404 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "a", + "version": "0", + "intentionally-malformed" +} diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json new file mode 100644 index 0000000000..4a241e770e --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json @@ -0,0 +1,4 @@ +{ + "$comment": "'./a' in . should get loaded first, so we should never consider 'malformed/a'", + "overlay-port-dirs": [ ".", "malformed" ] +} diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg.json new file mode 100644 index 0000000000..bf720c8018 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg.json @@ -0,0 +1,5 @@ +{ + "dependencies": [ + "a" + ] +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake new file mode 100644 index 0000000000..065116c276 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json new file mode 100644 index 0000000000..baf6dd9a57 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "another-vcpkg-empty-port", + "version": "0" +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake new file mode 100644 index 0000000000..aef13f8bcf --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "overlay-port-dirs should prevent this directory being interpreted as an overlay-port") diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json new file mode 100644 index 0000000000..baf6dd9a57 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "another-vcpkg-empty-port", + "version": "0" +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake new file mode 100644 index 0000000000..c03dfab71e --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake @@ -0,0 +1,21 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO northwindtraders/beicode + REF 19a1f95c2f56a27ced90227b5e2754a602a08e69 + SHA512 7b2bb7acb2a8ff07bff59cfa27247a7b2cced03828919cd65cc0c8cf1f724f5f1e947ed6992dcdbc913fb470694a52613d1861eaaadbf8903e94eb9cdfe4d000 + HEAD_REF main +) + +vcpkg_configure_cmake( + SOURCE_PATH "${SOURCE_PATH}" + PREFER_NINJA +) +vcpkg_install_cmake() +vcpkg_fixup_cmake_targets() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file( + INSTALL "${SOURCE_PATH}/LICENSE" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" + RENAME copyright) \ No newline at end of file diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json new file mode 100644 index 0000000000..945db90b35 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json @@ -0,0 +1,6 @@ +{ + "name": "beicode", + "version": "1.0.0", + "description": "A simple utf-8 based unicode decoding and encoding library", + "homepage": "https://github.com/northwindtraders/beicode" +} \ No newline at end of file diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake new file mode 100644 index 0000000000..aef13f8bcf --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "overlay-port-dirs should prevent this directory being interpreted as an overlay-port") diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json new file mode 100644 index 0000000000..cd2e87fbe6 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "beicode", + "version": "0" +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake new file mode 100644 index 0000000000..aef13f8bcf --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "overlay-port-dirs should prevent this directory being interpreted as an overlay-port") diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake new file mode 100644 index 0000000000..065116c276 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json new file mode 100644 index 0000000000..1f42aa9278 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "vcpkg-empty-port", + "version": "0" +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json new file mode 100644 index 0000000000..1f42aa9278 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "vcpkg-empty-port", + "version": "0" +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake new file mode 100644 index 0000000000..91a235b525 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake @@ -0,0 +1,18 @@ +if(CMAKE_HOST_WIN32) +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE dynamic) +elseif(CMAKE_HOST_APPLE) +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES x86_64) +else() +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) +endif() diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json new file mode 100644 index 0000000000..d6e6ed2f35 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json @@ -0,0 +1,4 @@ +{ + "overlay-port-dirs": [ "./config-overlays" ], + "overlay-triplets": [ "./my-triplets" ] +} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json new file mode 100644 index 0000000000..797d3da4ea --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json @@ -0,0 +1,7 @@ +{ + "dependencies": [ + "vcpkg-empty-port", + "another-vcpkg-empty-port", + "beicode" + ] +} diff --git a/azure-pipelines/end-to-end-tests-dir/overlays.ps1 b/azure-pipelines/end-to-end-tests-dir/overlays.ps1 index bf58bbf0cf..6d81267757 100644 --- a/azure-pipelines/end-to-end-tests-dir/overlays.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/overlays.ps1 @@ -2,9 +2,11 @@ # Tests a simple project with overlay ports and triplets configured on a vcpkg-configuration.json file Copy-Item -Recurse -LiteralPath @( - "$PSScriptRoot/../e2e-projects/overlays-project-with-config", + "$PSScriptRoot/../e2e-projects/overlays-bad-paths", + "$PSScriptRoot/../e2e-projects/overlays-malformed-shadowing", "$PSScriptRoot/../e2e-projects/overlays-project-config-embedded", - "$PSScriptRoot/../e2e-projects/overlays-bad-paths" + "$PSScriptRoot/../e2e-projects/overlays-project-with-config", + "$PSScriptRoot/../e2e-projects/overlays-project-with-config-dirs" ) $TestingRoot $manifestRoot = "$TestingRoot/overlays-project-with-config" @@ -17,6 +19,19 @@ Run-Vcpkg install --x-manifest-root=$manifestRoot ` --triplet fancy-triplet Throw-IfFailed +# And also with overlay-port-dirs +$manifestRoot = "$TestingRoot/overlays-project-with-config-dirs" +Remove-Item env:VCPKG_OVERLAY_PORTS +$env:VCPKG_OVERLAY_PORT_DIRS = "$manifestRoot/env-overlays" + +Run-Vcpkg install --x-manifest-root=$manifestRoot ` + --overlay-port-dirs=$manifestRoot/cli-overlays ` + --overlay-triplets=$manifestRoot/my-triplets ` + --x-install-root=$installRoot ` + --triplet fancy-triplet +Throw-IfFailed +Remove-Item env:VCPKG_OVERLAY_PORT_DIRS + # Tests overlays configured in env and cli on a project with configuration embedded on the manifest file $manifestRoot = "$TestingRoot/overlays-project-config-embedded" $env:VCPKG_OVERLAY_PORTS = "$manifestRoot/env-overlays" @@ -34,6 +49,12 @@ Run-Vcpkg install --x-manifest-root=$manifestRoot ` --overlay-triplets=$manifestRoot/my-triplets ` --x-install-root=$installRoot Throw-IfNotFailed +Remove-Item env:VCPKG_OVERLAY_PORTS + +# Test that once an overlay port is loaded for a name, subsequent ports are not considered +$manifestRoot = "$TestingRoot/overlays-malformed-shadowing" +Run-Vcpkg install --x-manifest-root=$manifestRoot +Throw-IfFailed # Test overlay_triplet paths remain relative to the manifest root after x-update-baseline $manifestRoot = "$TestingRoot/overlays-project-with-config" @@ -47,11 +68,10 @@ $overlaysAfter = $configurationAfter."overlay-triplets" $notEqual = @(Compare-Object $overlaysBefore $overlaysAfter -SyncWindow 0).Length -ne 0 if ($notEqual) { - Throw "Overlay triplets paths changed after x-update-baseline" + Throw "Overlay triplets paths changed after x-update-baseline" } # Test that removals can happen without the overlay triplets -Remove-Item env:VCPKG_OVERLAY_PORTS Refresh-TestRoot Run-Vcpkg install another-vcpkg-empty-port:fancy-triplet ` --overlay-ports=$PSScriptRoot/../e2e-projects/overlays-project-with-config/cli-overlays ` From 327a15f04524e428751e4a093d558f7c47f44322 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 1 Nov 2024 19:28:29 -0700 Subject: [PATCH 04/11] Down with is_port_directory. --- include/vcpkg/paragraphs.h | 2 -- src/vcpkg/paragraphs.cpp | 6 ------ 2 files changed, 8 deletions(-) diff --git a/include/vcpkg/paragraphs.h b/include/vcpkg/paragraphs.h index fb1b2f5210..99b2f858e1 100644 --- a/include/vcpkg/paragraphs.h +++ b/include/vcpkg/paragraphs.h @@ -24,8 +24,6 @@ namespace vcpkg::Paragraphs ExpectedL> parse_paragraphs(StringView str, StringView origin); - bool is_port_directory(const ReadOnlyFilesystem& fs, const Path& maybe_directory); - struct PortLoadResult { ExpectedL maybe_scfl; diff --git a/src/vcpkg/paragraphs.cpp b/src/vcpkg/paragraphs.cpp index 46efcf3aea..09c22262b1 100644 --- a/src/vcpkg/paragraphs.cpp +++ b/src/vcpkg/paragraphs.cpp @@ -352,12 +352,6 @@ namespace vcpkg::Paragraphs return PghParser(str, origin).get_paragraphs(); } - bool is_port_directory(const ReadOnlyFilesystem& fs, const Path& maybe_directory) - { - return fs.exists(maybe_directory / "CONTROL", IgnoreErrors{}) || - fs.exists(maybe_directory / "vcpkg.json", IgnoreErrors{}); - } - ExpectedL> try_load_project_manifest_text(StringView text, StringView control_path, MessageSink& warning_sink) From 075b59521c6d4e3878e29f4c3ef1402c12912659 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Fri, 1 Nov 2024 20:39:45 -0700 Subject: [PATCH 05/11] Delete copy pasto comment. --- src/vcpkg/portfileprovider.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index bda0bab686..08ac747bc2 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -57,7 +57,6 @@ namespace vcpkg else { // it looked like a port but we failed to load it for some reason - // succeeded in loading it, so this must be a port m_kind = OverlayPortKind::Port; m_loaded_ports.emplace(std::string(), std::move(maybe_scfl)); } From c0007963e31cdbe31731efd23ed12afbaf768718 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 8 Nov 2024 15:39:17 -0800 Subject: [PATCH 06/11] Make attempting to set overlay-ports or overlay-port-dirs to be the manifest directory an error. --- .../overlays-dot/vcpkg-configuration.json | 3 ++ .../e2e-projects/overlays-dot/vcpkg.json | 5 ++ .../{ => config-overlays}/a/portfile.cmake | 0 .../{ => config-overlays}/a/vcpkg.json | 0 .../malformed/a/portfile.cmake | 0 .../malformed/a/vcpkg.json | 0 .../vcpkg-configuration.json | 4 +- .../vcpkg-configuration.json | 3 ++ .../overlays-not-quite-dot/vcpkg.json | 5 ++ .../end-to-end-tests-dir/overlays.ps1 | 47 ++++++++++++++++++- include/vcpkg/base/message-data.inc.h | 10 ++++ locales/messages.json | 3 ++ src/vcpkg/vcpkgpaths.cpp | 41 ++++++++++++---- 13 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json create mode 100644 azure-pipelines/e2e-projects/overlays-dot/vcpkg.json rename azure-pipelines/e2e-projects/overlays-malformed-shadowing/{ => config-overlays}/a/portfile.cmake (100%) rename azure-pipelines/e2e-projects/overlays-malformed-shadowing/{ => config-overlays}/a/vcpkg.json (100%) rename azure-pipelines/e2e-projects/overlays-malformed-shadowing/{ => config-overlays}/malformed/a/portfile.cmake (100%) rename azure-pipelines/e2e-projects/overlays-malformed-shadowing/{ => config-overlays}/malformed/a/vcpkg.json (100%) create mode 100644 azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json create mode 100644 azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg.json diff --git a/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json new file mode 100644 index 0000000000..a1667fc2d1 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json @@ -0,0 +1,3 @@ +{ + "overlay-port-dirs": [ "." ] +} diff --git a/azure-pipelines/e2e-projects/overlays-dot/vcpkg.json b/azure-pipelines/e2e-projects/overlays-dot/vcpkg.json new file mode 100644 index 0000000000..bf720c8018 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-dot/vcpkg.json @@ -0,0 +1,5 @@ +{ + "dependencies": [ + "a" + ] +} diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/portfile.cmake b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/a/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/portfile.cmake rename to azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/a/portfile.cmake diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/vcpkg.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/a/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-projects/overlays-malformed-shadowing/a/vcpkg.json rename to azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/a/vcpkg.json diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/portfile.cmake b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/malformed/a/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/portfile.cmake rename to azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/malformed/a/portfile.cmake diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/vcpkg.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/malformed/a/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-projects/overlays-malformed-shadowing/malformed/a/vcpkg.json rename to azure-pipelines/e2e-projects/overlays-malformed-shadowing/config-overlays/malformed/a/vcpkg.json diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json index 4a241e770e..88a24a9219 100644 --- a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json @@ -1,4 +1,4 @@ { - "$comment": "'./a' in . should get loaded first, so we should never consider 'malformed/a'", - "overlay-port-dirs": [ ".", "malformed" ] + "$comment": "'config-overlays/a' in . should get loaded first, so we should never consider 'config-overlays/malformed/a'", + "overlay-port-dirs": [ "config-overlays", "config-overlays/malformed" ] } diff --git a/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json new file mode 100644 index 0000000000..ddd81de124 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json @@ -0,0 +1,3 @@ +{ + "overlay-port-dirs": [ "./hello/.." ] +} diff --git a/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg.json b/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg.json new file mode 100644 index 0000000000..bf720c8018 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg.json @@ -0,0 +1,5 @@ +{ + "dependencies": [ + "a" + ] +} diff --git a/azure-pipelines/end-to-end-tests-dir/overlays.ps1 b/azure-pipelines/end-to-end-tests-dir/overlays.ps1 index 6d81267757..ab77531494 100644 --- a/azure-pipelines/end-to-end-tests-dir/overlays.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/overlays.ps1 @@ -2,7 +2,6 @@ # Tests a simple project with overlay ports and triplets configured on a vcpkg-configuration.json file Copy-Item -Recurse -LiteralPath @( - "$PSScriptRoot/../e2e-projects/overlays-bad-paths", "$PSScriptRoot/../e2e-projects/overlays-malformed-shadowing", "$PSScriptRoot/../e2e-projects/overlays-project-config-embedded", "$PSScriptRoot/../e2e-projects/overlays-project-with-config", @@ -21,6 +20,7 @@ Throw-IfFailed # And also with overlay-port-dirs $manifestRoot = "$TestingRoot/overlays-project-with-config-dirs" +$canonicalManifestRoot = (Get-Item $manifestRoot).FullName Remove-Item env:VCPKG_OVERLAY_PORTS $env:VCPKG_OVERLAY_PORT_DIRS = "$manifestRoot/env-overlays" @@ -30,6 +30,19 @@ Run-Vcpkg install --x-manifest-root=$manifestRoot ` --x-install-root=$installRoot ` --triplet fancy-triplet Throw-IfFailed + +# ... but not if the manifest directory is an overlay +$output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot ` + --overlay-port-dirs=$manifestRoot ` + --overlay-port-dirs=$manifestRoot/cli-overlays ` + --overlay-triplets=$manifestRoot/my-triplets ` + --x-install-root=$installRoot ` + --triplet fancy-triplet +Throw-IfNotFailed +Throw-IfNonContains -Actual $output -Expected @" +The manifest directory ($canonicalManifestRoot) cannot be the same as a directory configured as an overlay-port or overlay-port-dir. +"@ + Remove-Item env:VCPKG_OVERLAY_PORT_DIRS # Tests overlays configured in env and cli on a project with configuration embedded on the manifest file @@ -42,8 +55,21 @@ Run-Vcpkg install --x-manifest-root=$manifestRoot ` --triplet fancy-config-embedded-triplet Throw-IfFailed +# ... and with command line overlay-ports being 'dot' +pushd "$manifestRoot/cli-overlays" +try { + Run-Vcpkg install --x-manifest-root=$manifestRoot ` + --overlay-ports=. ` + --overlay-triplets=$manifestRoot/my-triplets ` + --x-install-root=$installRoot ` + --triplet fancy-config-embedded-triplet + Throw-IfFailed +} finally { + popd +} + # Config with bad paths -$manifestRoot = "$TestingRoot/overlays-bad-paths" +$manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-bad-paths" $env:VCPKG_OVERLAY_PORTS = "$manifestRoot/env_overlays" Run-Vcpkg install --x-manifest-root=$manifestRoot ` --overlay-triplets=$manifestRoot/my-triplets ` @@ -71,6 +97,23 @@ if ($notEqual) { Throw "Overlay triplets paths changed after x-update-baseline" } +# Test that trying to declare overlay-ports as '.' fails +$manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-dot" +$output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot --x-install-root=$installRoot +Throw-IfNotFailed +Throw-IfNonContains -Actual $output -Expected @" +error: The manifest directory cannot be the same as a directory configured as an overlay-port or overlay-port-dir, so "overlay-ports" and "overlay-port-dir" values cannot be ".". +"@ + +# Test that trying to declare overlay-ports as the same directory in a roundabout way fails +$manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-not-quite-dot" +$canonicalManifestRoot = (Get-Item $manifestRoot).FullName +$output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot --x-install-root=$installRoot +Throw-IfNotFailed +Throw-IfNonContains -Actual $output -Expected @" +The manifest directory ($canonicalManifestRoot) cannot be the same as a directory configured as an overlay-port or overlay-port-dir. +"@ + # Test that removals can happen without the overlay triplets Refresh-TestRoot Run-Vcpkg install another-vcpkg-empty-port:fancy-triplet ` diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index 2922d6456a..ecef97762d 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -1099,6 +1099,16 @@ DECLARE_MESSAGE(ErrorInvalidManifestModeOption, (msg::option), "", "The option --{option} is not supported in manifest mode.") +DECLARE_MESSAGE(ErrorManifestMustDifferFromOverlay, + (msg::path), + "", + "The manifest directory ({path}) cannot be the same as a directory configured as an overlay-port or " + "overlay-port-dir.") +DECLARE_MESSAGE(ErrorManifestMustDifferFromOverlayDot, + (), + "", + "The manifest directory cannot be the same as a directory configured as an overlay-port or " + "overlay-port-dir, so \"overlay-ports\" and \"overlay-port-dir\" values cannot be \".\".") DECLARE_MESSAGE( ErrorMissingVcpkgRoot, (), diff --git a/locales/messages.json b/locales/messages.json index b5e34b11b8..9770d0d161 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -646,6 +646,9 @@ "_ErrorInvalidExtractOption.comment": "The keyword 'AUTO' should not be localized An example of {option} is editable.", "ErrorInvalidManifestModeOption": "The option --{option} is not supported in manifest mode.", "_ErrorInvalidManifestModeOption.comment": "An example of {option} is editable.", + "ErrorManifestMustDifferFromOverlay": "The manifest directory ({path}) cannot be the same as a directory configured as an overlay-port or overlay-port-dir.", + "_ErrorManifestMustDifferFromOverlay.comment": "An example of {path} is /foo/bar.", + "ErrorManifestMustDifferFromOverlayDot": "The manifest directory cannot be the same as a directory configured as an overlay-port or overlay-port-dir, so \"overlay-ports\" and \"overlay-port-dir\" values cannot be \".\".", "ErrorMissingVcpkgRoot": "Could not detect vcpkg-root. If you are trying to use a copy of vcpkg that you've built, you must define the VCPKG_ROOT environment variable to point to a cloned copy of https://github.com/Microsoft/vcpkg.", "ErrorNoVSInstance": "in triplet {triplet}: Unable to find a valid Visual Studio instance", "_ErrorNoVSInstance.comment": "An example of {triplet} is x64-windows.", diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index bb350aad50..466054153a 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -99,29 +99,46 @@ namespace } static void append_overlays(std::vector& result, + const ReadOnlyFilesystem& fs, const std::vector& overlay_entries, - const Path& relative_root) + const Path& relative_root, + const Path& config_directory, + bool forbid_dot) { for (auto&& entry : overlay_entries) { - result.push_back(relative_root / entry); + if (forbid_dot && entry == ".") + { + Checks::msg_exit_with_error(VCPKG_LINE_INFO, msgErrorManifestMustDifferFromOverlayDot); + } + + auto full_entry = fs.almost_canonical(relative_root / entry, VCPKG_LINE_INFO); + if (full_entry == config_directory) + { + Checks::msg_exit_with_error( + VCPKG_LINE_INFO, msgErrorManifestMustDifferFromOverlay, msg::path = config_directory); + } + + result.push_back(std::move(full_entry)); } } // Merges overlay settings from the 3 major sources in the usual priority order, where command line wins first, then // manifest, then environment. The parameter order is specifically chosen to group information that comes from the // manifest together and make parameter order confusion less likely to compile. - static std::vector merge_overlays(const std::vector& cli_overlays, + static std::vector merge_overlays(const ReadOnlyFilesystem& fs, + const std::vector& cli_overlays, const std::vector& env_overlays, const Path& original_cwd, + bool forbid_config_dot, const std::vector& config_overlays, const Path& config_directory) { std::vector result; result.reserve(cli_overlays.size() + config_overlays.size() + env_overlays.size()); - append_overlays(result, cli_overlays, original_cwd); - append_overlays(result, config_overlays, config_directory); - append_overlays(result, env_overlays, original_cwd); + append_overlays(result, fs, cli_overlays, original_cwd, config_directory, false); + append_overlays(result, fs, config_overlays, config_directory, config_directory, forbid_config_dot); + append_overlays(result, fs, env_overlays, original_cwd, config_directory, false); return result; } @@ -685,19 +702,25 @@ namespace vcpkg std::move(maybe_json_config), m_pimpl->m_config_dir, *this); - overlay_ports.overlay_port_dirs = merge_overlays(args.cli_overlay_port_dirs, + overlay_ports.overlay_port_dirs = merge_overlays(m_pimpl->m_fs, + args.cli_overlay_port_dirs, args.env_overlay_port_dirs, original_cwd, + true, m_pimpl->m_config.config.overlay_port_dirs, m_pimpl->m_config.directory); - overlay_ports.overlay_ports = merge_overlays(args.cli_overlay_ports, + overlay_ports.overlay_ports = merge_overlays(m_pimpl->m_fs, + args.cli_overlay_ports, args.env_overlay_ports, original_cwd, + true, m_pimpl->m_config.config.overlay_ports, m_pimpl->m_config.directory); - overlay_triplets = merge_overlays(args.cli_overlay_triplets, + overlay_triplets = merge_overlays(m_pimpl->m_fs, + args.cli_overlay_triplets, args.env_overlay_triplets, original_cwd, + false, m_pimpl->m_config.config.overlay_triplets, m_pimpl->m_config.directory); for (const auto& triplet : this->overlay_triplets) From faddc4ad09a65706d91844d06235635a3db9ae03 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 8 Nov 2024 16:01:03 -0800 Subject: [PATCH 07/11] Avoid canonicalizing overlay-paths on the command line in console output. --- src/vcpkg/vcpkgpaths.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 06c2de0251..9c11e21bb8 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -112,8 +112,8 @@ namespace Checks::msg_exit_with_error(VCPKG_LINE_INFO, msgErrorManifestMustDifferFromOverlayDot); } - auto full_entry = fs.almost_canonical(relative_root / entry, VCPKG_LINE_INFO); - if (full_entry == config_directory) + auto full_entry = relative_root / entry; + if (fs.almost_canonical(full_entry, VCPKG_LINE_INFO) == config_directory) { Checks::msg_exit_with_error( VCPKG_LINE_INFO, msgErrorManifestMustDifferFromOverlay, msg::path = config_directory); From 14afed239f829dde4234dd4b8a36847978a19618 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Wed, 13 Nov 2024 12:47:19 -0800 Subject: [PATCH 08/11] Delete the actual overlay-port-dirs feature. --- .../overlays-dot/vcpkg-configuration.json | 2 +- .../vcpkg-configuration.json | 2 +- .../vcpkg-configuration.json | 2 +- .../another-vcpkg-empty-port/portfile.cmake | 1 - .../another-vcpkg-empty-port/vcpkg.json | 4 -- .../cli-overlays/portfile.cmake | 1 - .../cli-overlays/vcpkg.json | 4 -- .../config-overlays/beicode/portfile.cmake | 21 -------- .../config-overlays/beicode/vcpkg.json | 6 --- .../config-overlays/portfile.cmake | 1 - .../config-overlays/vcpkg.json | 4 -- .../env-overlays/portfile.cmake | 1 - .../vcpkg-empty-port/portfile.cmake | 1 - .../env-overlays/vcpkg-empty-port/vcpkg.json | 4 -- .../env-overlays/vcpkg.json | 4 -- .../my-triplets/fancy-triplet.cmake | 18 ------- .../vcpkg-configuration.json | 4 -- .../vcpkg.json | 7 --- .../end-to-end-tests-dir/overlays.ps1 | 34 ++----------- docs/vcpkg-configuration.schema.json | 7 --- include/vcpkg/base/contractual-constants.h | 3 -- include/vcpkg/base/message-data.inc.h | 11 ++--- include/vcpkg/configuration.h | 1 - include/vcpkg/portfileprovider.h | 4 +- include/vcpkg/vcpkgcmdarguments.h | 2 - locales/messages.json | 6 +-- src/vcpkg/commands.install.cpp | 2 +- src/vcpkg/configuration.cpp | 12 ----- src/vcpkg/portfileprovider.cpp | 48 ++++++++++--------- src/vcpkg/vcpkgcmdarguments.cpp | 14 +----- src/vcpkg/vcpkgpaths.cpp | 9 +--- 31 files changed, 43 insertions(+), 197 deletions(-) delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json delete mode 100644 azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json diff --git a/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json index a1667fc2d1..8bf3475a84 100644 --- a/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json +++ b/azure-pipelines/e2e-projects/overlays-dot/vcpkg-configuration.json @@ -1,3 +1,3 @@ { - "overlay-port-dirs": [ "." ] + "overlay-ports": [ "." ] } diff --git a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json index 88a24a9219..cbf8b52cfe 100644 --- a/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json +++ b/azure-pipelines/e2e-projects/overlays-malformed-shadowing/vcpkg-configuration.json @@ -1,4 +1,4 @@ { "$comment": "'config-overlays/a' in . should get loaded first, so we should never consider 'config-overlays/malformed/a'", - "overlay-port-dirs": [ "config-overlays", "config-overlays/malformed" ] + "overlay-ports": [ "config-overlays", "config-overlays/malformed" ] } diff --git a/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json index ddd81de124..dfbb7f3ebc 100644 --- a/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json +++ b/azure-pipelines/e2e-projects/overlays-not-quite-dot/vcpkg-configuration.json @@ -1,3 +1,3 @@ { - "overlay-port-dirs": [ "./hello/.." ] + "overlay-ports": [ "./hello/.." ] } diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake deleted file mode 100644 index 065116c276..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/portfile.cmake +++ /dev/null @@ -1 +0,0 @@ -set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json deleted file mode 100644 index baf6dd9a57..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/another-vcpkg-empty-port/vcpkg.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "another-vcpkg-empty-port", - "version": "0" -} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake deleted file mode 100644 index aef13f8bcf..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/portfile.cmake +++ /dev/null @@ -1 +0,0 @@ -message(FATAL_ERROR "overlay-port-dirs should prevent this directory being interpreted as an overlay-port") diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json deleted file mode 100644 index baf6dd9a57..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/cli-overlays/vcpkg.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "another-vcpkg-empty-port", - "version": "0" -} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake deleted file mode 100644 index c03dfab71e..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/portfile.cmake +++ /dev/null @@ -1,21 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO northwindtraders/beicode - REF 19a1f95c2f56a27ced90227b5e2754a602a08e69 - SHA512 7b2bb7acb2a8ff07bff59cfa27247a7b2cced03828919cd65cc0c8cf1f724f5f1e947ed6992dcdbc913fb470694a52613d1861eaaadbf8903e94eb9cdfe4d000 - HEAD_REF main -) - -vcpkg_configure_cmake( - SOURCE_PATH "${SOURCE_PATH}" - PREFER_NINJA -) -vcpkg_install_cmake() -vcpkg_fixup_cmake_targets() - -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - -file( - INSTALL "${SOURCE_PATH}/LICENSE" - DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" - RENAME copyright) \ No newline at end of file diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json deleted file mode 100644 index 945db90b35..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/beicode/vcpkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "beicode", - "version": "1.0.0", - "description": "A simple utf-8 based unicode decoding and encoding library", - "homepage": "https://github.com/northwindtraders/beicode" -} \ No newline at end of file diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake deleted file mode 100644 index aef13f8bcf..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/portfile.cmake +++ /dev/null @@ -1 +0,0 @@ -message(FATAL_ERROR "overlay-port-dirs should prevent this directory being interpreted as an overlay-port") diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json deleted file mode 100644 index cd2e87fbe6..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/config-overlays/vcpkg.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "beicode", - "version": "0" -} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake deleted file mode 100644 index aef13f8bcf..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/portfile.cmake +++ /dev/null @@ -1 +0,0 @@ -message(FATAL_ERROR "overlay-port-dirs should prevent this directory being interpreted as an overlay-port") diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake deleted file mode 100644 index 065116c276..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/portfile.cmake +++ /dev/null @@ -1 +0,0 @@ -set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json deleted file mode 100644 index 1f42aa9278..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg-empty-port/vcpkg.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "vcpkg-empty-port", - "version": "0" -} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json deleted file mode 100644 index 1f42aa9278..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/env-overlays/vcpkg.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "vcpkg-empty-port", - "version": "0" -} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake deleted file mode 100644 index 91a235b525..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/my-triplets/fancy-triplet.cmake +++ /dev/null @@ -1,18 +0,0 @@ -if(CMAKE_HOST_WIN32) -set(VCPKG_TARGET_ARCHITECTURE x64) -set(VCPKG_CRT_LINKAGE static) -set(VCPKG_LIBRARY_LINKAGE dynamic) -elseif(CMAKE_HOST_APPLE) -set(VCPKG_TARGET_ARCHITECTURE x64) -set(VCPKG_CRT_LINKAGE dynamic) -set(VCPKG_LIBRARY_LINKAGE static) - -set(VCPKG_CMAKE_SYSTEM_NAME Darwin) -set(VCPKG_OSX_ARCHITECTURES x86_64) -else() -set(VCPKG_TARGET_ARCHITECTURE x64) -set(VCPKG_CRT_LINKAGE dynamic) -set(VCPKG_LIBRARY_LINKAGE static) - -set(VCPKG_CMAKE_SYSTEM_NAME Linux) -endif() diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json deleted file mode 100644 index d6e6ed2f35..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg-configuration.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "overlay-port-dirs": [ "./config-overlays" ], - "overlay-triplets": [ "./my-triplets" ] -} diff --git a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json b/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json deleted file mode 100644 index 797d3da4ea..0000000000 --- a/azure-pipelines/e2e-projects/overlays-project-with-config-dirs/vcpkg.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dependencies": [ - "vcpkg-empty-port", - "another-vcpkg-empty-port", - "beicode" - ] -} diff --git a/azure-pipelines/end-to-end-tests-dir/overlays.ps1 b/azure-pipelines/end-to-end-tests-dir/overlays.ps1 index ab77531494..9f32317f07 100644 --- a/azure-pipelines/end-to-end-tests-dir/overlays.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/overlays.ps1 @@ -4,8 +4,7 @@ Copy-Item -Recurse -LiteralPath @( "$PSScriptRoot/../e2e-projects/overlays-malformed-shadowing", "$PSScriptRoot/../e2e-projects/overlays-project-config-embedded", - "$PSScriptRoot/../e2e-projects/overlays-project-with-config", - "$PSScriptRoot/../e2e-projects/overlays-project-with-config-dirs" + "$PSScriptRoot/../e2e-projects/overlays-project-with-config" ) $TestingRoot $manifestRoot = "$TestingRoot/overlays-project-with-config" @@ -18,33 +17,6 @@ Run-Vcpkg install --x-manifest-root=$manifestRoot ` --triplet fancy-triplet Throw-IfFailed -# And also with overlay-port-dirs -$manifestRoot = "$TestingRoot/overlays-project-with-config-dirs" -$canonicalManifestRoot = (Get-Item $manifestRoot).FullName -Remove-Item env:VCPKG_OVERLAY_PORTS -$env:VCPKG_OVERLAY_PORT_DIRS = "$manifestRoot/env-overlays" - -Run-Vcpkg install --x-manifest-root=$manifestRoot ` - --overlay-port-dirs=$manifestRoot/cli-overlays ` - --overlay-triplets=$manifestRoot/my-triplets ` - --x-install-root=$installRoot ` - --triplet fancy-triplet -Throw-IfFailed - -# ... but not if the manifest directory is an overlay -$output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot ` - --overlay-port-dirs=$manifestRoot ` - --overlay-port-dirs=$manifestRoot/cli-overlays ` - --overlay-triplets=$manifestRoot/my-triplets ` - --x-install-root=$installRoot ` - --triplet fancy-triplet -Throw-IfNotFailed -Throw-IfNonContains -Actual $output -Expected @" -The manifest directory ($canonicalManifestRoot) cannot be the same as a directory configured as an overlay-port or overlay-port-dir. -"@ - -Remove-Item env:VCPKG_OVERLAY_PORT_DIRS - # Tests overlays configured in env and cli on a project with configuration embedded on the manifest file $manifestRoot = "$TestingRoot/overlays-project-config-embedded" $env:VCPKG_OVERLAY_PORTS = "$manifestRoot/env-overlays" @@ -102,7 +74,7 @@ $manifestRoot = "$PSScriptRoot/../e2e-projects/overlays-dot" $output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot --x-install-root=$installRoot Throw-IfNotFailed Throw-IfNonContains -Actual $output -Expected @" -error: The manifest directory cannot be the same as a directory configured as an overlay-port or overlay-port-dir, so "overlay-ports" and "overlay-port-dir" values cannot be ".". +error: The manifest directory cannot be the same as a directory configured in overlay-ports, so "overlay-ports" values cannot be ".". "@ # Test that trying to declare overlay-ports as the same directory in a roundabout way fails @@ -111,7 +83,7 @@ $canonicalManifestRoot = (Get-Item $manifestRoot).FullName $output = Run-VcpkgAndCaptureStdErr install --x-manifest-root=$manifestRoot --x-install-root=$installRoot Throw-IfNotFailed Throw-IfNonContains -Actual $output -Expected @" -The manifest directory ($canonicalManifestRoot) cannot be the same as a directory configured as an overlay-port or overlay-port-dir. +The manifest directory ($canonicalManifestRoot) cannot be the same as a directory configured in overlay-ports. "@ # Test that removals can happen without the overlay triplets diff --git a/docs/vcpkg-configuration.schema.json b/docs/vcpkg-configuration.schema.json index 949d61d1d6..eb0aa2461d 100644 --- a/docs/vcpkg-configuration.schema.json +++ b/docs/vcpkg-configuration.schema.json @@ -21,13 +21,6 @@ "type": "string", "description": "A message to print if this entry is evaluated." }, - "overlay-port-dirs": { - "type": "array", - "description": "An array of port overlay directory paths.", - "items": { - "type": "string" - } - }, "overlay-ports": { "type": "array", "description": "An array of port overlay paths.", diff --git a/include/vcpkg/base/contractual-constants.h b/include/vcpkg/base/contractual-constants.h index ee77642efe..1dd7d6fbc9 100644 --- a/include/vcpkg/base/contractual-constants.h +++ b/include/vcpkg/base/contractual-constants.h @@ -69,7 +69,6 @@ namespace vcpkg inline constexpr StringLiteral JsonIdMicrosoft = "microsoft"; inline constexpr StringLiteral JsonIdName = "name"; inline constexpr StringLiteral JsonIdOverlayPorts = "overlay-ports"; - inline constexpr StringLiteral JsonIdOverlayPortDirs = "overlay-port-dirs"; inline constexpr StringLiteral JsonIdOverlayTriplets = "overlay-triplets"; inline constexpr StringLiteral JsonIdOverrides = "overrides"; inline constexpr StringLiteral JsonIdPackages = "packages"; @@ -252,7 +251,6 @@ namespace vcpkg inline constexpr StringLiteral SwitchOutput = "output"; inline constexpr StringLiteral SwitchOutputDir = "output-dir"; inline constexpr StringLiteral SwitchOutputHashes = "output-hashes"; - inline constexpr StringLiteral SwitchOverlayPortDirs = "overlay-port-dirs"; inline constexpr StringLiteral SwitchOverlayPorts = "overlay-ports"; inline constexpr StringLiteral SwitchOverlayTriplets = "overlay-triplets"; inline constexpr StringLiteral SwitchOverwriteVersion = "overwrite-version"; @@ -537,7 +535,6 @@ namespace vcpkg inline constexpr StringLiteral EnvironmentVariableVcpkgMaxConcurrency = "VCPKG_MAX_CONCURRENCY"; inline constexpr StringLiteral EnvironmentVariableVcpkgNoCi = "VCPKG_NO_CI"; inline constexpr StringLiteral EnvironmentVariableVcpkgNuGetRepository = "VCPKG_NUGET_REPOSITORY"; - inline constexpr StringLiteral EnvironmentVariableVcpkgOverlayPortDirs = "VCPKG_OVERLAY_PORT_DIRS"; inline constexpr StringLiteral EnvironmentVariableVcpkgOverlayPorts = "VCPKG_OVERLAY_PORTS"; inline constexpr StringLiteral EnvironmentVariableVcpkgRoot = "VCPKG_ROOT"; inline constexpr StringLiteral EnvironmentVariableVcpkgUseNuGetCache = "VCPKG_USE_NUGET_CACHE"; diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index b8a2cbba55..3e2ce4e735 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -1123,13 +1123,12 @@ DECLARE_MESSAGE(ErrorInvalidManifestModeOption, DECLARE_MESSAGE(ErrorManifestMustDifferFromOverlay, (msg::path), "", - "The manifest directory ({path}) cannot be the same as a directory configured as an overlay-port or " - "overlay-port-dir.") + "The manifest directory ({path}) cannot be the same as a directory configured in overlay-ports.") DECLARE_MESSAGE(ErrorManifestMustDifferFromOverlayDot, (), "", - "The manifest directory cannot be the same as a directory configured as an overlay-port or " - "overlay-port-dir, so \"overlay-ports\" and \"overlay-port-dir\" values cannot be \".\".") + "The manifest directory cannot be the same as a directory configured in overlay-ports, so " + "\"overlay-ports\" values cannot be \".\".") DECLARE_MESSAGE( ErrorMissingVcpkgRoot, (), @@ -2236,10 +2235,6 @@ DECLARE_MESSAGE(Options, (), "Printed just before a list of options for a comman DECLARE_MESSAGE(OriginalBinParagraphHeader, (), "", "\nOriginal Binary Paragraph") DECLARE_MESSAGE(OtherCommandsHeader, (), "", "Other") DECLARE_MESSAGE(OverlayPatchDir, (msg::path), "", "Overlay path \"{path}\" must be an existing directory.") -DECLARE_MESSAGE(OverlayPortDirsHelp, - (msg::env_var), - "", - "Directories containing overlay-port directories (also: {env_var})") DECLARE_MESSAGE(OverlayPortsHelp, (msg::env_var), "", diff --git a/include/vcpkg/configuration.h b/include/vcpkg/configuration.h index ac9c416e79..79d4d0fe9f 100644 --- a/include/vcpkg/configuration.h +++ b/include/vcpkg/configuration.h @@ -51,7 +51,6 @@ namespace vcpkg std::vector registries; Json::Object ce_metadata; Json::Object extra_info; - std::vector overlay_port_dirs; std::vector overlay_ports; std::vector overlay_triplets; diff --git a/include/vcpkg/portfileprovider.h b/include/vcpkg/portfileprovider.h index e194fa202a..312e26d66f 100644 --- a/include/vcpkg/portfileprovider.h +++ b/include/vcpkg/portfileprovider.h @@ -19,7 +19,7 @@ namespace vcpkg { struct OverlayPortPaths { - std::vector overlay_port_dirs; + Optional builtin_overlay_port_dir; std::vector overlay_ports; bool empty() const noexcept; @@ -37,6 +37,8 @@ namespace vcpkg ExpectedL try_load_all_ports(const ReadOnlyFilesystem& fs, std::map& out); + void check_directory(const ReadOnlyFilesystem& fs) const; + private: OverlayPortKind m_kind; Path m_directory; diff --git a/include/vcpkg/vcpkgcmdarguments.h b/include/vcpkg/vcpkgcmdarguments.h index 27b2089649..37109d3056 100644 --- a/include/vcpkg/vcpkgcmdarguments.h +++ b/include/vcpkg/vcpkgcmdarguments.h @@ -228,8 +228,6 @@ namespace vcpkg Optional triplet; Optional host_triplet; - std::vector cli_overlay_port_dirs; - std::vector env_overlay_port_dirs; std::vector cli_overlay_ports; std::vector env_overlay_ports; std::vector cli_overlay_triplets; diff --git a/locales/messages.json b/locales/messages.json index a4fa7ebbe2..a7e03c113f 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -650,9 +650,9 @@ "_ErrorInvalidExtractOption.comment": "The keyword 'AUTO' should not be localized An example of {option} is editable.", "ErrorInvalidManifestModeOption": "The option --{option} is not supported in manifest mode.", "_ErrorInvalidManifestModeOption.comment": "An example of {option} is editable.", - "ErrorManifestMustDifferFromOverlay": "The manifest directory ({path}) cannot be the same as a directory configured as an overlay-port or overlay-port-dir.", + "ErrorManifestMustDifferFromOverlay": "The manifest directory ({path}) cannot be the same as a directory configured in overlay-ports.", "_ErrorManifestMustDifferFromOverlay.comment": "An example of {path} is /foo/bar.", - "ErrorManifestMustDifferFromOverlayDot": "The manifest directory cannot be the same as a directory configured as an overlay-port or overlay-port-dir, so \"overlay-ports\" and \"overlay-port-dir\" values cannot be \".\".", + "ErrorManifestMustDifferFromOverlayDot": "The manifest directory cannot be the same as a directory configured in overlay-ports, so \"overlay-ports\" values cannot be \".\".", "ErrorMissingVcpkgRoot": "Could not detect vcpkg-root. If you are trying to use a copy of vcpkg that you've built, you must define the VCPKG_ROOT environment variable to point to a cloned copy of https://github.com/Microsoft/vcpkg.", "ErrorNoVSInstance": "in triplet {triplet}: Unable to find a valid Visual Studio instance", "_ErrorNoVSInstance.comment": "An example of {triplet} is x64-windows.", @@ -1233,8 +1233,6 @@ "OtherCommandsHeader": "Other", "OverlayPatchDir": "Overlay path \"{path}\" must be an existing directory.", "_OverlayPatchDir.comment": "An example of {path} is /foo/bar.", - "OverlayPortDirsHelp": "Directories containing overlay-port directories (also: {env_var})", - "_OverlayPortDirsHelp.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "OverlayPortsHelp": "Overlay-port directories, or directories containing overlay-port directories (also: {env_var})", "_OverlayPortsHelp.comment": "An example of {env_var} is VCPKG_DEFAULT_TRIPLET.", "OverlayTripletDirectoriesHelp": "Directories of overlay triplets (also: {env_var})", diff --git a/src/vcpkg/commands.install.cpp b/src/vcpkg/commands.install.cpp index 8e40a1c74c..43f9e5787b 100644 --- a/src/vcpkg/commands.install.cpp +++ b/src/vcpkg/commands.install.cpp @@ -1239,7 +1239,7 @@ namespace vcpkg auto extended_overlay_port_directories = paths.overlay_ports; if (add_builtin_ports_directory_as_overlay) { - extended_overlay_port_directories.overlay_ports.emplace_back(paths.builtin_ports_directory()); + extended_overlay_port_directories.builtin_overlay_port_dir.emplace(paths.builtin_ports_directory()); } auto oprovider = diff --git a/src/vcpkg/configuration.cpp b/src/vcpkg/configuration.cpp index 61a43bcf0a..9aa32cd370 100644 --- a/src/vcpkg/configuration.cpp +++ b/src/vcpkg/configuration.cpp @@ -548,8 +548,6 @@ namespace } r.optional_object_field(obj, JsonIdOverlayPorts, ret.overlay_ports, OverlayPathArrayDeserializer::instance); - r.optional_object_field( - obj, JsonIdOverlayPortDirs, ret.overlay_port_dirs, OverlayPathArrayDeserializer::instance); r.optional_object_field( obj, JsonIdOverlayTriplets, ret.overlay_triplets, OverlayTripletsPathArrayDeserializer::instance); @@ -773,7 +771,6 @@ namespace vcpkg JsonIdDefaultRegistry, JsonIdRegistries, JsonIdOverlayPorts, - JsonIdOverlayPortDirs, JsonIdOverlayTriplets, JsonIdMessage, JsonIdWarning, @@ -962,15 +959,6 @@ namespace vcpkg } } - if (!overlay_port_dirs.empty()) - { - auto& opd_arr = obj.insert(JsonIdOverlayPortDirs, Json::Array()); - for (const auto& port : overlay_port_dirs) - { - opd_arr.push_back(port); - } - } - if (!overlay_ports.empty()) { auto& op_arr = obj.insert(JsonIdOverlayPorts, Json::Array()); diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index 08ac747bc2..04c1c9f428 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -239,6 +239,16 @@ namespace vcpkg } } + void OverlayPortIndexEntry::check_directory(const ReadOnlyFilesystem& fs) const + { + Debug::println("Using overlay: ", m_directory); + + Checks::msg_check_exit(VCPKG_LINE_INFO, + vcpkg::is_directory(fs.status(m_directory, VCPKG_LINE_INFO)), + msgOverlayPatchDir, + msg::path = m_directory); + } + struct OverlayPortIndex { OverlayPortIndex() = delete; @@ -247,9 +257,9 @@ namespace vcpkg OverlayPortIndex(const OverlayPortPaths& paths) { - for (auto&& overlay_port_dir : paths.overlay_port_dirs) + if (auto builtin_overlay_port_dir = paths.builtin_overlay_port_dir.get()) { - m_entries.emplace_back(OverlayPortKind::Directory, overlay_port_dir); + m_entries.emplace_back(OverlayPortKind::Directory, *builtin_overlay_port_dir); } for (auto&& overlay_port : paths.overlay_ports) @@ -287,10 +297,22 @@ namespace vcpkg return Unit{}; } + void check_directories(const ReadOnlyFilesystem& fs) + { + for (auto&& overlay : m_entries) + { + overlay.check_directory(fs); + } + } + + private: std::vector m_entries; }; - bool OverlayPortPaths::empty() const noexcept { return overlay_port_dirs.empty() && overlay_ports.empty(); } + bool OverlayPortPaths::empty() const noexcept + { + return !builtin_overlay_port_dir.has_value() && overlay_ports.empty(); + } MapPortFileProvider::MapPortFileProvider(const std::unordered_map& map) : ports(map) @@ -492,25 +514,7 @@ namespace vcpkg OverlayProviderImpl(const ReadOnlyFilesystem& fs, const OverlayPortPaths& overlay_port_paths) : m_fs(fs), m_overlay_index(overlay_port_paths) { - for (auto&& overlay : overlay_port_paths.overlay_port_dirs) - { - Debug::println("Using overlay-dir: ", overlay); - - Checks::msg_check_exit(VCPKG_LINE_INFO, - vcpkg::is_directory(m_fs.status(overlay, VCPKG_LINE_INFO)), - msgOverlayPatchDir, - msg::path = overlay); - } - - for (auto&& overlay : overlay_port_paths.overlay_ports) - { - Debug::println("Using overlay: ", overlay); - - Checks::msg_check_exit(VCPKG_LINE_INFO, - vcpkg::is_directory(m_fs.status(overlay, VCPKG_LINE_INFO)), - msgOverlayPatchDir, - msg::path = overlay); - } + m_overlay_index.check_directories(m_fs); } OverlayProviderImpl(const OverlayProviderImpl&) = delete; diff --git a/src/vcpkg/vcpkgcmdarguments.cpp b/src/vcpkg/vcpkgcmdarguments.cpp index 3247976471..7c9c033be2 100644 --- a/src/vcpkg/vcpkgcmdarguments.cpp +++ b/src/vcpkg/vcpkgcmdarguments.cpp @@ -375,12 +375,6 @@ namespace vcpkg } } - args.parser.parse_multi_option( - SwitchOverlayPortDirs, - StabilityTag::Standard, - args.cli_overlay_port_dirs, - msg::format(msgOverlayPortDirsHelp, - msg::env_var = format_environment_variable(EnvironmentVariableVcpkgOverlayPortDirs))); args.parser.parse_multi_option( SwitchOverlayPorts, StabilityTag::Standard, @@ -611,13 +605,7 @@ namespace vcpkg ignore_lock_failures = true; } } - { - const auto vcpkg_overlay_port_dirs_env = get_env(EnvironmentVariableVcpkgOverlayPortDirs); - if (const auto unpacked = vcpkg_overlay_port_dirs_env.get()) - { - env_overlay_port_dirs = Strings::split_paths(*unpacked); - } - } + { const auto vcpkg_overlay_ports_env = get_env(EnvironmentVariableVcpkgOverlayPorts); if (const auto unpacked = vcpkg_overlay_ports_env.get()) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 9c11e21bb8..e915e3db36 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -113,7 +113,7 @@ namespace } auto full_entry = relative_root / entry; - if (fs.almost_canonical(full_entry, VCPKG_LINE_INFO) == config_directory) + if (forbid_dot && fs.almost_canonical(full_entry, VCPKG_LINE_INFO) == config_directory) { Checks::msg_exit_with_error( VCPKG_LINE_INFO, msgErrorManifestMustDifferFromOverlay, msg::path = config_directory); @@ -705,13 +705,6 @@ namespace vcpkg std::move(maybe_json_config), m_pimpl->m_config_dir, *this); - overlay_ports.overlay_port_dirs = merge_overlays(m_pimpl->m_fs, - args.cli_overlay_port_dirs, - args.env_overlay_port_dirs, - original_cwd, - true, - m_pimpl->m_config.config.overlay_port_dirs, - m_pimpl->m_config.directory); overlay_ports.overlay_ports = merge_overlays(m_pimpl->m_fs, args.cli_overlay_ports, args.env_overlay_ports, From 03ac99341dc91e02bfbe2ff87c3f11605cc1648c Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 15 Nov 2024 00:49:22 +0000 Subject: [PATCH 09/11] Fix Linux execute bit test to work in the home directory. --- azure-pipelines/end-to-end-tests-dir/commands.extract.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/end-to-end-tests-dir/commands.extract.ps1 b/azure-pipelines/end-to-end-tests-dir/commands.extract.ps1 index 366ce00147..f9776b2d5b 100644 --- a/azure-pipelines/end-to-end-tests-dir/commands.extract.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/commands.extract.ps1 @@ -12,8 +12,8 @@ if (-Not (Test-Path $extractedFilePath)) { if (-Not $IsWindows) { $unixMode = (Get-Item $extractedFilePath).UnixMode - if ($unixMode -ne "-rwxr-xr-x") { - throw "File does not have +x permission. UnixMode: $unixMode" + if (-not ($unixMode -match 'x.*x.*x')) { + throw "File does not have +x permission. $extractedFilePath UnixMode: $unixMode" } } From 5a2a973a55c035e79cc76e8edb6d7ad3eedbcefb Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 15 Nov 2024 00:49:43 +0000 Subject: [PATCH 10/11] Add the real hello directory to fix the not-quite-dot test on POSIX. --- .../overlays-not-quite-dot/hello/ensure-directory.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 azure-pipelines/e2e-projects/overlays-not-quite-dot/hello/ensure-directory.txt diff --git a/azure-pipelines/e2e-projects/overlays-not-quite-dot/hello/ensure-directory.txt b/azure-pipelines/e2e-projects/overlays-not-quite-dot/hello/ensure-directory.txt new file mode 100644 index 0000000000..00ff321468 --- /dev/null +++ b/azure-pipelines/e2e-projects/overlays-not-quite-dot/hello/ensure-directory.txt @@ -0,0 +1 @@ +This file exists only to ensure that git creates the directory containing it, so that ./hello/.. is a valid path. \ No newline at end of file From 67650935adf1c64533bee6682cecef700d423183 Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Fri, 15 Nov 2024 01:00:11 +0000 Subject: [PATCH 11/11] Fix path identity test on POSIX. --- src/vcpkg/vcpkgpaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index e915e3db36..8261e1d40b 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -113,7 +113,7 @@ namespace } auto full_entry = relative_root / entry; - if (forbid_dot && fs.almost_canonical(full_entry, VCPKG_LINE_INFO) == config_directory) + if (forbid_dot && (fs.almost_canonical(full_entry, VCPKG_LINE_INFO) / "") == (config_directory / "")) { Checks::msg_exit_with_error( VCPKG_LINE_INFO, msgErrorManifestMustDifferFromOverlay, msg::path = config_directory);