aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-build.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-06-16 18:17:07 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-06-19 13:49:27 +0300
commit636d69c1b740d8975bb7c7a3b518c280ac224545 (patch)
treebe9552beaea26413280bac12dabf07127bec4e28 /bpkg/pkg-build.cxx
parent5e6c781d4a1fafdb5e81c17b792cd36b7433ce90 (diff)
Add --mask-repository pkg-build option
Diffstat (limited to 'bpkg/pkg-build.cxx')
-rw-r--r--bpkg/pkg-build.cxx53
1 files changed, 41 insertions, 12 deletions
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 <bpkg/common-options.hxx>
#include <bpkg/cfg-link.hxx>
+#include <bpkg/rep-mask.hxx>
#include <bpkg/pkg-purge.hxx>
#include <bpkg/pkg-fetch.hxx>
#include <bpkg/rep-fetch.hxx>
@@ -93,11 +94,23 @@ namespace bpkg
for (const auto& pl: dap->locations)
{
- shared_ptr<repository_fragment> rf (pl.repository_fragment.load ());
+ const lazy_shared_ptr<repository_fragment>& 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<repository_fragment> 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<selected_package>& sp)
{
@@ -217,7 +235,7 @@ namespace bpkg
const shared_ptr<repository_fragment> rf (
ddb.find<repository_fragment> (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.
//