aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/pkg-build.cli10
-rw-r--r--bpkg/pkg-build.cxx63
-rwxr-xr-xtests/test.sh4
3 files changed, 44 insertions, 33 deletions
diff --git a/bpkg/pkg-build.cli b/bpkg/pkg-build.cli
index 2b0d24a..9de38f2 100644
--- a/bpkg/pkg-build.cli
+++ b/bpkg/pkg-build.cli
@@ -15,7 +15,7 @@ namespace bpkg
"\h|SYNOPSIS|
- \c{\b{bpkg pkg-build}|\b{build} [<options>] (<pkg>[/<ver>] | <file> | <dir>)...}
+ \c{\b{bpkg pkg-build}|\b{build} [<options>] (<pkg>[/<ver>] | <file> | <dir>/)...}
\h|DESCRIPTION|
@@ -27,10 +27,10 @@ namespace bpkg
information on package repositories.
Alternatively, the package can be specified as either the path to the
- package archive (<file>) or to the package directory (<dir>). See the
- \l{bpkg-pkg-fetch(1)} and \l{bpkg-pkg-unpack(1)} commands for more
- information on the semantics of specifying the package as an archive or
- a directory.
+ package archive (<file>) or to the package directory (<dir>/; note that
+ it must end with a directory separator). See the \l{bpkg-pkg-fetch(1)}
+ and \l{bpkg-pkg-unpack(1)} commands for more information on the semantics
+ of specifying the package as an archive or a directory.
Packages that are specified explicitly on the command line will be
\i{held}, that is, they will not be considered for automatic removal if
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.
diff --git a/tests/test.sh b/tests/test.sh
index b4905c0..0cdcd4f 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -824,7 +824,7 @@ fail pkg-build -p libfoo/1.0.0 # unknown package
test pkg-build -p repository/1/satisfy/libfoo-1.1.0.tar.gz <<EOF
build libfoo 1.1.0
EOF
-test pkg-build -p repository/1/satisfy/libfoo-1.1.0 <<EOF
+test pkg-build -p repository/1/satisfy/libfoo-1.1.0/ <<EOF
build libfoo 1.1.0
EOF
@@ -1171,7 +1171,7 @@ stat libbaz/1.1.0 "configured hold_package"
test cfg-create --wipe
test pkg-build -y repository/1/satisfy/libfoo-1.0.0.tar.gz
stat libfoo "configured 1.0.0 hold_package hold_version"
-test pkg-build -y repository/1/satisfy/libfoo-1.1.0
+test pkg-build -y repository/1/satisfy/libfoo-1.1.0/
stat libfoo "configured 1.1.0 hold_package hold_version"
test cfg-create --wipe