aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-03-03 15:09:37 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-03-03 15:38:45 +0300
commitfca35b977472f5fec9a1a8129792e94cc78cc204 (patch)
tree8be640a1536dd5a14cf12479e9358a4425efe894
parent26a2f3a6c485d7fdb6f11f106978eb6ca84af5f9 (diff)
Fix support of package scheme in <package>@<location>
-rw-r--r--bpkg/pkg-build.cxx43
-rw-r--r--tests/pkg-build.test90
2 files changed, 101 insertions, 32 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index f580858..77469f5 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -1084,20 +1084,29 @@ namespace bpkg
{
size_t p (0);
- // Skip leading ':' that are not part of "://".
+ // Check that the scheme belongs to a URL: is not one character long and
+ // is followed by :/.
+ //
+ auto url_scheme = [&arg, &p] () -> bool
+ {
+ assert (arg[p] == ':');
+ return p > 1 && // Is not a Windows drive letter.
+ arg[p + 1] == '/';
+ };
+
+ // Skip leading ':' that are not part of a URL.
//
while ((p = arg.find_first_of ("@:", p)) != string::npos &&
- arg[p] == ':' &&
- arg.compare (p + 1, 2, "//") != 0)
+ arg[p] == ':' && !url_scheme ())
++p;
if (p != string::npos)
{
if (arg[p] == ':')
{
- p = arg.compare (p + 1, 2, "//") != 0
- ? string::npos
- : 0; // The whole thing is the location.
+ p = url_scheme ()
+ ? 0 // The whole thing is the location.
+ : string::npos;
}
else
p += 1; // Skip '@'.
@@ -1217,18 +1226,23 @@ namespace bpkg
string pkg (ps, b, p != string::npos ? p - b : p);
const char* s (pkg.c_str ());
- // @@ Shouldn't we skip version selection for sys packages?
- //
- parse_package_scheme (s);
+ bool sys (parse_package_scheme (s) == package_scheme::sys);
string n (parse_package_name (s));
version v (parse_package_version (s));
- optional<dependency_constraint> c (
- !v.empty () ? optional<dependency_constraint> (v) : nullopt);
-
// Check if the package is present in the repository and its
// complements, recursively.
//
+ // Note that for the system package we don't care about its exact
+ // version available from the repository (which may well be a
+ // stub). All we need is to make sure that it is present in the
+ // repository.
+ //
+ optional<dependency_constraint> c (
+ v.empty () || sys
+ ? nullopt
+ : optional<dependency_constraint> (v));
+
shared_ptr<available_package> ap (
find_available (db, n, r, c, false /* prereq */).first);
@@ -1243,7 +1257,10 @@ namespace bpkg
// Add the [scheme:]package/version to the argument list.
//
- eargs.push_back (pkg + '/' + ap->version.string ());
+ // Note that the system package is added to the argument list as
+ // it appears originally (see above).
+ //
+ eargs.push_back (sys ? pkg : n + '/' + ap->version.string ());
b = p != string::npos ? p + 1 : p;
}
diff --git a/tests/pkg-build.test b/tests/pkg-build.test
index 2b54d12..d0f9787 100644
--- a/tests/pkg-build.test
+++ b/tests/pkg-build.test
@@ -1313,30 +1313,69 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
: all-packages
:
{
- $clone_root_cfg;
+ : explicit
+ :
+ {
+ $clone_root_cfg;
- $* "@$rep/t4d" 2>>~%EOE%;
- %.+
- %info: .+libfox-1.0.0.+ is up to date%
- %info: .+libbiz-1.0.0.+ is up to date%
- updated libfox/1.0.0
- updated libbiz/1.0.0
- EOE
+ $* "@$rep/t4d" 2>>~%EOE%;
+ %.+
+ %info: .+libfox-1.0.0.+ is up to date%
+ %info: .+libbiz-1.0.0.+ is up to date%
+ updated libfox/1.0.0
+ updated libbiz/1.0.0
+ EOE
- $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0';
- $pkg_purge libbiz 2>'purged libbiz/1.0.0';
+ $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0';
+ $pkg_purge libbiz 2>'purged libbiz/1.0.0';
- $pkg_disfigure libfox 2>'disfigured libfox/1.0.0';
- $pkg_purge libfox 2>'purged libfox/1.0.0';
+ $pkg_disfigure libfox 2>'disfigured libfox/1.0.0';
+ $pkg_purge libfox 2>'purged libfox/1.0.0';
- $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
- $pkg_purge libbaz 2>'purged libbaz/1.1.0';
+ $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
+ $pkg_purge libbaz 2>'purged libbaz/1.1.0';
- $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
- $pkg_purge libbar 2>'purged libbar/1.1.0';
+ $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
+ $pkg_purge libbar 2>'purged libbar/1.1.0';
- $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
- $pkg_purge libfoo 2>'purged libfoo/1.1.0'
+ $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
+ $pkg_purge libfoo 2>'purged libfoo/1.1.0'
+ }
+
+ : url-detection
+ :
+ {
+ $clone_root_cfg;
+
+ if ($remote != true)
+ rep = ($cxx.target.class != 'windows' \
+ ? "file:$rep" \
+ : "file:/$regex.replace($rep, '\\', '/')")
+ end;
+
+ $* "$rep/t4d" 2>>~%EOE%;
+ %.+
+ %info: .+libfox-1.0.0.+ is up to date%
+ %info: .+libbiz-1.0.0.+ is up to date%
+ updated libfox/1.0.0
+ updated libbiz/1.0.0
+ EOE
+
+ $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0';
+ $pkg_purge libbiz 2>'purged libbiz/1.0.0';
+
+ $pkg_disfigure libfox 2>'disfigured libfox/1.0.0';
+ $pkg_purge libfox 2>'purged libfox/1.0.0';
+
+ $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0';
+ $pkg_purge libbaz 2>'purged libbaz/1.1.0';
+
+ $pkg_disfigure libbar 2>'disfigured libbar/1.1.0';
+ $pkg_purge libbar 2>'purged libbar/1.1.0';
+
+ $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0';
+ $pkg_purge libfoo 2>'purged libfoo/1.1.0'
+ }
}
: multiple-packages
@@ -1383,6 +1422,19 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
$pkg_purge libfoo 2>'purged libfoo/1.0.0'
}
+ : system
+ :
+ {
+ $clone_root_cfg;
+
+ $* "sys:libbiz/2.0.0@$rep/t4d" 2>>~%EOE%;
+ %.+
+ configured sys:libbiz/2.0.0
+ EOE
+
+ $pkg_disfigure libbiz 2>'purged libbiz/2.0.0'
+ }
+
: non-existent-package
:
{
@@ -1390,7 +1442,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>!
$* "libbar@$rep/t4d" 2>>~%EOE% != 0
%.+
- error: package libbar is not found in bpkg:build2.org/pkg-build/t4d nor its complements
+ error: package libbar is not found in bpkg:build2.org/pkg-build/t4d or its complements
EOE
}
}