From 3c8e389347445913fb3329a53decf04e0af87735 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 May 2022 09:21:25 +0200 Subject: Use bsdtar or gtar on OpenBSD for -O|--to-stdout support --- bpkg/archive.cxx | 29 ++++++++++++++++++++++++----- 1 file 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. // -- cgit v1.1