aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-06-13 00:05:20 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-06-13 00:06:38 +0300
commite21bb74df4e5370c8959aca909aece3e679f7056 (patch)
treebffe61d9c56bb39a5c889418ebc09b3c8c5f7b1b
parent72a86b7db44fcdce975bda932138adc4543cead8 (diff)
-rw-r--r--bpkg/database.cxx22
-rw-r--r--bpkg/package.cxx12
-rw-r--r--tests/pkg-drop.testscript33
3 files changed, 62 insertions, 5 deletions
diff --git a/bpkg/database.cxx b/bpkg/database.cxx
index d0b72c8..21ce3ef 100644
--- a/bpkg/database.cxx
+++ b/bpkg/database.cxx
@@ -339,7 +339,20 @@ namespace bpkg
schema_catalog::migrate (*this);
for (auto& c: query<configuration> (odb::query<configuration>::id != 0))
- attach (c.make_effective_path (config)).migrate ();
+ {
+ dir_path d (c.effective_path (config));
+
+ if (!c.expl && !exists (d))
+ {
+ warn << "implicit association " << c.path << " of configuration "
+ << config_orig << " does not exist, removing";
+
+ erase (c);
+ continue;
+ }
+
+ attach (d).migrate ();
+ }
}
}
@@ -522,7 +535,12 @@ namespace bpkg
//
for (const auto& ac: query<configuration> ("ORDER BY" + q::id))
{
- database& db (attach (ac.effective_path (config), sys_rep));
+ const dir_path& d (ac.effective_path (config));
+
+ if (!ac.expl && !exists (d))
+ continue;
+
+ database& db (attach (d, sys_rep));
// Verify the association integrity.
//
diff --git a/bpkg/package.cxx b/bpkg/package.cxx
index 9b15a2c..4b44246 100644
--- a/bpkg/package.cxx
+++ b/bpkg/package.cxx
@@ -497,12 +497,18 @@ namespace bpkg
lazy_shared_ptr<selected_package> _selected_package_ref::
to_ptr (odb::database& db) &&
{
+ database& pdb (static_cast<database&> (db));
+
// Note that if this points to a different configuration, then it should
// already be pre-attached since it must be explicitly associated.
//
- return lazy_shared_ptr<selected_package> (
- static_cast<database&> (db).find_dependency_config (configuration),
- move (prerequisite));
+ database& ddb (pdb.find_dependency_config (configuration));
+
+ if (ddb != pdb && ddb.find<selected_package> (prerequisite) == nullptr)
+ fail << "unable to find package " << prerequisite
+ << " in configuration " << ddb.config_orig;
+
+ return lazy_shared_ptr<selected_package> (ddb, move (prerequisite));
}
pair<shared_ptr<selected_package>, database*>
diff --git a/tests/pkg-drop.testscript b/tests/pkg-drop.testscript
index f94ff0e..c46032c 100644
--- a/tests/pkg-drop.testscript
+++ b/tests/pkg-drop.testscript
@@ -693,4 +693,37 @@ $* libfoo/1.0.0 2>>~%EOE% != 0
$pkg_status -r libbar >'libbar available 1.0.0'
}
+
+ : skip-deleted-dependency
+ :
+ {
+ cp -pr --no-cleanup ../cfg ./;
+ cp -pr ../cfg2 ./;
+
+ $pkg_build libbar --yes >! &cfg/***;
+
+ mv cfg cfg.tmp;
+
+ $* -d cfg2 libbaz <<EOI 2>>/~%EOE%;
+ y
+ y
+ EOI
+ following dependent packages will have to be dropped as well:
+ foo (requires libbaz)
+ %drop dependent packages\? \[y.N\] drop foo%
+ drop libbaz
+ %continue\? \[Y.n\] disfigured foo%
+ disfigured libbaz
+ purged foo
+ purged libbaz
+ EOE
+
+ mv cfg.tmp cfg;
+
+ $* libbar 2>>/EOE != 0;
+ error: unable to find package foo in configuration cfg2/
+ EOE
+
+ $pkg_status -d cfg2 -r 2>'info: no held packages in the configuration'
+ }
}