aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-07 13:33:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-07 13:33:29 +0200
commit74bbd943c042478ac550ba7bf6fec0a14ae14bcf (patch)
tree90fbe65a3fc60fa2acc068d32f4a3a789cc0a41a
parent8826b24d68f3caff30ec0b70762073760dc8eb72 (diff)
Ignoring unknown manifest entries where appropriate
-rw-r--r--bpkg/build.cxx8
-rw-r--r--bpkg/fetch12
-rw-r--r--bpkg/fetch.cxx33
-rw-r--r--bpkg/pkg-configure.cxx2
-rw-r--r--bpkg/pkg-fetch.cxx2
-rw-r--r--bpkg/pkg-unpack.cxx2
-rw-r--r--bpkg/pkg-verify7
-rw-r--r--bpkg/pkg-verify-options.cli5
-rw-r--r--bpkg/pkg-verify.cxx11
-rw-r--r--bpkg/rep-create-options.cli5
-rw-r--r--bpkg/rep-create.cxx8
-rw-r--r--bpkg/rep-fetch.cxx4
-rw-r--r--bpkg/rep-info.cxx7
13 files changed, 65 insertions, 41 deletions
diff --git a/bpkg/build.cxx b/bpkg/build.cxx
index 0087180..86219dd 100644
--- a/bpkg/build.cxx
+++ b/bpkg/build.cxx
@@ -116,8 +116,8 @@ namespace bpkg
package_manifest m (
sp->state == package_state::fetched
- ? pkg_verify (options, a->absolute () ? *a : cd / *a)
- : pkg_verify (d->absolute () ? *d : cd / *d));
+ ? pkg_verify (options, a->absolute () ? *a : cd / *a, true)
+ : pkg_verify (d->absolute () ? *d : cd / *d, true));
return make_pair (make_shared<available_package> (move (m)), move (ar));
}
@@ -767,7 +767,7 @@ namespace bpkg
path a (s);
if (exists (a))
{
- package_manifest m (pkg_verify (o, a, false));
+ package_manifest m (pkg_verify (o, a, true, false));
// This is a package archive (note that we shouldn't throw
// failed from here on).
@@ -796,7 +796,7 @@ namespace bpkg
dir_path d (s);
if (exists (d))
{
- package_manifest m (pkg_verify (d, false));
+ package_manifest m (pkg_verify (d, true, false));
// This is a package directory (note that we shouldn't throw
// failed from here on).
diff --git a/bpkg/fetch b/bpkg/fetch
index 9a58cc3..4d7d78e 100644
--- a/bpkg/fetch
+++ b/bpkg/fetch
@@ -13,13 +13,17 @@
namespace bpkg
{
- repository_manifests fetch_repositories (const dir_path&);
+ repository_manifests fetch_repositories (const dir_path&,
+ bool ignore_unknown);
repository_manifests fetch_repositories (const common_options&,
- const repository_location&);
+ const repository_location&,
+ bool ignore_unknown);
- package_manifests fetch_packages (const dir_path&);
+ package_manifests fetch_packages (const dir_path&,
+ bool ignore_unknown);
package_manifests fetch_packages (const common_options&,
- const repository_location&);
+ const repository_location&,
+ bool ignore_unknown);
path
fetch_archive (const common_options&,
diff --git a/bpkg/fetch.cxx b/bpkg/fetch.cxx
index 2306d4e..f63a6e3 100644
--- a/bpkg/fetch.cxx
+++ b/bpkg/fetch.cxx
@@ -518,7 +518,8 @@ namespace bpkg
fetch_manifest (const common_options& o,
const string& host,
uint16_t port,
- const path& f)
+ const path& f,
+ bool ignore_unknown)
{
string url (to_url (host, port, f));
process pr (start (o, url));
@@ -529,7 +530,7 @@ namespace bpkg
is.exceptions (ifdstream::badbit | ifdstream::failbit);
manifest_parser mp (is, url);
- M m (mp);
+ M m (mp, ignore_unknown);
is.close ();
if (pr.wait ())
@@ -608,7 +609,7 @@ namespace bpkg
template <typename M>
static M
- fetch_manifest (const path& f)
+ fetch_manifest (const path& f, bool ignore_unknown)
{
if (!exists (f))
fail << "file " << f << " does not exist";
@@ -620,7 +621,7 @@ namespace bpkg
ifs.open (f.string ());
manifest_parser mp (ifs, f.string ());
- return M (mp);
+ return M (mp, ignore_unknown);
}
catch (const manifest_parsing& e)
{
@@ -637,41 +638,45 @@ namespace bpkg
static const path repositories ("repositories");
repository_manifests
- fetch_repositories (const dir_path& d)
+ fetch_repositories (const dir_path& d, bool iu)
{
- return fetch_manifest<repository_manifests> (d / repositories);
+ return fetch_manifest<repository_manifests> (d / repositories, iu);
}
repository_manifests
- fetch_repositories (const common_options& o, const repository_location& rl)
+ fetch_repositories (const common_options& o,
+ const repository_location& rl,
+ bool iu)
{
assert (rl.remote () || rl.absolute ());
path f (rl.path () / repositories);
return rl.remote ()
- ? fetch_manifest<repository_manifests> (o, rl.host (), rl.port (), f)
- : fetch_manifest<repository_manifests> (f);
+ ? fetch_manifest<repository_manifests> (o, rl.host (), rl.port (), f, iu)
+ : fetch_manifest<repository_manifests> (f, iu);
}
static const path packages ("packages");
package_manifests
- fetch_packages (const dir_path& d)
+ fetch_packages (const dir_path& d, bool iu)
{
- return fetch_manifest<package_manifests> (d / packages);
+ return fetch_manifest<package_manifests> (d / packages, iu);
}
package_manifests
- fetch_packages (const common_options& o, const repository_location& rl)
+ fetch_packages (const common_options& o,
+ const repository_location& rl,
+ bool iu)
{
assert (rl.remote () || rl.absolute ());
path f (rl.path () / packages);
return rl.remote ()
- ? fetch_manifest<package_manifests> (o, rl.host (), rl.port (), f)
- : fetch_manifest<package_manifests> (f);
+ ? fetch_manifest<package_manifests> (o, rl.host (), rl.port (), f, iu)
+ : fetch_manifest<package_manifests> (f, iu);
}
path
diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx
index f7e1901..9e478c8 100644
--- a/bpkg/pkg-configure.cxx
+++ b/bpkg/pkg-configure.cxx
@@ -50,7 +50,7 @@ namespace bpkg
{
assert (p->prerequisites.empty ());
- package_manifest m (pkg_verify (src_root));
+ package_manifest m (pkg_verify (src_root, true));
for (const dependency_alternatives& da: m.dependencies)
{
diff --git a/bpkg/pkg-fetch.cxx b/bpkg/pkg-fetch.cxx
index 492c4e7..1718c5b 100644
--- a/bpkg/pkg-fetch.cxx
+++ b/bpkg/pkg-fetch.cxx
@@ -142,7 +142,7 @@ namespace bpkg
// Verify archive is a package and get its manifest.
//
- package_manifest m (pkg_verify (co, a));
+ package_manifest m (pkg_verify (co, a, true));
level4 ([&]{trace << m.name << " " << m.version;});
// Check/diagnose an already existing package.
diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx
index 604abdf..9851d74 100644
--- a/bpkg/pkg-unpack.cxx
+++ b/bpkg/pkg-unpack.cxx
@@ -40,7 +40,7 @@ namespace bpkg
// Verify the directory is a package and get its manifest.
//
- package_manifest m (pkg_verify (d));
+ package_manifest m (pkg_verify (d, true));
level4 ([&]{trace << d << ": " << m.name << " " << m.version;});
// Make the package and configuration paths absolute and normalized.
diff --git a/bpkg/pkg-verify b/bpkg/pkg-verify
index 8a62b66..aac4f8a 100644
--- a/bpkg/pkg-verify
+++ b/bpkg/pkg-verify
@@ -21,13 +21,16 @@ namespace bpkg
// invalid.
//
package_manifest
- pkg_verify (const common_options&, const path& archive, bool diag = true);
+ pkg_verify (const common_options&,
+ const path& archive,
+ bool ignore_unknown,
+ bool diag = true);
// Similar to the above but verifies that a source directory is
// a valid package.
//
package_manifest
- pkg_verify (const dir_path& source, bool diag = true);
+ pkg_verify (const dir_path& source, bool ignore_unknown, bool diag = true);
}
#endif // BPKG_PKG_VERIFY
diff --git a/bpkg/pkg-verify-options.cli b/bpkg/pkg-verify-options.cli
index e1f810f..2a69623 100644
--- a/bpkg/pkg-verify-options.cli
+++ b/bpkg/pkg-verify-options.cli
@@ -31,5 +31,10 @@ namespace bpkg
"Suppress error messages about the reason why the package is
invalid. Just return the error status."
}
+
+ bool --ignore-unknown
+ {
+ "Ignore unknown manifest entries."
+ }
};
}
diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx
index 5e16410..3470e0a 100644
--- a/bpkg/pkg-verify.cxx
+++ b/bpkg/pkg-verify.cxx
@@ -21,7 +21,7 @@ using namespace butl;
namespace bpkg
{
package_manifest
- pkg_verify (const common_options& co, const path& af, bool diag)
+ pkg_verify (const common_options& co, const path& af, bool iu, bool diag)
{
// Figure out the package directory. Strip the top-level extension
// and, as a special case, if the second-level extension is .tar,
@@ -77,7 +77,7 @@ namespace bpkg
is.exceptions (ifdstream::badbit | ifdstream::failbit);
manifest_parser mp (is, mf.string ());
- package_manifest m (mp);
+ package_manifest m (mp, iu);
is.close ();
if (pr.wait ())
@@ -154,7 +154,7 @@ namespace bpkg
}
package_manifest
- pkg_verify (const dir_path& d, bool diag)
+ pkg_verify (const dir_path& d, bool iu, bool diag)
{
// Parse the manifest.
//
@@ -175,7 +175,7 @@ namespace bpkg
ifs.open (mf.string ());
manifest_parser mp (ifs, mf.string ());
- package_manifest m (mp);
+ package_manifest m (mp, iu);
// Verify package directory is <name>-<version>.
//
@@ -229,7 +229,8 @@ namespace bpkg
//
try
{
- package_manifest m (pkg_verify (o, a, !o.silent ()));
+ package_manifest m (
+ pkg_verify (o, a, o.ignore_unknown (), !o.silent ()));
if (verb && !o.silent ())
text << "valid package " << m.name << " " << m.version;
diff --git a/bpkg/rep-create-options.cli b/bpkg/rep-create-options.cli
index 13c3b3d..70ca78d 100644
--- a/bpkg/rep-create-options.cli
+++ b/bpkg/rep-create-options.cli
@@ -19,5 +19,10 @@ namespace bpkg
"Use <dir> as the repository root directory instead of the
current working directory."
*/
+
+ bool --ignore-unknown
+ {
+ "Ignore unknown manifest entries."
+ }
};
}
diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx
index 1f0e420..27aeb0a 100644
--- a/bpkg/rep-create.cxx
+++ b/bpkg/rep-create.cxx
@@ -52,7 +52,7 @@ namespace bpkg
using package_map = map<package_key, package_data>;
static void
- collect (const common_options& co,
+ collect (const rep_create_options& o,
package_map& map,
const dir_path& d,
const dir_path& root)
@@ -76,7 +76,7 @@ namespace bpkg
{
case entry_type::directory:
{
- collect (co, map, path_cast<dir_path> (d / p), root);
+ collect (o, map, path_cast<dir_path> (d / p), root);
continue;
}
case entry_type::regular:
@@ -97,7 +97,7 @@ namespace bpkg
// Verify archive is a package and get its manifest.
//
path a (d / p);
- package_manifest m (pkg_verify (co, a));
+ package_manifest m (pkg_verify (o, a, o.ignore_unknown ()));
level4 ([&]{trace << m.name << " " << m.version << " in " << a;});
@@ -146,7 +146,7 @@ namespace bpkg
// Load the 'repositories' file to make sure it is there and
// is valid.
//
- repository_manifests rms (fetch_repositories (d));
+ repository_manifests rms (fetch_repositories (d, o.ignore_unknown ()));
level4 ([&]{trace << rms.size () - 1 << " prerequisite repository(s)";});
// While we could have serialized as we go along, the order of
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index f96607f..1136e98 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -47,7 +47,7 @@ namespace bpkg
// Load the 'repositories' file and use it to populate the
// prerequisite and complement repository sets.
//
- repository_manifests rms (fetch_repositories (co, rl));
+ repository_manifests rms (fetch_repositories (co, rl, true));
for (repository_manifest& rm: rms)
{
@@ -130,7 +130,7 @@ namespace bpkg
// @@ We need to check that that 'repositories' file hasn't
// changed since.
//
- package_manifests pms (fetch_packages (co, rl));
+ package_manifests pms (fetch_packages (co, rl, true));
// "Suspend" session while persisting packages to reduce memory
// consumption.
diff --git a/bpkg/rep-info.cxx b/bpkg/rep-info.cxx
index 041d804..7ca7b22 100644
--- a/bpkg/rep-info.cxx
+++ b/bpkg/rep-info.cxx
@@ -32,10 +32,11 @@ namespace bpkg
repository_location rl (parse_location (args.next ()));
- // Fetch everything we will need before printing anything.
+ // Fetch everything we will need before printing anything. Ignore
+ // unknown manifest entries unless we are dumping them.
//
- repository_manifests rms (fetch_repositories (o, rl));
- package_manifests pms (fetch_packages (o, rl));
+ repository_manifests rms (fetch_repositories (o, rl, !o.manifest ()));
+ package_manifests pms (fetch_packages (o, rl, !o.manifest ()));
// Now print.
//