diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-12 17:25:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-16 16:41:50 +0200 |
commit | 96281a6c4f818311a6df90c0d8b8f537a61e1090 (patch) | |
tree | d0c0ccacda5ccfb94b98d018abb273b554eb2f77 | |
parent | e80ebd1c1a6fe7749c1565c4a9e2fccaa07d5d95 (diff) |
Add url, email, summary, description members to the repository class
-rw-r--r-- | brep/package | 15 | ||||
-rw-r--r-- | brep/package-version-details.cxx | 43 | ||||
-rw-r--r-- | brep/package.cxx | 20 | ||||
-rw-r--r-- | brep/page.cxx | 21 | ||||
-rw-r--r-- | etc/httpd.conf | 1 | ||||
-rw-r--r-- | loader/loader.cxx | 61 | ||||
-rw-r--r-- | tests/loader/driver.cxx | 5 | ||||
-rw-r--r-- | tests/loader/external/1/basics/repositories | 1 | ||||
-rw-r--r-- | tests/loader/external/1/misc/repositories | 1 | ||||
-rw-r--r-- | tests/loader/external/1/staging/repositories | 1 | ||||
-rw-r--r-- | tests/loader/external/1/testing/repositories | 1 |
11 files changed, 114 insertions, 56 deletions
diff --git a/brep/package b/brep/package index 8fc6a43..f56906a 100644 --- a/brep/package +++ b/brep/package @@ -14,6 +14,7 @@ #include <cstddef> // size_t #include <utility> // move() #include <cstdint> // uint16 +#include <ostream> #include <odb/core.hxx> #include <odb/forward.hxx> // database @@ -261,6 +262,9 @@ namespace brep #pragma db member(package) column("") not_null }; + std::ostream& + operator<< (std::ostream&, const dependency&); + #pragma db value class dependency_alternatives: public std::vector<dependency> { @@ -310,6 +314,14 @@ namespace brep repository_location location; std::string display_name; + optional<std::string> url; + + // Set only for internal repositories. + // + optional<std::string> email; + optional<std::string> summary; + optional<std::string> description; + // Non empty for internal repositories and external ones with a filesystem // path location. // @@ -428,8 +440,7 @@ namespace brep requirements_type requirements; odb::lazy_shared_ptr<repository_type> internal_repository; - // Path to the package file. Set only for packages present in internal - // repository. + // Path to the package file. Set only for internal packages. // optional<path> location; diff --git a/brep/package-version-details.cxx b/brep/package-version-details.cxx index 9c90b8d..ce25a44 100644 --- a/brep/package-version-details.cxx +++ b/brep/package-version-details.cxx @@ -212,29 +212,36 @@ namespace brep shared_ptr<package> p (d.package.load ()); string en (mime_url_encode (p->id.name)); - if (p->internal ()) - s << A << HREF << "/go/" << en << ~HREF << p->id.name << ~A; - else - // @@ Refer to package repository URL when supported in repository - // manifest. - // - s << p->id.name; + assert (p->internal () || !p->other_repositories.empty ()); + shared_ptr<repository> r ( + p->internal () + ? p->internal_repository.load () + : p->other_repositories[0].load ()); - if (d.constraint) - { - s << ' '; + optional<string> u (r->url); // Repository web interface URL. + if (!u && p->internal ()) + u = ""; // Make URL to reference the current web interface. - if (p->internal ()) - s << A - << HREF << "/go/" << en << "/" << p->version.string () << ~HREF + if (u) + { + s << A << HREF << *u << "/go/" << en << ~HREF << p->id.name << ~A; + + if (d.constraint) + { + s << ' ' + << A + << HREF + << *u << "/go/" << en << "/" << p->version.string () + << ~HREF << *d.constraint << ~A; - else - // @@ Refer to package repository URL when supported in - // repository manifest. - // - s << *d.constraint; + } } + else + // Display the dependency as a plain text in no repository URL + // available. + // + s << d; } s << ~SPAN diff --git a/brep/package.cxx b/brep/package.cxx index 853d484..d99819c 100644 --- a/brep/package.cxx +++ b/brep/package.cxx @@ -6,6 +6,7 @@ #include <utility> // move() #include <cassert> +#include <ostream> #include <odb/database.hxx> @@ -24,6 +25,17 @@ namespace brep return package.object_id ().name; } + ostream& + operator<< (ostream& o, const dependency& d) + { + o << d.name (); + + if (d.constraint) + o << ' ' << *d.constraint; + + return o; + } + // package // package:: @@ -120,19 +132,19 @@ namespace brep // repository:: repository (repository_location l, string d, dir_path p) - : location (move (l)), + : name (l.canonical_name ()), + location (move (l)), display_name (move (d)), local_path (move (p)), internal (true) { - name = location.canonical_name (); } repository:: repository (repository_location l) - : location (move (l)), + : name (l.canonical_name ()), + location (move (l)), internal (false) { - name = location.canonical_name (); } } diff --git a/brep/page.cxx b/brep/page.cxx index 481825b..81a7de5 100644 --- a/brep/page.cxx +++ b/brep/page.cxx @@ -284,11 +284,24 @@ namespace brep shared_ptr<package> p (da.package.load ()); - if (p->internal ()) - s << A << HREF << "/go/" << mime_url_encode (n) << ~HREF << n << ~A; + assert (p->internal () || !p->other_repositories.empty ()); + shared_ptr<repository> r ( + p->internal () + ? p->internal_repository.load () + : p->other_repositories[0].load ()); + + optional<string> u (r->url); // Repository web interface URL. + if (!u && p->internal ()) + u = ""; // Make URL to reference the current web interface. + + if (u) + s << A + << HREF << *u << "/go/" << mime_url_encode (n) << ~HREF + << n + << ~A; else - // @@ Refer to package repository URL when supported in repository - // manifest. + // Display the dependency as a plain text in no repository URL + // available. // s << n; } diff --git a/etc/httpd.conf b/etc/httpd.conf index 33658a8..1000b04 100644 --- a/etc/httpd.conf +++ b/etc/httpd.conf @@ -94,3 +94,4 @@ ExtendedStatus On DirectoryIndex index.html TypesConfig /etc/mime.types AddOutputFilterByType DEFLATE application/xhtml+xml +AddOutputFilterByType DEFLATE text/css diff --git a/loader/loader.cxx b/loader/loader.cxx index 782d3f3..ee3e5fa 100644 --- a/loader/loader.cxx +++ b/loader/loader.cxx @@ -382,13 +382,13 @@ load_packages (const shared_ptr<repository>& rp, database& db) db.persist (rp); // Save the repository state. } -// Load the prerequsite repositories and their complements state from the -// 'repositories' file. Update the repository persistent state to save -// repositories_timestamp, prerequsites, and complements members. -// Should be called once per persisted internal repository. +// Load the repository manifest values, prerequsite repositories, and their +// complements state from the 'repositories' file. Update the repository +// persistent state to save changed members. Should be called once per +// persisted internal repository. // static void -load_prerequisites (const shared_ptr<repository>& rp, database& db) +load_repositories (const shared_ptr<repository>& rp, database& db) { // repositories_timestamp other than timestamp_nonexistent signals that // repository prerequisites are already loaded. @@ -417,12 +417,28 @@ load_prerequisites (const shared_ptr<repository>& rp, database& db) for (auto& rm: rpm) { - if (rm.location.empty () || - (!rp->internal && - rm.effective_role () == repository_role::prerequisite)) - continue; // Ignore entry for this repository. + if (rm.effective_role () == repository_role::prerequisite && !rp->internal) + continue; // Ignore the external repository prerequisite entry. - assert (rm.effective_role () != repository_role::base); + if (rm.effective_role () == repository_role::base) + { + // Update the base repository with manifest values. + // + rp->url = move (rm.url); + + if (rp->internal) + { + rp->email = move (rm.email); + rp->summary = move (rm.summary); + rp->description = move (rm.description); + } + + continue; + } + + // Load prerequisite or complement repository. + // + assert (!rm.location.empty ()); repository_location rl; @@ -498,24 +514,12 @@ load_prerequisites (const shared_ptr<repository>& rp, database& db) } load_packages (pr, db); - load_prerequisites (pr, db); + load_repositories (pr, db); } db.update (rp); } -static ostream& -operator<< (ostream& o, - const brep::dependency& d) // Ambiguity with bpkg::dependency. -{ - o << d.name (); - - if (d.constraint) - o << ' ' << *d.constraint; - - return o; -} - // Check if the package is available from the specified repository, // its prerequisite repositories, or one of their complements, // recursively. @@ -749,8 +753,8 @@ main (int argc, char* argv[]) throw; } - // Load the description of all the internal repositories from - // the configuration file. + // Load the description of all the internal repositories from the + // configuration file. // internal_repositories irs (load_repositories (path (argv[1]))); @@ -776,15 +780,16 @@ main (int argc, char* argv[]) load_packages (r, db); } - // On the second pass over the internal repositories we - // load their (not yet loaded) prerequisite repositories. + // On the second pass over the internal repositories we load their + // (not yet loaded) manifest values, complement, and prerequisite + // repositories. // for (const auto& ir: irs) { shared_ptr<repository> r ( db.load<repository> (ir.location.canonical_name ())); - load_prerequisites (r, db); + load_repositories (r, db); } session s; diff --git a/tests/loader/driver.cxx b/tests/loader/driver.cxx index 881a2db..f996ab7 100644 --- a/tests/loader/driver.cxx +++ b/tests/loader/driver.cxx @@ -117,6 +117,7 @@ main (int argc, char* argv[]) assert (sr->location.string () == "http://pkg.cppget.org/internal/1/stable"); assert (sr->display_name == "stable"); + assert (!sr->url); dir_path srp (cp.directory () / dir_path ("internal/1/stable")); assert (sr->local_path == srp.normalize ()); @@ -281,6 +282,7 @@ main (int argc, char* argv[]) assert (mr->location.string () == "http://pkg.cppget.org/internal/1/math"); assert (mr->display_name == "math"); + assert (!mr->url); dir_path mrp (cp.directory () / dir_path ("internal/1/math")); assert (mr->local_path == mrp.normalize ()); @@ -477,6 +479,7 @@ main (int argc, char* argv[]) assert (cr->location.string () == "http://pkg.cppget.org/external/1/misc"); assert (cr->display_name.empty ()); + assert (cr->url && *cr->url == "http://misc.cppget.org"); dir_path crp (cp.directory () / dir_path ("external/1/misc")); assert (cr->local_path == crp.normalize ()); @@ -531,6 +534,7 @@ main (int argc, char* argv[]) assert (tr->location.string () == "http://pkg.cppget.org/external/1/testing"); assert (tr->display_name.empty ()); + assert (tr->url && *tr->url == "http://test.cppget.org"); dir_path trp (cp.directory () / dir_path ("external/1/testing")); assert (tr->local_path == trp.normalize ()); @@ -563,6 +567,7 @@ main (int argc, char* argv[]) assert (gr->location.string () == "http://pkg.cppget.org/external/1/staging"); assert (gr->display_name.empty ()); + assert (gr->url && *gr->url == "http://stage.cppget.org"); dir_path grp (cp.directory () / dir_path ("external/1/staging")); assert (gr->local_path == grp.normalize ()); diff --git a/tests/loader/external/1/basics/repositories b/tests/loader/external/1/basics/repositories index 9a15f2b..57a1c7a 100644 --- a/tests/loader/external/1/basics/repositories +++ b/tests/loader/external/1/basics/repositories @@ -1,3 +1,4 @@ : 1 # Local repository manifest (this repository). # +url: http://basics.org diff --git a/tests/loader/external/1/misc/repositories b/tests/loader/external/1/misc/repositories index 93acdb3..1b98ebc 100644 --- a/tests/loader/external/1/misc/repositories +++ b/tests/loader/external/1/misc/repositories @@ -10,3 +10,4 @@ role: complement : # Local repository manifest (this repository). # +url: http://misc.cppget.org diff --git a/tests/loader/external/1/staging/repositories b/tests/loader/external/1/staging/repositories index 9a15f2b..8443ab8 100644 --- a/tests/loader/external/1/staging/repositories +++ b/tests/loader/external/1/staging/repositories @@ -1,3 +1,4 @@ : 1 # Local repository manifest (this repository). # +url: http://stage.cppget.org diff --git a/tests/loader/external/1/testing/repositories b/tests/loader/external/1/testing/repositories index 5f7246c..227d5ac 100644 --- a/tests/loader/external/1/testing/repositories +++ b/tests/loader/external/1/testing/repositories @@ -6,3 +6,4 @@ role: complement : # Local repository manifest (this repository). # +url: http://test.cppget.org |