aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/common-options.cli18
-rw-r--r--bpkg/pkg-fetch.cxx2
-rw-r--r--bpkg/pkg-unpack.cxx30
-rw-r--r--bpkg/pkg-verify2
-rw-r--r--bpkg/pkg-verify.cxx27
-rw-r--r--bpkg/rep-create.cxx13
-rwxr-xr-xbpkg/test.sh2
7 files changed, 69 insertions, 25 deletions
diff --git a/bpkg/common-options.cli b/bpkg/common-options.cli
index d564a1c..8088ccc 100644
--- a/bpkg/common-options.cli
+++ b/bpkg/common-options.cli
@@ -54,6 +54,24 @@ namespace bpkg
option to specify multiple fetch options."
};
+ path --tar = "tar"
+ {
+ "<path>",
+ "The tar program that should be used to extract package archives. For
+ example, \cb{gtar} or \cb{bsdtar}. You can also specify additional
+ options that should be passed to the tar program with
+ \cb{--tar-option}. If the tar program is not explicitly specified,
+ then \cb{bpkg} will use \cb{tar} by default."
+ };
+
+ strings --tar-option
+ {
+ "<opt>",
+ "Additional option that should be passed to the tar program. See
+ \cb{--tar} for more information on the tar program. Repeat this
+ option to specify multiple tar options."
+ };
+
// The following option is "fake" in that it is actually handled by
// argv_file_scanner. We have it here for documentation.
//
diff --git a/bpkg/pkg-fetch.cxx b/bpkg/pkg-fetch.cxx
index 9da632a..ca2bada 100644
--- a/bpkg/pkg-fetch.cxx
+++ b/bpkg/pkg-fetch.cxx
@@ -105,7 +105,7 @@ namespace bpkg
// Verify archive is a package and get its manifest.
//
- package_manifest m (pkg_verify (a));
+ package_manifest m (pkg_verify (o, a));
level4 ([&]{trace << m.name << " " << m.version;});
const auto& n (m.name);
diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx
index 84dd5ae..5fc5f0b 100644
--- a/bpkg/pkg-unpack.cxx
+++ b/bpkg/pkg-unpack.cxx
@@ -77,7 +77,10 @@ namespace bpkg
}
static shared_ptr<package>
- pkg_unpack (database& db, const dir_path& c, const string& name)
+ pkg_unpack (const common_options& co,
+ database& db,
+ const dir_path& c,
+ const string& name)
{
tracer trace ("pkg_unpack(pkg)");
tracer_guard tg (db, trace);
@@ -120,19 +123,28 @@ namespace bpkg
//
auto_rm_r arm (d);
- const char* args[] {
- "tar",
- "-C", c.string ().c_str (), // -C/--directory -- change to directory.
- "-xf",
- a.string ().c_str (),
- nullptr};
+ cstrings args {co.tar ().string ().c_str ()};
+
+ // Add extra options.
+ //
+ for (const string& o: co.tar_option ())
+ args.push_back (o.c_str ());
+
+ // -C/--directory -- change to directory.
+ //
+ args.push_back ("-C");
+ args.push_back (c.string ().c_str ());
+
+ args.push_back ("-xf");
+ args.push_back (a.string ().c_str ());
+ args.push_back (nullptr);
if (verb >= 2)
print_process (args);
try
{
- process pr (args);
+ process pr (args.data ());
// While it is reasonable to assuming the child process issued
// diagnostics, tar, specifically, doesn't mention the archive
@@ -194,7 +206,7 @@ namespace bpkg
fail << "package name argument expected" <<
info << "run 'bpkg help pkg-unpack' for more information";
- p = pkg_unpack (db, c, args.next ());
+ p = pkg_unpack (o, db, c, args.next ());
}
if (verb)
diff --git a/bpkg/pkg-verify b/bpkg/pkg-verify
index 8250579..e0675c6 100644
--- a/bpkg/pkg-verify
+++ b/bpkg/pkg-verify
@@ -21,7 +21,7 @@ namespace bpkg
// invalid.
//
package_manifest
- pkg_verify (const path& archive, bool diag = true);
+ pkg_verify (const common_options&, const path& archive, bool diag = true);
// Similar to the above but verifies that a source directory is
// a valid package.
diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx
index a7d215e..969eb22 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 path& af, bool diag)
+ pkg_verify (const common_options& co, const path& af, bool diag)
{
// Figure out the package directory. Strip the top-level extension
// and, as a special case, if the second-level extension is .tar,
@@ -38,12 +38,21 @@ namespace bpkg
//
path mf (pd / path ("manifest"));
- const char* args[] {
- "tar",
- "-xOf", // -O/--to-stdout -- extract to STDOUT.
- af.string ().c_str (),
- mf.string ().c_str (),
- nullptr};
+ cstrings args {co.tar ().string ().c_str ()};
+
+ // Add extra options.
+ //
+ for (const string& o: co.tar_option ())
+ args.push_back (o.c_str ());
+
+ // -O/--to-stdout -- extract to STDOUT.
+ //
+ args.push_back ("-O");
+
+ args.push_back ("-xf");
+ args.push_back (af.string ().c_str ());
+ args.push_back (mf.string ().c_str ());
+ args.push_back (nullptr);
if (verb >= 2)
print_process (args);
@@ -60,7 +69,7 @@ namespace bpkg
// since we assume that the child error is always the reason for
// the manifest parsing failure.
//
- process pr (args, 0, -1, (diag ? 2 : 1));
+ process pr (args.data (), 0, -1, (diag ? 2 : 1));
try
{
@@ -218,7 +227,7 @@ namespace bpkg
// If we were asked to run silent, don't yap about the reason
// why the package is invalid. Just return the error status.
//
- package_manifest m (pkg_verify (a, !o.silent ()));
+ package_manifest m (pkg_verify (o, a, !o.silent ()));
if (verb && !o.silent ())
text << "valid package " << m.name << " " << m.version;
diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx
index 8cb1827..291374e 100644
--- a/bpkg/rep-create.cxx
+++ b/bpkg/rep-create.cxx
@@ -52,7 +52,10 @@ namespace bpkg
using package_map = map<package_key, package_data>;
static void
- collect (package_map& map, const dir_path& d, const dir_path& root)
+ collect (const common_options& co,
+ package_map& map,
+ const dir_path& d,
+ const dir_path& root)
try
{
tracer trace ("collect");
@@ -73,7 +76,7 @@ namespace bpkg
{
case entry_type::directory:
{
- collect (map, path_cast<dir_path> (d / p), root);
+ collect (co, map, path_cast<dir_path> (d / p), root);
continue;
}
case entry_type::regular:
@@ -94,7 +97,7 @@ namespace bpkg
// Verify archive is a package and get its manifest.
//
path a (d / p);
- package_manifest m (pkg_verify (a));
+ package_manifest m (pkg_verify (co, a));
level4 ([&]{trace << m.name << " " << m.version << " in " << a;});
@@ -129,7 +132,7 @@ namespace bpkg
}
void
- rep_create (const rep_create_options&, cli::scanner& args)
+ rep_create (const rep_create_options& o, cli::scanner& args)
try
{
tracer trace ("rep_create");
@@ -151,7 +154,7 @@ namespace bpkg
// collecting all the manifests in a map we get a sorted list.
//
package_map pm;
- collect (pm, d, d);
+ collect (o, pm, d, d);
// Serialize.
//
diff --git a/bpkg/test.sh b/bpkg/test.sh
index 9ff6908..5449883 100755
--- a/bpkg/test.sh
+++ b/bpkg/test.sh
@@ -4,6 +4,8 @@ trap 'exit 1' ERR
bpkg="./bpkg $*"
#bpkg="valgrind -q ./bpkg $*"
+#bpkg="./bpkg --fetch curl $*"
+#bpkg="./bpkg --fetch fetch --tar bsdtar $*"
cfg=/tmp/conf
pkg=libhello
ver=1.0.0