From d22f466823192963c22eb8f51ae930cb5af8fa9a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 30 Aug 2018 23:14:51 +0300 Subject: Add support for git repositories to brep-load --- libbrep/build-extra.sql | 3 ++- libbrep/common.hxx | 30 ++++++++++++++++++++++++------ libbrep/package.cxx | 12 ++++-------- libbrep/package.hxx | 17 +++++++++++------ libbrep/package.xml | 28 ++++++++++++++++------------ 5 files changed, 57 insertions(+), 33 deletions(-) (limited to 'libbrep') diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql index 96e355c..e0aa92a 100644 --- a/libbrep/build-extra.sql +++ b/libbrep/build-extra.sql @@ -14,7 +14,8 @@ DROP FOREIGN TABLE IF EXISTS build_repository; -- CREATE FOREIGN TABLE build_repository ( name TEXT NOT NULL, - location TEXT NOT NULL, + location_url TEXT NOT NULL, + location_type TEXT NOT NULL, certificate_fingerprint TEXT NULL) SERVER package_server OPTIONS (table_name 'repository'); diff --git a/libbrep/common.hxx b/libbrep/common.hxx index 5b172ec..0163ca0 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -218,21 +218,39 @@ namespace brep // repository_type // using bpkg::repository_type; + using bpkg::to_repository_type; + + #pragma db map type(repository_type) as(string) \ + to(to_string (?)) \ + from(brep::to_repository_type (?)) // repository_url // using bpkg::repository_url; + #pragma db map type(repository_url) as(string) \ + to((?).string ()) \ + from((?).empty () ? brep::repository_url () : brep::repository_url (?)) + // repository_location // using bpkg::repository_location; - #pragma db map type(repository_location) as(string) \ - to((?).url ().string ()) \ - from(brep::repository_location ((?).empty () \ - ? bpkg::repository_url () \ - : brep::repository_url (?), \ - brep::repository_type::pkg)) + #pragma db value + struct _repository_location + { + repository_url url; + repository_type type; + }; + + // Note that the type() call fails for an empty repository location. + // + #pragma db map type(repository_location) as(_repository_location) \ + to(brep::_repository_location {(?).url (), \ + (?).empty () \ + ? brep::repository_type::pkg \ + : (?).type ()}) \ + from(brep::repository_location (std::move ((?).url), (?).type)) // Version comparison operators. // diff --git a/libbrep/package.cxx b/libbrep/package.cxx index 5b729c8..6d4550d 100644 --- a/libbrep/package.cxx +++ b/libbrep/package.cxx @@ -15,16 +15,10 @@ namespace brep { // dependency // - package_name dependency:: - name () const - { - return package.object_id ().name; - } - ostream& operator<< (ostream& o, const dependency& d) { - o << d.name (); + o << d.name; if (d.constraint) o << ' ' << *d.constraint; @@ -35,7 +29,7 @@ namespace brep bool operator== (const dependency& x, const dependency& y) { - return x.name () == y.name () && x.constraint == y.constraint; + return x.name == y.name && x.constraint == y.constraint; } bool @@ -67,6 +61,7 @@ namespace brep requirements_type rq, build_constraints_type bc, optional lc, + optional fr, optional sh, shared_ptr rp) : id (move (nm), vr), @@ -93,6 +88,7 @@ namespace brep : build_constraints_type ()), internal_repository (move (rp)), location (move (lc)), + fragment (move (fr)), sha256sum (move (sh)) { assert (internal_repository->internal); diff --git a/libbrep/package.hxx b/libbrep/package.hxx index e7a8338..3d281b0 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -120,17 +120,16 @@ namespace brep { using package_type = brep::package; - lazy_shared_ptr package; + package_name name; optional constraint; - // Prerequisite package name. + // Resolved dependency package. NULL if the repository load was shallow + // and so the package dependencies are not resolved. // - package_name - name () const; + lazy_shared_ptr package; // Database mapping. // - #pragma db member(package) column("") not_null #pragma db member(constraint) column("") }; @@ -212,7 +211,7 @@ namespace brep // uint16_t priority; - optional url; + optional interface_url; // Present only for internal repositories. // @@ -318,6 +317,7 @@ namespace brep requirements_type, build_constraints_type, optional location, + optional fragment, optional sha256sum, shared_ptr); @@ -370,6 +370,11 @@ namespace brep // optional location; + // Present only for packages that come from the supporting fragmentation + // internal repository (normally version control-based). + // + optional fragment; + // Present only for internal packages. // optional sha256sum; diff --git a/libbrep/package.xml b/libbrep/package.xml index 47ff071..55baae9 100644 --- a/libbrep/package.xml +++ b/libbrep/package.xml @@ -2,15 +2,17 @@ - + + - + - + + @@ -99,6 +101,7 @@ + @@ -259,10 +262,6 @@ - - - - @@ -277,6 +276,11 @@ + + + + + @@ -299,11 +303,11 @@ - - - - - + + + + + -- cgit v1.1