From 636d69c1b740d8975bb7c7a3b518c280ac224545 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 16 Jun 2023 18:17:07 +0300 Subject: Add --mask-repository pkg-build option --- bpkg/pkg-build.cxx | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'bpkg/pkg-build.cxx') diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index 7d9aa6d..6101826 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -93,11 +94,23 @@ namespace bpkg for (const auto& pl: dap->locations) { - shared_ptr rf (pl.repository_fragment.load ()); + const lazy_shared_ptr& lrf ( + pl.repository_fragment); - if (find (rfs.begin (), rfs.end (), rf) == rfs.end ()) - rfs.push_back (move (rf)); + if (!rep_masked_fragment (lrf)) + { + shared_ptr rf (lrf.load ()); + + if (find (rfs.begin (), rfs.end (), rf) == rfs.end ()) + rfs.push_back (move (rf)); + } } + + // Erase the entry from the map if it contains no fragments, which may + // happen if all the available package repositories are masked. + // + if (rfs.empty ()) + r.erase (i); } } } @@ -202,6 +215,11 @@ namespace bpkg // (see dependent_repo_configs() for details) and this exact version is // available from this repository fragment or from its complement. // + // Note that the orphan definition here is stronger than in the rest of the + // code, since we request the available package to also be present in the + // repository fragment. It feels that such a definition aligns better with + // the user expectations about deorphaning. + // static bool orphan_package (database& db, const shared_ptr& sp) { @@ -217,7 +235,7 @@ namespace bpkg const shared_ptr rf ( ddb.find (cn)); - if (rf != nullptr) + if (rf != nullptr && !rep_masked_fragment (ddb, rf)) { auto af ( find_available_one (sp->name, @@ -1574,6 +1592,8 @@ namespace bpkg if (!current (db)) current_configs.push_back (db); } + + t.commit (); } validate_options (o, ""); // Global package options. @@ -1977,6 +1997,12 @@ namespace bpkg string () /* reason for "fetching ..." */); } + // Now, as repo_configs is filled and the repositories are fetched mask + // the repositories, if any. + // + if (o.mask_repository_specified ()) + rep_mask (o.mask_repository ()); + // Expand the package specs into individual package args, parsing them // into the package scheme, name, and version constraint components, and // also saving associated options and configuration variables. @@ -5883,19 +5909,22 @@ namespace bpkg for (const package_location& l: ap->locations) { - const repository_location& rl ( - l.repository_fragment.load ()->location); - - if (!basis || rl.local ()) // First or local? + if (!rep_masked_fragment (l.repository_fragment)) { - basis = rl.basis (); + const repository_location& rl ( + l.repository_fragment.load ()->location); - if (rl.directory_based ()) - break; + if (!basis || rl.local ()) // First or local? + { + basis = rl.basis (); + + if (rl.directory_based ()) + break; + } } } - assert (basis); + assert (basis); // Shouldn't be here otherwise. // All calls commit the transaction. // -- cgit v1.1