From 45863925a722c75b6ca4ba055c4a7d54f53d3f95 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 22 Jul 2021 10:49:27 +0100 Subject: tar: use external program for lzma/xz compression The lzma and xz applets don't support compression. Any attempt to generate a tar file using these compressors should try to use an external program. (Which probably won't work on a typical Windows system, but hey, at least we made the effort.) See GitHub issue #222. --- win32/popen.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/win32/popen.c b/win32/popen.c index 8810b8de0..c9ea00ffd 100644 --- a/win32/popen.c +++ b/win32/popen.c @@ -315,11 +315,17 @@ pid_t mingw_fork_compressor(int fd, const char *compressor, const char *mode) int fd1; pid_t pid; - if (find_applet_by_name(compressor) >= 0) + if (find_applet_by_name(compressor) < 0 +#if ENABLE_XZ || ENABLE_LZMA + /* xz and lzma applets don't support compression, try using + * an external program */ + || (mode[0] == 'w' && index_in_strings("lzma\0xz\0", compressor) >= 0) +#endif + ) + cmd = xasprintf("%s -cf -", compressor); + else cmd = xasprintf("%s --busybox %s -cf -", bb_busybox_exec_path, compressor); - else - cmd = xasprintf("%s -cf -", compressor); if ((fd1 = mingw_popen_fd(cmd, mode, fd, &pid)) == -1) bb_perror_msg_and_die("can't execute '%s'", compressor); -- cgit v1.2.3-55-g6feb