From cbcf98064cf2dd8a2da80932af799789dc2ca2a9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 29 Sep 2015 17:30:19 +0200 Subject: Add --tar, --tar-option options, test with bsdtar --- bpkg/pkg-unpack.cxx | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'bpkg/pkg-unpack.cxx') 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 - 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) -- cgit v1.1