From 9f4ef03ed488acd2af2ec5155a37677444edc605 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 30 May 2019 13:25:18 +0200 Subject: Default to libarchive's bsdtar for tar archives on Windows --- build2/dist/operation.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'build2') diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx index fddfcea..7b07c0f 100644 --- a/build2/dist/operation.cxx +++ b/build2/dist/operation.cxx @@ -575,12 +575,19 @@ namespace build2 } else { + // On Windows we default to libarchive's bsdtar with auto-compression. + // +#ifdef _WIN32 + const char* tar = "bsdtar"; +#else + const char* tar = "tar"; + if (const char* c = (e == "tar.gz" ? "gzip" : e == "tar.xz" ? "xz" : e == "tar.bz2" ? "bzip2" : nullptr)) { - args = {"tar", + args = {tar, "--format", "ustar", "-cf", "-", pkg.c_str (), @@ -603,14 +610,16 @@ namespace build2 fail << "unable to open " << ap << ": " << e; } } - else if (e == "tar") - args = {"tar", + else +#endif + if (e == "tar") + args = {tar, "--format", "ustar", "-cf", ap.string ().c_str (), pkg.c_str (), nullptr}; else - args = {"tar", + args = {tar, "--format", "ustar", "-a", "-cf", ap.string ().c_str (), -- cgit v1.1