diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-05-27 09:21:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-05-27 09:21:25 +0200 |
commit | 3c8e389347445913fb3329a53decf04e0af87735 (patch) | |
tree | a893d499bf8ca000c874392ff6f7fdab1b7e0d39 | |
parent | 25628489a936de1149f03425bb8653f6cfb09639 (diff) |
Use bsdtar or gtar on OpenBSD for -O|--to-stdout support
-rw-r--r-- | bpkg/archive.cxx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/bpkg/archive.cxx b/bpkg/archive.cxx index 2d92802..c41c4e3 100644 --- a/bpkg/archive.cxx +++ b/bpkg/archive.cxx @@ -43,14 +43,33 @@ namespace bpkg // On Windows we default to libarchive's bsdtar with auto-decompression // (though there is also bsdcat which we could have used). // - const char* tar (co.tar_specified () - ? co.tar ().string ().c_str () + // OpenBSD tar does not support -O|--to-stdout and so far the best + // solution seems to require bsdtar (libarchive) or gtar (GNU tar). + // + const char* tar; + + if (co.tar_specified ()) + tar = co.tar ().string ().c_str (); + else + { #ifdef _WIN32 - : "bsdtar" + tar = "bsdtar"; +#elif defined(__OpenBSD__) + // A bit wasteful to do this every time (and throw away the result). + // Oh, well, the user can always "optimize" this away by passing + // explicit --tar. + // + if (!process::try_path_search ("bsdtar", true).empty ()) + tar = "bsdtar"; + else if (!process::try_path_search ("gtar", true).empty ()) + tar = "gtar"; + else + fail << "bsdtar or gtar required on OpenBSD for -O|--to-stdout support" + << endf; #else - : "tar" + tar = "tar"; #endif - ); + } // See if we need to decompress. // |