[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-tar] tar patch to selectively divert named compressors to alte
From: |
Sergey Poznyakoff |
Subject: |
Re: [Help-tar] tar patch to selectively divert named compressors to alternatives |
Date: |
Sat, 10 Oct 2009 17:44:00 +0300 |
Paul Wise <address@hidden> ha escrit:
> I personally feel that alternatives are not the best way to do this,
> because there will be some distros that do not implement a feature like
> this. In my opinion the most useful solution would be for tar to gain
> knowledge about the various bzip2 filters available and have them
> selectable via an environment variable as well as a command-line option.
> I understand that tar upstream does not want to do that though.
I didn't say that I did not want to do that. I asked to allow me
some more time to weigh all pros and cons and prepare the optimal
solution. So far I have not finished that.
In the meantime, I have installed the attached patch, which roughly
corresponds to the 2nd alternative in Laszlo's terms.
Regards,
Sergey
>From a7e9b6a17b2c111f4afa5ae35e3a206483366693 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff <address@hidden>
Date: Sat, 10 Oct 2009 17:29:18 +0300
Subject: [PATCH] Allow installers to specify alternative program names for
compression programs.
This adds --with-gzip, --with-bzip2 etc. switches to the configure, so that
one can do, e.g. ./configure --with-bzip2=lbzip2 and have lbzip2 executed
whenever user calls `tar --bzip2'.
* acinclude.m4: New file.
* configure.ac: Add TAR_COMPR_PROGRAM invocations for
the supported compressors.
* src/buffer.c (magic): Use *_COMPRESSOR defines instead
of hardcoded program names.
* src/suffix.c (compression_suffixes): Likewise.
---
acinclude.m4 | 26 ++++++++++++++++++++++++++
configure.ac | 7 +++++++
src/buffer.c | 12 ++++++------
src/suffix.c | 30 ++++++++++++++++--------------
4 files changed, 55 insertions(+), 20 deletions(-)
create mode 100644 acinclude.m4
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000..fff919a
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,26 @@
+dnl Special Autoconf macros for GNU Tar -*- autoconf -*-
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl
+dnl GNU tar is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3, or (at your option)
+dnl any later version.
+dnl
+dnl GNU tar is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License along
+dnl with GNU tar. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([TAR_COMPR_PROGRAM],[
+ m4_pushdef([tar_compr_define],translit($1,[a-z+-],[A-ZX_])[_PROGRAM])
+ m4_pushdef([tar_compr_var],[tar_cv_compressor_]translit($1,[+-],[x_]))
+ AC_ARG_WITH([--with-]$1,
+ AC_HELP_STRING([--with-]$1[=PROG],
+ [use PROG as ]$1[ compressor program]),
+ [tar_compr_var=${withvar}],
+ [tar_compr_var=m4_if($2,,$1,$2)])
+ AC_DEFINE_UNQUOTED(tar_compr_define, "$tar_compr_var",
+ [Define to the program name of ]$1[ compressor program])])
diff --git a/configure.ac b/configure.ac
index 1b1831a..7521d64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,6 +121,13 @@ else
[Define to the full path of your rsh, if any.])
fi
+TAR_COMPR_PROGRAM(compress)
+TAR_COMPR_PROGRAM(gzip)
+TAR_COMPR_PROGRAM(bzip2)
+TAR_COMPR_PROGRAM(lzma)
+TAR_COMPR_PROGRAM(lzop)
+TAR_COMPR_PROGRAM(xz)
+
AC_MSG_CHECKING(for default archive format)
AC_ARG_VAR([DEFAULT_ARCHIVE_FORMAT],
diff --git a/src/buffer.c b/src/buffer.c
index fa9ccc2..d7ff214 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -220,12 +220,12 @@ struct zip_magic
static struct zip_magic const magic[] = {
{ ct_tar },
{ ct_none, },
- { ct_compress, 2, "\037\235", "compress", "-Z" },
- { ct_gzip, 2, "\037\213", "gzip", "-z" },
- { ct_bzip2, 3, "BZh", "bzip2", "-j" },
- { ct_lzma, 6, "\xFFLZMA", "lzma", "--lzma" },
- { ct_lzop, 4, "\211LZO", "lzop", "--lzop" },
- { ct_xz, 6, "\0xFD7zXZ", "xz", "-J" },
+ { ct_compress, 2, "\037\235", COMPRESS_PROGRAM, "-Z" },
+ { ct_gzip, 2, "\037\213", GZIP_PROGRAM, "-z" },
+ { ct_bzip2, 3, "BZh", BZIP2_PROGRAM, "-j" },
+ { ct_lzma, 6, "\xFFLZMA", LZMA_PROGRAM, "--lzma" },
+ { ct_lzop, 4, "\211LZO", LZOP_PROGRAM, "--lzop" },
+ { ct_xz, 6, "\0xFD7zXZ", XZ_PROGRAM, "-J" },
};
#define NMAGIC (sizeof(magic)/sizeof(magic[0]))
diff --git a/src/suffix.c b/src/suffix.c
index a044d5a..cd9c01a 100644
--- a/src/suffix.c
+++ b/src/suffix.c
@@ -27,21 +27,23 @@ struct compression_suffix
};
static struct compression_suffix compression_suffixes[] = {
-#define S(s,p) #s, sizeof (#s) - 1, #p
- { S(gz, gzip) },
- { S(tgz, gzip) },
- { S(taz, gzip) },
- { S(Z, compress) },
- { S(taZ, compress) },
- { S(bz2, bzip2) },
- { S(tbz, bzip2) },
- { S(tbz2, bzip2) },
- { S(tz2, bzip2) },
- { S(lzma, lzma) },
- { S(tlz, lzma) },
- { S(lzo, lzop) },
- { S(xz, xz) },
+#define __CAT2__(a,b) a ## b
+#define S(s,p) #s, sizeof (#s) - 1, __CAT2__(p,_PROGRAM)
+ { S(gz, GZIP) },
+ { S(tgz, GZIP) },
+ { S(taz, GZIP) },
+ { S(Z, COMPRESS) },
+ { S(taZ, COMPRESS) },
+ { S(bz2, BZIP2) },
+ { S(tbz, BZIP2) },
+ { S(tbz2, BZIP2) },
+ { S(tz2, BZIP2) },
+ { S(lzma, LZMA) },
+ { S(tlz, LZMA) },
+ { S(lzo, LZOP) },
+ { S(xz, XZ) },
#undef S
+#undef __CAT2__
};
static int nsuffixes = sizeof (compression_suffixes) /
--
1.6.4.2
- [Help-tar] tar patch to selectively divert named compressors to alternatives, ERSEK Laszlo, 2009/10/08
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, Sergey Poznyakoff, 2009/10/08
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, ERSEK Laszlo, 2009/10/08
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, Sergey Poznyakoff, 2009/10/08
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, Karl Berry, 2009/10/08
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, ERSEK Laszlo, 2009/10/08
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, ERSEK Laszlo, 2009/10/09
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, Paul Wise, 2009/10/10
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, ERSEK Laszlo, 2009/10/10
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives,
Sergey Poznyakoff <=
- Re: [Help-tar] tar patch to selectively divert named compressors to alternatives, Sergey Poznyakoff, 2009/10/10