diff options
-rw-r--r-- | bpkg/pkg-build.cxx | 10 | ||||
-rw-r--r-- | bpkg/pkg-unpack.cxx | 12 | ||||
-rw-r--r-- | tests/pkg-build.test | 9 |
3 files changed, 17 insertions, 14 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index 3a301c8..efe7e20 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -1950,10 +1950,12 @@ namespace bpkg if (pl.repository.object_id () != "") // Special root? { + transaction t (db.begin ()); + // Go through package repositories to decide if we should fetch, // checkout or unpack depending on the available repository basis. - // Preferring a local one over the remotes seems like a sensible - // thing to do. + // Preferring a local one over the remotes and the dir repository + // type over the others seems like a sensible thing to do. // optional<repository_basis> basis; @@ -1965,15 +1967,13 @@ namespace bpkg { basis = rl.basis (); - if (rl.local ()) + if (rl.directory_based ()) break; } } assert (basis); - transaction t (db.begin ()); - // All calls commit the transaction. // switch (*basis) diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx index aa3390d..9bd3e03 100644 --- a/bpkg/pkg-unpack.cxx +++ b/bpkg/pkg-unpack.cxx @@ -192,21 +192,17 @@ namespace bpkg if (ap == nullptr) fail << "package " << n << " " << v << " is not available"; - // Pick a directory-based repository. Preferring a local one over the - // remotes seems like a sensible thing to do. + // Pick a directory-based repository. They are always local, so we pick + // the first one. // const package_location* pl (nullptr); for (const package_location& l: ap->locations) { - const repository_location& rl (l.repository.load ()->location); - - if (rl.directory_based () && (pl == nullptr || rl.local ())) + if (l.repository.load ()->location.directory_based ()) { pl = &l; - - if (rl.local ()) - break; + break; } } diff --git a/tests/pkg-build.test b/tests/pkg-build.test index 03ed040..f5b3dee 100644 --- a/tests/pkg-build.test +++ b/tests/pkg-build.test @@ -1450,7 +1450,14 @@ rep_fetch += -d cfg --auth all --trust-yes 2>! : dir-rep : { - $clone_root_cfg && $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; + : preferred + : + : Test that dir (local) repository is preferred over non-dir local repository + : that comes first. + : + $clone_root_cfg; + $rep_fetch $rep/t4a; + $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch "dir:$src/libfoo-1.1.0"; $* libfoo 2>>~%EOE%; using libfoo/1.1.0 (external) |