aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brep/package11
-rw-r--r--brep/package.cxx6
-rw-r--r--loader/loader.cxx5
-rw-r--r--tests/loader/driver.cxx18
-rw-r--r--tests/loader/external/1/misc/packages1
-rw-r--r--tests/loader/internal/1/math/packages2
-rw-r--r--tests/loader/internal/1/stable/packages4
7 files changed, 43 insertions, 4 deletions
diff --git a/brep/package b/brep/package
index 45660a6..0132b73 100644
--- a/brep/package
+++ b/brep/package
@@ -80,6 +80,13 @@ namespace brep
#pragma db map type(path) as(std::string) \
to((?).string ()) from(brep::path (?))
+ using optional_path = optional<path>;
+ using optional_string = optional<std::string>;
+
+ #pragma db map type(optional_path) as(brep::optional_string) \
+ to((?) ? (?)->string () : brep::optional_string ()) \
+ from((?) ? brep::path (*(?)) : brep::optional_path ())
+
using dir_path = butl::dir_path;
#pragma db map type(dir_path) as(std::string) \
@@ -352,7 +359,8 @@ namespace brep
license_alternatives_type,
std::string changes,
dependencies_type,
- requirements_type);
+ requirements_type,
+ optional<path> location);
// Manifest data.
//
@@ -364,6 +372,7 @@ namespace brep
std::string changes;
dependencies_type dependencies;
requirements_type requirements;
+ optional<path> location;
// Database mapping.
//
diff --git a/brep/package.cxx b/brep/package.cxx
index 585a0b5..215754f 100644
--- a/brep/package.cxx
+++ b/brep/package.cxx
@@ -62,7 +62,8 @@ namespace brep
license_alternatives_type la,
string ch,
dependencies_type dp,
- requirements_type rq)
+ requirements_type rq,
+ optional<path> lc)
: repository (move (rp)),
package (move (pk)),
version (move (vr)),
@@ -70,7 +71,8 @@ namespace brep
license_alternatives (move (la)),
changes (move (ch)),
dependencies (move (dp)),
- requirements (move (rq))
+ requirements (move (rq)),
+ location (move (lc))
{
}
diff --git a/loader/loader.cxx b/loader/loader.cxx
index 503f577..e666804 100644
--- a/loader/loader.cxx
+++ b/loader/loader.cxx
@@ -416,6 +416,7 @@ load_repository (const shared_ptr<repository>& rp, database& db)
//
dependencies dep;
requirements req;
+ brep::optional<path> loc; // Ambiguity with butl::optional.
string chn;
// Don't add dependencies, requirements and changes for external
@@ -425,6 +426,7 @@ load_repository (const shared_ptr<repository>& rp, database& db)
{
dep = move (pm.dependencies);
req = move (pm.requirements);
+ loc = move (pm.location);
for (auto& c: pm.changes)
{
@@ -450,7 +452,8 @@ load_repository (const shared_ptr<repository>& rp, database& db)
move (pm.license_alternatives),
move (chn),
move (dep),
- move (req));
+ move (req),
+ move (loc));
db.persist (pv);
}
diff --git a/tests/loader/driver.cxx b/tests/loader/driver.cxx
index 0c6c995..e828e79 100644
--- a/tests/loader/driver.cxx
+++ b/tests/loader/driver.cxx
@@ -35,6 +35,17 @@ operator== (const dependency& a, const dependency& b)
a.version->operation == b.version->operation));
}
+static bool
+check_location (shared_ptr<package_version>& pv)
+{
+ if (pv->repository.load ()->internal)
+ return pv->location && *pv->location ==
+ path (pv->package.load ()->name + "-" + pv->version.string () +
+ ".tar.gz");
+ else
+ return !pv->location;
+}
+
int
main (int argc, char* argv[])
{
@@ -143,6 +154,7 @@ main (int argc, char* argv[])
fv1.epoch (),
fv1.canonical_upstream ()}));
assert (srv[0].load () == fpv1);
+ assert (check_location (fpv1));
version fv2 ("1.2.3-4");
shared_ptr<package_version> fpv2 (
@@ -153,6 +165,7 @@ main (int argc, char* argv[])
fv2.epoch (),
fv2.canonical_upstream ()}));
assert (srv[1].load () == fpv2);
+ assert (check_location (fpv2));
version fv3 ("1.2.4");
shared_ptr<package_version> fpv3 (
@@ -163,6 +176,7 @@ main (int argc, char* argv[])
fv3.epoch (),
fv3.canonical_upstream ()}));
assert (srv[2].load () == fpv3);
+ assert (check_location (fpv3));
version xv ("1.0.0-1");
shared_ptr<package_version> xpv (
@@ -173,6 +187,7 @@ main (int argc, char* argv[])
xv.epoch (),
xv.canonical_upstream ()}));
assert (srv[3].load () == xpv);
+ assert (check_location (xpv));
// Verify libstudxml package.
//
@@ -358,6 +373,7 @@ main (int argc, char* argv[])
ev.epoch (),
ev.canonical_upstream ()}));
assert (mrv[0].load () == epv);
+ assert (check_location (epv));
version fv4 ("1.2.4-1");
shared_ptr<package_version> fpv4 (
@@ -369,6 +385,7 @@ main (int argc, char* argv[])
fv4.canonical_upstream ()}));
assert (mrv[1].load () == fpv4);
assert (fpv[3].load () == fpv4);
+ assert (check_location (fpv4));
// Verify libexp package.
//
@@ -433,6 +450,7 @@ main (int argc, char* argv[])
bv.epoch (),
bv.canonical_upstream ()}));
assert (crv[0].load () == bpv);
+ assert (check_location (bpv));
// Verify libbar package.
//
diff --git a/tests/loader/external/1/misc/packages b/tests/loader/external/1/misc/packages
index de96771..718b30e 100644
--- a/tests/loader/external/1/misc/packages
+++ b/tests/loader/external/1/misc/packages
@@ -12,3 +12,4 @@ depends: libfoo
depends: libmath >= 2.0.0
requires: linux | windows | macosx
changes: some changes
+location: libbar-2.3.5.tar.gz
diff --git a/tests/loader/internal/1/math/packages b/tests/loader/internal/1/math/packages
index e55168f..f2d7024 100644
--- a/tests/loader/internal/1/math/packages
+++ b/tests/loader/internal/1/math/packages
@@ -7,6 +7,7 @@ tags: c++, exponent
url: http://www.exp.com
email: users@exp.com
depends: libmisc
+location: libexp-1+1.2.tar.gz
:
name: libfoo
version: 1.2.4-1
@@ -17,3 +18,4 @@ tags: c++, foo, math
url: http://www.example.com/foo/
email: foo-users@example.com
depends: libmisc >= 2.3.0
+location: libfoo-1.2.4-1.tar.gz
diff --git a/tests/loader/internal/1/stable/packages b/tests/loader/internal/1/stable/packages
index 59898c1..b95aa62 100644
--- a/tests/loader/internal/1/stable/packages
+++ b/tests/loader/internal/1/stable/packages
@@ -7,6 +7,7 @@ tags: c++, foo
url: http://www.example.com/foo/
email: foo-users@example.com
depends: libmisc >= 2.0.0
+location: libfoo-1.2.3-4.tar.gz
:
name: libstudxml
version: 1.0.0-1
@@ -21,6 +22,7 @@ email: studxml-users@codesynthesis.com; Public mailing list, posts by\
package-email: boris@codesynthesis.com; Direct email to the author.
depends: libexpat >= 2.0.0
depends: libgenx
+location: libstudxml-1.0.0-1.tar.gz
:
name: libfoo
version: 1.2.2
@@ -35,6 +37,7 @@ requires: linux | windows | macosx
requires: c++11
requires: ? ; VC++ 12.0 or later if targeting Windows.
requires: ? ; libc++ standard library if using Clang on Mac OS X.
+location: libfoo-1.2.2.tar.gz
:
name: libfoo
version: 1.2.4
@@ -47,3 +50,4 @@ email: foo-users@example.com
depends: libmisc >= 2.0.0
changes: some changes 1
changes: some changes 2
+location: libfoo-1.2.4.tar.gz