aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/auth.cxx4
-rw-r--r--bpkg/fetch-bpkg.cxx21
-rw-r--r--bpkg/fetch.hxx8
-rw-r--r--bpkg/manifest-utility.cxx45
-rw-r--r--bpkg/pkg-verify.cxx4
-rw-r--r--bpkg/rep-create.cxx4
-rw-r--r--bpkg/rep-fetch.cxx8
-rw-r--r--tests/rep-info.test2
8 files changed, 35 insertions, 61 deletions
diff --git a/bpkg/auth.cxx b/bpkg/auth.cxx
index ebc98b0..df9a259 100644
--- a/bpkg/auth.cxx
+++ b/bpkg/auth.cxx
@@ -69,7 +69,9 @@ namespace bpkg
//
if (rl.remote ())
return repository_location (
- repository_url (p.posix_string ()), rl).canonical_name ();
+ repository_url (p.posix_string ()),
+ repository_type::bpkg,
+ rl).canonical_name ();
else
return (path_cast<dir_path> (rl.path ()) / p).normalize ().string ();
}
diff --git a/bpkg/fetch-bpkg.cxx b/bpkg/fetch-bpkg.cxx
index 39f84f9..4fe0bfc 100644
--- a/bpkg/fetch-bpkg.cxx
+++ b/bpkg/fetch-bpkg.cxx
@@ -167,14 +167,14 @@ namespace bpkg
static const path repositories ("repositories");
- repository_manifests
+ bpkg_repository_manifests
bpkg_fetch_repositories (const dir_path& d, bool iu)
{
- return fetch_manifest<repository_manifests> (
+ return fetch_manifest<bpkg_repository_manifests> (
nullptr, d / repositories, iu).first;
}
- pair<repository_manifests, string/*checksum*/>
+ pair<bpkg_repository_manifests, string/*checksum*/>
bpkg_fetch_repositories (const common_options& o,
const repository_location& rl,
bool iu)
@@ -187,19 +187,20 @@ namespace bpkg
f /= repositories;
return rl.remote ()
- ? fetch_manifest<repository_manifests> (o, u, iu)
- : fetch_manifest<repository_manifests> (&o, f, iu);
+ ? fetch_manifest<bpkg_repository_manifests> (o, u, iu)
+ : fetch_manifest<bpkg_repository_manifests> (&o, f, iu);
}
static const path packages ("packages");
- package_manifests
+ bpkg_package_manifests
bpkg_fetch_packages (const dir_path& d, bool iu)
{
- return fetch_manifest<package_manifests> (nullptr, d / packages, iu).first;
+ return fetch_manifest<bpkg_package_manifests> (
+ nullptr, d / packages, iu).first;
}
- pair<package_manifests, string/*checksum*/>
+ pair<bpkg_package_manifests, string/*checksum*/>
bpkg_fetch_packages (const common_options& o,
const repository_location& rl,
bool iu)
@@ -212,8 +213,8 @@ namespace bpkg
f /= packages;
return rl.remote ()
- ? fetch_manifest<package_manifests> (o, u, iu)
- : fetch_manifest<package_manifests> (&o, f, iu);
+ ? fetch_manifest<bpkg_package_manifests> (o, u, iu)
+ : fetch_manifest<bpkg_package_manifests> (&o, f, iu);
}
static const path signature ("signature");
diff --git a/bpkg/fetch.hxx b/bpkg/fetch.hxx
index 49e144c..f243e09 100644
--- a/bpkg/fetch.hxx
+++ b/bpkg/fetch.hxx
@@ -19,18 +19,18 @@ namespace bpkg
// Repository type bpkg (fetch-bpkg.cxx).
//
- repository_manifests
+ bpkg_repository_manifests
bpkg_fetch_repositories (const dir_path&, bool ignore_unknown);
- pair<repository_manifests, string /* checksum */>
+ pair<bpkg_repository_manifests, string /* checksum */>
bpkg_fetch_repositories (const common_options&,
const repository_location&,
bool ignore_unknown);
- package_manifests
+ bpkg_package_manifests
bpkg_fetch_packages (const dir_path&, bool ignore_unknown);
- pair<package_manifests, string /* checksum */>
+ pair<bpkg_package_manifests, string /* checksum */>
bpkg_fetch_packages (const common_options&,
const repository_location&,
bool ignore_unknown);
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx
index d697620..27e2553 100644
--- a/bpkg/manifest-utility.cxx
+++ b/bpkg/manifest-utility.cxx
@@ -86,45 +86,10 @@ namespace bpkg
// 1. If type is specified as an option use that (but validate
// incompatible scheme/type e.g., git/bpkg).
//
- // 2. If scheme is git then git.
+ // 2. See guess_type() function description in libbpkg/manifest.hxx for
+ // the algorithm details.
//
- // 3. If scheme is http(s), then check if path has the .git extension,
- // then git, otherwise bpkg.
- //
- // 4. If local (which will normally be without the .git extension), check
- // if directory contains the .git/ subdirectory then git, otherwise
- // bpkg.
- //
- repository_type t (repository_type::bpkg);
-
- if (ot)
- t = *ot;
- else
- {
- switch (u.scheme)
- {
- case repository_protocol::git:
- {
- t = repository_type::git;
- break;
- }
- case repository_protocol::http:
- case repository_protocol::https:
- {
- t = u.path->extension () == "git"
- ? repository_type::git
- : repository_type::bpkg;
- break;
- }
- case repository_protocol::file:
- {
- t = exists (path_cast<dir_path> (*u.path) / dir_path (".git"))
- ? repository_type::git
- : repository_type::bpkg;
- break;
- }
- }
- }
+ repository_type t (ot ? *ot : guess_type (u, true));
try
{
@@ -155,4 +120,8 @@ namespace bpkg
{
fail << "invalid repository path '" << s << "': " << e << endf;
}
+ catch (const system_error& e)
+ {
+ fail << "failed to guess repository type for '" << s << "': " << e << endf;
+ }
}
diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx
index e388001..d46e5b6 100644
--- a/bpkg/pkg-verify.cxx
+++ b/bpkg/pkg-verify.cxx
@@ -40,7 +40,7 @@ namespace bpkg
{
ifdstream is (move (pr.second.in_ofd), fdstream_mode::skip);
manifest_parser mp (is, mf.string ());
- package_manifest m (mp, iu);
+ package_manifest m (bpkg_package_manifest (mp, iu));
is.close ();
if (wait ())
@@ -130,7 +130,7 @@ namespace bpkg
{
ifdstream ifs (mf);
manifest_parser mp (ifs, mf.string ());
- package_manifest m (mp, iu);
+ package_manifest m (bpkg_package_manifest (mp, iu));
// We used to verify package directory is <name>-<version> but it is
// not clear why we should enforce it in this case (i.e., the user
diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx
index 60f7f59..228b7f6 100644
--- a/bpkg/rep-create.cxx
+++ b/bpkg/rep-create.cxx
@@ -185,7 +185,7 @@ namespace bpkg
// Load the 'repositories' file to make sure it is there and
// is valid.
//
- repository_manifests rms (
+ bpkg_repository_manifests rms (
bpkg_fetch_repositories (d, o.ignore_unknown ()));
l4 ([&]{trace << rms.size () - 1 << " prerequisite repository(s)";});
@@ -197,7 +197,7 @@ namespace bpkg
package_map pm;
collect (o, pm, d, d);
- package_manifests manifests;
+ bpkg_package_manifests manifests;
manifests.sha256sum = sha256 (o, path (d / repositories));
for (auto& p: pm)
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index 6ed62ab..d7f0386 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -27,10 +27,10 @@ namespace bpkg
// First fetch the repositories list and authenticate the base's
// certificate.
//
- pair<repository_manifests, string /* checksum */> rmc (
+ pair<bpkg_repository_manifests, string /* checksum */> rmc (
bpkg_fetch_repositories (co, rl, ignore_unknown));
- repository_manifests& rms (rmc.first);
+ bpkg_repository_manifests& rms (rmc.first);
bool a (co.auth () != auth::none &&
(co.auth () == auth::all || rl.remote ()));
@@ -47,10 +47,10 @@ namespace bpkg
// Now fetch the packages list and make sure it matches the repositories
// we just fetched.
//
- pair<package_manifests, string /* checksum */> pmc (
+ pair<bpkg_package_manifests, string /* checksum */> pmc (
bpkg_fetch_packages (co, rl, ignore_unknown));
- package_manifests& pms (pmc.first);
+ bpkg_package_manifests& pms (pmc.first);
if (rmc.second != pms.sha256sum)
fail << "repositories manifest file checksum mismatch for "
diff --git a/tests/rep-info.test b/tests/rep-info.test
index fbe7c0a..4c90ab6 100644
--- a/tests/rep-info.test
+++ b/tests/rep-info.test
@@ -107,8 +107,10 @@ $* --name $rep/testing >"bpkg:build2.org/rep-info/testing ($rep/testing)"
$* --repositories --manifest $rep/testing >>EOO
: 1
location: ../../foo/testing
+ type: bpkg
:
location: ../stable
+ type: bpkg
role: complement
:
EOO