diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-02-29 15:02:38 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-03-01 12:54:04 +0300 |
commit | d7dfb3f9262c116ee948df161cf13f57a13be362 (patch) | |
tree | 8348617d587dfad953b43cf99bc49a2cab78b65e | |
parent | acd8cb9bfeb0a1d25d38106afe8cb81eb0af4917 (diff) |
Allow to unhold unknown orphaned selected package in pkg-build
-rw-r--r-- | bpkg/pkg-build.cxx | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index b430c29..fac79c2 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -4857,36 +4857,47 @@ namespace bpkg bool sys (arg_sys (pa)); - // Make sure that the package is known. + if (pdb != nullptr) + sp = pdb->find<selected_package> (pa.name); + + // Make sure that the package is known. Only allow to unhold an + // unknown orphaned selected package (with the view that there is + // a good chance it will get dropped; and if not, such an unhold + // should be harmless). // if (!existing && find_available (repo_configs, pa.name, !sys ? pa.constraint : nullopt).empty ()) { - string n (arg_string (pa, false /* options */)); - - diag_record dr (fail); - dr << "unknown package " << n; - if (sys) + // Don't fail if the selected package is held and satisfies the + // constraints, if specified. Note that we may still fail later + // with the "not available from its dependents' repositories" + // error if the dependency is requested to be deorphaned and all + // its dependents are orphaned. + // + if (!(sp != nullptr && + sp->hold_package && + (!pa.constraint || satisfies (sp->version, pa.constraint)))) { - // Feels like we can't end up here if the version was specified - // explicitly. - // - dr << info << "consider specifying " << n << "/*"; + string n (arg_string (pa, false /* options */)); + + diag_record dr (fail); + dr << "unknown package " << n; + if (sys) + { + // Feels like we can't end up here if the version was specified + // explicitly. + // + dr << info << "consider specifying " << n << "/*"; + } + else + check_any_available (repo_configs, t, &dr); } - else - check_any_available (repo_configs, t, &dr); } if (pdb != nullptr) - { - // Save before the name move. - // - sp = pdb->find<selected_package> (pa.name); - pkg_confs.emplace_back (*pdb, pa.name); - } bool hold_version (pa.constraint.has_value ()); |