From f4196f1638ad41cd640f4a57cefbcdb422724133 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Fri, 23 Sep 2016 14:25:17 -0700 Subject: [vcpkg] Move find_available_package, find_available_port_file into vcpkg_paths. `vcpkg_paths` is responsible for binding the concrete filesystem representation to the abstract `package_spec`. --- toolsrc/src/lib.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 2a3b95182..780067870 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -133,24 +133,9 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) return ret; } -fs::path vcpkg::control_file_for_package(const fs::path& package) -{ - return package / "CONTROL"; -} - -fs::path vcpkg::find_available_package(const vcpkg_paths& paths, const package_spec& spec) -{ - return paths.packages / Strings::format("%s_%s", spec.name, spec.target_triplet); -} - -fs::path vcpkg::find_available_port_file(const vcpkg_paths& paths, const package_spec& spec) -{ - return paths.ports / spec.name; -} - static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) { - return find_available_package(paths, {pgh.name, pgh.target_triplet}); + return paths.find_available_package({pgh.name, pgh.target_triplet}); } static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) @@ -228,7 +213,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar std::vector vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) { std::vector> pghs; - const fs::path packages_dir_control_file_path = find_available_package(paths, spec) / "CONTROL"; + const fs::path packages_dir_control_file_path = paths.find_available_package(spec) / "CONTROL"; if (fs::exists(packages_dir_control_file_path)) { @@ -245,7 +230,7 @@ std::vector vcpkg::get_unmet_package_dependencies(const vcpkg_paths return BinaryParagraph(pghs[0]).depends; } - const fs::path ports_dir_control_file_path = find_available_port_file(paths, spec) / "CONTROL"; + const fs::path ports_dir_control_file_path = paths.find_available_port_file(spec) / "CONTROL"; try { pghs = get_paragraphs(ports_dir_control_file_path); -- cgit v1.2.3 From 76149ffac5bf57882b8f7b9827f31e508da73d16 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Fri, 23 Sep 2016 14:32:56 -0700 Subject: [vcpkg] Rename `vcpkg_ports::find_available_x` to be more concise --- toolsrc/src/lib.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 780067870..a717344a4 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -135,7 +135,7 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) { - return paths.find_available_package({pgh.name, pgh.target_triplet}); + return paths.package_dir({pgh.name, pgh.target_triplet}); } static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) @@ -213,7 +213,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar std::vector vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) { std::vector> pghs; - const fs::path packages_dir_control_file_path = paths.find_available_package(spec) / "CONTROL"; + const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL"; if (fs::exists(packages_dir_control_file_path)) { @@ -230,7 +230,7 @@ std::vector vcpkg::get_unmet_package_dependencies(const vcpkg_paths return BinaryParagraph(pghs[0]).depends; } - const fs::path ports_dir_control_file_path = paths.find_available_port_file(spec) / "CONTROL"; + const fs::path ports_dir_control_file_path = paths.port_dir(spec) / "CONTROL"; try { pghs = get_paragraphs(ports_dir_control_file_path); -- cgit v1.2.3 From 2ed13a583d5c8537680125d2ab5ec77b0f63503c Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 27 Sep 2016 15:51:00 -0700 Subject: [vcpkg] Provide more error information on installation failures --- toolsrc/src/lib.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index a717344a4..e9f12cd1b 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -176,7 +176,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar auto status = it->status(ec); if (ec) { - System::println(System::color::error, "failed: %s", ec.message()); + System::println(System::color::error, "failed: %s: %s", it->path().u8string(), ec.message()); continue; } if (fs::is_directory(status)) @@ -184,7 +184,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar fs::create_directory(target, ec); if (ec) { - System::println(System::color::error, "failed: %s", ec.message()); + System::println(System::color::error, "failed: %s: %s", target.u8string(), ec.message()); } listfile << bpgh.target_triplet << "/" << suffix << "\n"; @@ -194,16 +194,16 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar fs::copy_file(*it, target, ec); if (ec) { - System::println(System::color::error, "failed: %s", ec.message()); + System::println(System::color::error, "failed: %s: %s", target.u8string(), ec.message()); } listfile << bpgh.target_triplet << "/" << suffix << "\n"; } else if (!fs::status_known(status)) { - std::cout << "unknown status: " << *it << "\n"; + System::println(System::color::error, "failed: %s: unknown status", it->path().u8string()); } else - std::cout << "warning: file does not exist: " << *it << "\n"; + System::println(System::color::error, "failed: %s: cannot handle file type", it->path().u8string()); } listfile.close(); @@ -374,16 +374,16 @@ void vcpkg::deinstall_package(const vcpkg_paths& paths, const package_spec& spec fs::remove(target, ec); if (ec) { - System::println(System::color::error, "failed: %s", ec.message()); + System::println(System::color::error, "failed: %s: %s", target.u8string(), ec.message()); } } else if (!fs::status_known(status)) { - System::println(System::color::warning, "Warning: unknown status: %s", target.string()); + System::println(System::color::warning, "Warning: unknown status: %s", target.u8string()); } else { - System::println(System::color::warning, "Warning: ???: %s", target.string()); + System::println(System::color::warning, "Warning: %s: cannot handle file type", target.u8string()); } } -- cgit v1.2.3 From 4ab32c520daa821250c6b4669dda7ce91b71d5e7 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 29 Sep 2016 14:31:28 -0700 Subject: [vcpkg] Improve error message on mistyped package name. --- toolsrc/src/lib.cpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index e9f12cd1b..2a9b06d4a 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -213,35 +213,40 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar std::vector vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) { std::vector> pghs; - const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL"; + { + const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL"; + + auto control_contents_maybe = Files::get_contents(packages_dir_control_file_path); + if (auto control_contents = control_contents_maybe.get()) + { + try + { + pghs = parse_paragraphs(*control_contents); + } + catch (std::runtime_error) + { + } + Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", packages_dir_control_file_path.string()); + return BinaryParagraph(pghs[0]).depends; + } + } - if (fs::exists(packages_dir_control_file_path)) + const fs::path ports_dir_control_file_path = paths.port_dir(spec) / "CONTROL"; + auto control_contents_maybe = Files::get_contents(ports_dir_control_file_path); + if (auto control_contents = control_contents_maybe.get()) { try { - pghs = get_paragraphs(packages_dir_control_file_path); + pghs = parse_paragraphs(*control_contents); } catch (std::runtime_error) { - // ?? } - - Checks::check_throw(pghs.size() == 1, "Invalid control file for package"); - return BinaryParagraph(pghs[0]).depends; - } - - const fs::path ports_dir_control_file_path = paths.port_dir(spec) / "CONTROL"; - try - { - pghs = get_paragraphs(ports_dir_control_file_path); - } - catch (std::runtime_error) - { - // ?? + Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", ports_dir_control_file_path.string()); + return SourceParagraph(pghs[0]).depends; } - Checks::check_exit(pghs.size() == 1, "Invalid control file for package %s", spec); - return SourceParagraph(pghs[0]).depends; + Checks::exit_with_message("Could not find package named %s", spec); } void vcpkg::install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) -- cgit v1.2.3 From 330b411cd2f4aa25632b2ae5ea2fef396fb13d12 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 3 Oct 2016 17:20:52 -0700 Subject: [triplet] Force using the factory that does sanity checks --- toolsrc/src/lib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 2a9b06d4a..2127b7850 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -158,7 +158,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar auto prefix_length = package_prefix_path.native().size(); std::error_code ec; - fs::create_directory(paths.installed / bpgh.target_triplet.value, ec); + fs::create_directory(paths.installed / bpgh.target_triplet.canonical_name(), ec); listfile << bpgh.target_triplet << "\n"; for (auto it = fs::recursive_directory_iterator(package_prefix_path); it != fs::recursive_directory_iterator(); ++it) @@ -171,7 +171,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar } auto suffix = it->path().generic_u8string().substr(prefix_length + 1); - auto target = paths.installed / bpgh.target_triplet.value / suffix; + auto target = paths.installed / bpgh.target_triplet.canonical_name() / suffix; auto status = it->status(ec); if (ec) -- cgit v1.2.3 From 5d58eb29cc9ae584335e3380c2645baf05b21222 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 3 Oct 2016 17:45:01 -0700 Subject: [package_spec] Force using the factories that do sanity checks --- toolsrc/src/lib.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 2127b7850..92451156a 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -135,7 +135,7 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) { - return paths.package_dir({pgh.name, pgh.target_triplet}); + return paths.package_dir(package_spec::from_name_and_triplet(pgh.name, pgh.target_triplet)); } static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) @@ -316,7 +316,7 @@ static deinstall_plan deinstall_package_plan( void vcpkg::deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db) { - auto package_it = status_db.find(spec.name, spec.target_triplet); + auto package_it = status_db.find(spec.name(), spec.target_triplet()); if (package_it == status_db.end()) { System::println(System::color::success, "Package %s is not installed", spec); -- cgit v1.2.3 From bf323e8cc6f3edd245e3f5661cab6c8b7f335da9 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 4 Oct 2016 14:47:42 -0700 Subject: [package_spec]User input gets lowercased; other input is checked --- toolsrc/src/lib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 92451156a..c4ebb872b 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -135,7 +135,7 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) { - return paths.package_dir(package_spec::from_name_and_triplet(pgh.name, pgh.target_triplet)); + return paths.package_dir(*package_spec::from_name_and_triplet(pgh.name, pgh.target_triplet).get()); } static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) -- cgit v1.2.3 From 79f823590d1f04634766d3bdf566b23f8570d117 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 4 Oct 2016 14:55:33 -0700 Subject: Temporarily use get_or_throw() --- toolsrc/src/lib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index c4ebb872b..955aa2c63 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -135,7 +135,7 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) { - return paths.package_dir(*package_spec::from_name_and_triplet(pgh.name, pgh.target_triplet).get()); + return paths.package_dir(package_spec::from_name_and_triplet(pgh.name, pgh.target_triplet).get_or_throw()); } static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) -- cgit v1.2.3 From 429e2eca4ab74127b144743b136f0407c0ae4492 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 4 Oct 2016 15:16:07 -0700 Subject: BinaryParagraph now contains a package_spec instead of name+triplet --- toolsrc/src/lib.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 955aa2c63..941454a6b 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -135,7 +135,7 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) { - return paths.package_dir(package_spec::from_name_and_triplet(pgh.name, pgh.target_triplet).get_or_throw()); + return paths.package_dir(pgh.spec); } static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) @@ -157,9 +157,11 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar auto package_prefix_path = prefix_path_for_package(paths, bpgh); auto prefix_length = package_prefix_path.native().size(); + const triplet& target_triplet = bpgh.spec.target_triplet(); + const std::string& target_triplet_as_string = target_triplet.canonical_name(); std::error_code ec; - fs::create_directory(paths.installed / bpgh.target_triplet.canonical_name(), ec); - listfile << bpgh.target_triplet << "\n"; + fs::create_directory(paths.installed / target_triplet_as_string, ec); + listfile << target_triplet << "\n"; for (auto it = fs::recursive_directory_iterator(package_prefix_path); it != fs::recursive_directory_iterator(); ++it) { @@ -171,7 +173,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar } auto suffix = it->path().generic_u8string().substr(prefix_length + 1); - auto target = paths.installed / bpgh.target_triplet.canonical_name() / suffix; + auto target = paths.installed / target_triplet_as_string / suffix; auto status = it->status(ec); if (ec) @@ -187,7 +189,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar System::println(System::color::error, "failed: %s: %s", target.u8string(), ec.message()); } - listfile << bpgh.target_triplet << "/" << suffix << "\n"; + listfile << target_triplet << "/" << suffix << "\n"; } else if (fs::is_regular_file(status)) { @@ -196,7 +198,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar { System::println(System::color::error, "failed: %s: %s", target.u8string(), ec.message()); } - listfile << bpgh.target_triplet << "/" << suffix << "\n"; + listfile << target_triplet << "/" << suffix << "\n"; } else if (!fs::status_known(status)) { @@ -257,7 +259,7 @@ void vcpkg::install_package(const vcpkg_paths& paths, const BinaryParagraph& bin spgh.state = install_state_t::half_installed; for (const std::string& dependency : spgh.package.depends) { - if (status_db.find_installed(dependency, spgh.package.target_triplet) == status_db.end()) + if (status_db.find_installed(dependency, spgh.package.spec.target_triplet()) == status_db.end()) { std::abort(); } @@ -297,12 +299,12 @@ static deinstall_plan deinstall_package_plan( { if (inst_pkg->want != want_t::install) continue; - if (inst_pkg->package.target_triplet != pkg.target_triplet) + if (inst_pkg->package.spec.target_triplet() != pkg.spec.target_triplet()) continue; const auto& deps = inst_pkg->package.depends; - if (std::find(deps.begin(), deps.end(), pkg.name) != deps.end()) + if (std::find(deps.begin(), deps.end(), pkg.spec.name()) != deps.end()) { dependencies_out.push_back(inst_pkg.get()); } -- cgit v1.2.3 From 8400da7f1d7143ff5969a5ae2fea4b0e76315216 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Tue, 4 Oct 2016 15:18:44 -0700 Subject: Remove function prefix_path_for_package() --- toolsrc/src/lib.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'toolsrc/src/lib.cpp') diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp index 941454a6b..45b73ee07 100644 --- a/toolsrc/src/lib.cpp +++ b/toolsrc/src/lib.cpp @@ -133,11 +133,6 @@ static std::string get_fullpkgname_from_listfile(const fs::path& path) return ret; } -static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) -{ - return paths.package_dir(pgh.spec); -} - static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) { static int update_id = 0; @@ -154,7 +149,7 @@ static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryPar { std::fstream listfile(listfile_path(paths, bpgh), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); - auto package_prefix_path = prefix_path_for_package(paths, bpgh); + auto package_prefix_path = paths.package_dir(bpgh.spec); auto prefix_length = package_prefix_path.native().size(); const triplet& target_triplet = bpgh.spec.target_triplet(); @@ -507,7 +502,7 @@ namespace void vcpkg::binary_import(const vcpkg_paths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data) { - fs::path library_destination_path = prefix_path_for_package(paths, control_file_data); + fs::path library_destination_path = paths.package_dir(control_file_data.spec); fs::create_directory(library_destination_path); place_library_files_in(include_directory, project_directory, library_destination_path); -- cgit v1.2.3