Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doubled warnings being printed for manifest warnings when loading ports. #1466

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
5 changes: 5 additions & 0 deletions azure-pipelines/e2e-ports/vcpkg-bad-spdx-license/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "vcpkg-bad-spdx-license",
"version": "1",
"license": "BSD-new"
}
16 changes: 16 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/build-test-ports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,19 @@ Throw-IfFailed
if ($output -notmatch 'vcpkg-internal-e2e-test-port3:[^ ]+ is already installed -- not building from HEAD') {
throw 'Wrong already installed message for --head'
}

Refresh-TestRoot
$output = Run-VcpkgAndCaptureOutput @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-ports" install vcpkg-bad-spdx-license
Throw-IfFailed
$output = $output.Replace("`r`n", "`n")
$expected = @"
vcpkg.json: warning: $.license (an SPDX license expression): warning: Unknown license identifier 'BSD-new'. Known values are listed at https://spdx.org/licenses/
on expression: BSD-new
^
"@
$firstMatch = $output.IndexOf($expected)
if ($firstMatch -lt 0) {
throw 'Did not detect expected bad license'
} elseif ($output.IndexOf($expected, $firstMatch + 1) -ge 0) {
throw 'Duplicated bad license'
}
4 changes: 0 additions & 4 deletions include/vcpkg/base/message-data.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3033,10 +3033,6 @@ DECLARE_MESSAGE(VersionMissingRequiredFeature,
(msg::version_spec, msg::feature, msg::constraint_origin),
"",
"{version_spec} does not have required feature {feature} needed by {constraint_origin}")
DECLARE_MESSAGE(VersionNotFound,
(msg::expected, msg::actual),
"{expected} and {actual} are versions",
"{expected} not available, only {actual} is available")
DECLARE_MESSAGE(VersionNotFoundInVersionsFile2,
(msg::version_spec),
"",
Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace vcpkg
VcpkgDefaultBinaryCache,
VcpkgNugetRepository,
VersioningErrorBaseline,
VersioningErrorVersion,
VersioningErrorVersion, // no longer used
X_VcpkgRegistriesCache,
X_WriteNugetPackagesConfig,
COUNT // always keep COUNT last
Expand Down
6 changes: 2 additions & 4 deletions include/vcpkg/paragraphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ namespace vcpkg::Paragraphs
std::vector<std::pair<std::string, LocalizedString>> errors;
};

LoadResults try_load_all_registry_ports(const ReadOnlyFilesystem& fs, const RegistrySet& registries);

std::vector<SourceControlFileAndLocation> load_all_registry_ports(const ReadOnlyFilesystem& fs,
const RegistrySet& registries);
LoadResults try_load_all_registry_ports(const RegistrySet& registries);
std::vector<SourceControlFileAndLocation> load_all_registry_ports(const RegistrySet& registries);

LoadResults try_load_overlay_ports(const ReadOnlyFilesystem& fs, const Path& dir);
std::vector<SourceControlFileAndLocation> load_overlay_ports(const ReadOnlyFilesystem& fs, const Path& dir);
Expand Down
6 changes: 2 additions & 4 deletions include/vcpkg/portfileprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ namespace vcpkg

struct PathsPortFileProvider : PortFileProvider
{
explicit PathsPortFileProvider(const ReadOnlyFilesystem& fs,
const RegistrySet& registry_set,
explicit PathsPortFileProvider(const RegistrySet& registry_set,
std::unique_ptr<IFullOverlayProvider>&& overlay);
ExpectedL<const SourceControlFileAndLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileAndLocation*> load_all_control_files() const override;
Expand All @@ -76,8 +75,7 @@ namespace vcpkg
};

std::unique_ptr<IBaselineProvider> make_baseline_provider(const RegistrySet& registry_set);
std::unique_ptr<IFullVersionedPortfileProvider> make_versioned_portfile_provider(const ReadOnlyFilesystem& fs,
const RegistrySet& registry_set);
std::unique_ptr<IFullVersionedPortfileProvider> make_versioned_portfile_provider(const RegistrySet& registry_set);
std::unique_ptr<IFullOverlayProvider> make_overlay_provider(const ReadOnlyFilesystem& fs,
const Path& original_cwd,
View<std::string> overlay_ports);
Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg/registries.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace vcpkg
{
virtual ExpectedL<View<Version>> get_port_versions() const = 0;

virtual ExpectedL<PortLocation> get_version(const Version& version) const = 0;
virtual ExpectedL<SourceControlFileAndLocation> try_load_port(const Version& version) const = 0;

virtual ~RegistryEntry() = default;
};
Expand Down
11 changes: 11 additions & 0 deletions include/vcpkg/sourceparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ namespace vcpkg
VersionSpec to_version_spec() const { return source_control_file->to_version_spec(); }
Path port_directory() const { return control_path.parent_path(); }

SourceControlFileAndLocation clone() const
{
std::unique_ptr<SourceControlFile> scf;
if (source_control_file)
{
scf = std::make_unique<SourceControlFile>(source_control_file->clone());
}

return SourceControlFileAndLocation{std::move(scf), control_path, spdx_location};
}

std::unique_ptr<SourceControlFile> source_control_file;
Path control_path;

Expand Down
2 changes: 0 additions & 2 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1613,8 +1613,6 @@
"_VersionMissing.comment": "The names version, version-date, version-semver, and version-string are code and must not be localized",
"VersionMissingRequiredFeature": "{version_spec} does not have required feature {feature} needed by {constraint_origin}",
"_VersionMissingRequiredFeature.comment": "An example of {version_spec} is zlib:x64-windows@1.0.0. An example of {feature} is avisynthplus. An example of {constraint_origin} is zlib:x64-windows@1.0.0.",
"VersionNotFound": "{expected} not available, only {actual} is available",
"_VersionNotFound.comment": "{expected} and {actual} are versions",
"VersionNotFoundInVersionsFile2": "{version_spec} was not found in versions database",
"_VersionNotFoundInVersionsFile2.comment": "An example of {version_spec} is zlib:x64-windows@1.0.0.",
"VersionNotFoundInVersionsFile3": "the version should be in this file",
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/commands.build-external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace vcpkg

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, overlays));
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.original_cwd, overlays));
command_build_and_exit_ex(args, paths, host_triplet, build_options, spec, provider, null_build_logs_recorder());
}
}
4 changes: 2 additions & 2 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ namespace vcpkg

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
Checks::exit_with_code(VCPKG_LINE_INFO,
command_build_ex(args,
paths,
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.check-support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ namespace vcpkg

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths);

// for each spec in the user-requested specs, check all dependencies
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ namespace vcpkg
build_logs_recorder_storage ? *(build_logs_recorder_storage.get()) : null_build_logs_recorder();

auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
filesystem, *registry_set, make_overlay_provider(filesystem, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(filesystem, paths.original_cwd, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;

Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.depend-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ namespace vcpkg

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;

Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ namespace vcpkg
const ParsedArguments options = args.parse_arguments(CommandEnvMetadata);

auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;

Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ namespace vcpkg
// Load ports from ports dirs
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));

// create the plan
std::vector<ExportPlanAction> export_plan = create_export_plan(opts.specs, status_db);
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/commands.find.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace vcpkg
Checks::check_exit(VCPKG_LINE_INFO, msg::default_output_stream == OutputStream::StdErr);
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, overlay_ports));
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.original_cwd, overlay_ports));
auto source_paragraphs =
Util::fmap(provider.load_all_control_files(),
[](auto&& port) -> const SourceControlFile* { return port->source_control_file.get(); });
Expand Down
3 changes: 2 additions & 1 deletion src/vcpkg/commands.format-manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace
auto res = serialize_manifest(*data.scf);

// reparse res to ensure no semantic changes were made
auto maybe_reparsed = SourceControlFile::parse_project_manifest_object(StringView{}, res, null_sink);
auto maybe_reparsed =
BillyONeal marked this conversation as resolved.
Show resolved Hide resolved
SourceControlFile::parse_project_manifest_object(StringLiteral{"<unsaved>"}, res, null_sink);
bool reparse_matches;
if (auto reparsed = maybe_reparsed.get())
{
Expand Down
6 changes: 3 additions & 3 deletions src/vcpkg/commands.install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ namespace vcpkg

const bool add_builtin_ports_directory_as_overlay =
registry_set->is_default_builtin_registry() && !paths.use_git_default_registry();
auto verprovider = make_versioned_portfile_provider(fs, *registry_set);
auto verprovider = make_versioned_portfile_provider(*registry_set);
auto baseprovider = make_baseline_provider(*registry_set);

std::vector<std::string> extended_overlay_ports;
Expand Down Expand Up @@ -1278,8 +1278,8 @@ namespace vcpkg
}

auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));

const std::vector<FullPackageSpec> specs = Util::fmap(options.command_arguments, [&](const std::string& arg) {
return check_and_get_full_package_spec(arg, default_triplet, paths.get_triplet_db())
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.package-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ namespace vcpkg
Json::Object response;
Json::Object results;
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));

for (auto&& arg : options.command_arguments)
{
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ namespace vcpkg
// Load ports from ports dirs
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));

specs =
Util::fmap(find_outdated_packages(provider, status_db), [](auto&& outdated) { return outdated.spec; });
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.set-installed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ namespace vcpkg

auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
auto cmake_vars = CMakeVars::make_triplet_cmake_var_provider(paths);

Optional<Path> pkgsconfig;
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ namespace vcpkg
const StatusParagraphs status_db = database_load_check(fs, paths.installed());

auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));

const auto outdated_packages = SortedVector<OutdatedPackage, decltype(&OutdatedPackage::compare_by_name)>(
find_outdated_packages(provider, status_db), &OutdatedPackage::compare_by_name);
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ namespace vcpkg
// Load ports from ports dirs
auto& fs = paths.get_filesystem();
auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(
fs, *registry_set, make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
PathsPortFileProvider provider(*registry_set,
make_overlay_provider(fs, paths.original_cwd, paths.overlay_ports));
auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;

Expand Down
16 changes: 6 additions & 10 deletions src/vcpkg/paragraphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ namespace vcpkg::Paragraphs
return maybe_paragraphs.error();
}

LoadResults try_load_all_registry_ports(const ReadOnlyFilesystem& fs, const RegistrySet& registries)
LoadResults try_load_all_registry_ports(const RegistrySet& registries)
{
LoadResults ret;
std::vector<std::string> ports = registries.get_all_reachable_port_names().value_or_exit(VCPKG_LINE_INFO);
Expand All @@ -530,19 +530,16 @@ namespace vcpkg::Paragraphs
const auto port_entry = maybe_port_entry.get();
if (!port_entry) continue; // port is attributed to this registry, but loading it failed
if (!*port_entry) continue; // port is attributed to this registry, but doesn't exist in this registry
auto maybe_port_location = (*port_entry)->get_version(*baseline_version);
const auto port_location = maybe_port_location.get();
if (!port_location) continue; // baseline version was not in version db (registry consistency issue)
auto maybe_result = try_load_port_required(fs, port_name, *port_location);
if (const auto scfl = maybe_result.maybe_scfl.get())
auto maybe_scfl = (*port_entry)->try_load_port(*baseline_version);
if (const auto scfl = maybe_scfl.get())
{
ret.paragraphs.push_back(std::move(*scfl));
}
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_result.maybe_scfl).error()));
std::forward_as_tuple(std::move(maybe_scfl).error()));
}
}

Expand Down Expand Up @@ -574,10 +571,9 @@ namespace vcpkg::Paragraphs
}
}

std::vector<SourceControlFileAndLocation> load_all_registry_ports(const ReadOnlyFilesystem& fs,
const RegistrySet& registries)
std::vector<SourceControlFileAndLocation> load_all_registry_ports(const RegistrySet& registries)
{
auto results = try_load_all_registry_ports(fs, registries);
auto results = try_load_all_registry_ports(registries);
load_results_print_error(results);
return std::move(results.paragraphs);
}
Expand Down
Loading
Loading