From d7dfb3f9262c116ee948df161cf13f57a13be362 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 29 Feb 2024 15:02:38 +0300 Subject: Allow to unhold unknown orphaned selected package in pkg-build --- bpkg/pkg-build.cxx | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'bpkg') 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 (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 (pa.name); - pkg_confs.emplace_back (*pdb, pa.name); - } bool hold_version (pa.constraint.has_value ()); -- cgit v1.1