aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-build.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-23 16:37:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-23 16:37:06 +0200
commitf39ac3228bc30ba770c266e19110f36ea5d83d90 (patch)
treebdb996bf31c443d18bb7607e8929f2b9e050abe1 /bpkg/pkg-build.cxx
parent0072c2109599d2d46dbde4f84a5957487d6158e7 (diff)
Unless name ends with a separator don't try it as package directory in pkg-build
Diffstat (limited to 'bpkg/pkg-build.cxx')
-rw-r--r--bpkg/pkg-build.cxx63
1 files changed, 37 insertions, 26 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index f4d4699..9dc58c4 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -7,6 +7,7 @@
#include <map>
#include <set>
#include <list>
+#include <cstring> // strlen()
#include <iostream> // cout
#include <algorithm> // find()
@@ -841,6 +842,7 @@ namespace bpkg
for (bool diag (false); args.more (); )
{
const char* s (args.peek ());
+ size_t sn (strlen (s));
// Reduce all the potential variations (archive, directory, package
// name, package name/version) to a single available_package object.
@@ -886,35 +888,44 @@ namespace bpkg
// Is this a package directory?
//
- try
+ // We used to just check any name which led to some really bizarre
+ // behavior where a sub-directory of the working directory happened
+ // to contain a manifest file and was therefore treated as a package
+ // directory. So now we will only do this test if the name ends with
+ // the directory separator.
+ //
+ if (sn != 0 && path::traits::is_separator (s[sn - 1]))
{
- dir_path d (s);
- if (exists (d))
+ try
{
- if (diag)
- info << "'" << s << "' does not appear to be a valid package "
- << "directory: ";
-
- package_manifest m (pkg_verify (d, true, diag));
-
- // This is a package directory (note that we shouldn't throw
- // failed from here on).
- //
- l4 ([&]{trace << "directory " << d;});
- n = m.name;
- v = m.version;
- ap = make_shared<available_package> (move (m));
- ar = root;
- ap->locations.push_back (package_location {root, move (d)});
+ dir_path d (s);
+ if (exists (d))
+ {
+ if (diag)
+ info << "'" << s << "' does not appear to be a valid package "
+ << "directory: ";
+
+ package_manifest m (pkg_verify (d, true, diag));
+
+ // This is a package directory (note that we shouldn't throw
+ // failed from here on).
+ //
+ l4 ([&]{trace << "directory " << d;});
+ n = m.name;
+ v = m.version;
+ ap = make_shared<available_package> (move (m));
+ ar = root;
+ ap->locations.push_back (package_location {root, move (d)});
+ }
+ }
+ catch (const invalid_path&)
+ {
+ // Not a valid path so cannot be an archive.
+ }
+ catch (const failed&)
+ {
+ // Not a valid package archive.
}
- }
- catch (const invalid_path&)
- {
- // Not a valid path so cannot be an archive.
- }
- catch (const failed&)
- {
- // Not a valid package archive.
}
// If this was a diagnostics "run", then we are done.