Browse Source

* configure.ac, NEWS: Version 1.20.90
* doc/tar.texi: Document -J, --no-auto-compress, etc.
* src/buffer.c (ct_tar): New constant.
(magic): Add lzop support. Proposed by Kevin Day
<[email protected]>.
(check_compressed_archive): Do not use autodetect if the
compression program was specified explicitly.
Fall back to analyzing archive name, if the autodetection fails.
* src/suffix.c: Add .lzo
* src/tar.c: New options --lzop and --no-auto-compress.
New short option -J (alias for --lzma).

Sergey Poznyakoff 16 years ago
parent
commit
c9a7297a8a
7 changed files with 138 additions and 33 deletions
  1. 14 1
      ChangeLog
  2. 25 1
      NEWS
  3. 2 2
      configure.ac
  4. 39 5
      doc/tar.texi
  5. 43 17
      src/buffer.c
  6. 1 0
      src/suffix.c
  7. 14 7
      src/tar.c

+ 14 - 1
ChangeLog

@@ -1,5 +1,17 @@
 2008-06-26  Sergey Poznyakoff  <[email protected]>
 
+	* configure.ac, NEWS: Version 1.20.90
+	* doc/tar.texi: Document -J, --no-auto-compress, etc.
+	* src/buffer.c (ct_tar): New constant.
+	(magic): Add lzop support.  Proposed by Kevin Day
+	<[email protected]>.
+	(check_compressed_archive): Do not use autodetect if the
+	compression program was specified explicitly.
+	Fall back to analyzing archive name, if the autodetection fails.
+	* src/suffix.c: Add .lzo
+	* src/tar.c: New options --lzop and --no-auto-compress.
+	New short option -J (alias for --lzma).
+
 	* src/buffer.c (try_new_volume): Print more information with error
 	diagnostics.
 	(_gnu_flush_write): Improve error checking.  Adjust
@@ -22,7 +34,8 @@
 	
 2008-06-14  Dan Drake <[email protected]> (tiny change)
 
-	* src/tar.c (exclude_vcs_files): Support for Bazaar, Mercurial and Darcs.
+	* src/tar.c (exclude_vcs_files): Support for Bazaar, Mercurial and
+	Darcs. 
 
 2008-05-06  Sergey Poznyakoff  <[email protected]>
 

+ 25 - 1
NEWS

@@ -1,7 +1,31 @@
-GNU tar NEWS - User visible changes. 2008-04-14
+GNU tar NEWS - User visible changes. 2008-06-26
 Please send GNU tar bug reports to <[email protected]>
 
 
+version 1.20.90 (CVS)
+
+* New short option -J
+
+A shortcut for --lzma.
+
+* New option --lzop
+
+* New option --no-auto-compress
+
+Cancels the effect of previous --auto-compress (-a) option.
+
+* Compressed format recognition
+
+If tar is unable to determine archive compression format, it falls
+back to using archive suffix to determine it.
+
+* VCS support.
+
+Using --exclude-vcs handles also files used internally by Bazaar,
+Mercurial and Darcs.
+
+
+
 version 1.20 - Sergey Poznyakoff, 2008-04-14
 
 * New option --auto-compress (-a)

+ 2 - 2
configure.ac

@@ -1,4 +1,4 @@
-# Configure template for GNU tar.
+# Configure template for GNU tar.  -*- autoconf -*-
 
 # Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301, USA.
 
-AC_INIT([GNU tar], [1.20], [[email protected]])
+AC_INIT([GNU tar], [1.20.90], [[email protected]])
 AC_CONFIG_SRCDIR([src/tar.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([config.h:config.hin])

+ 39 - 5
doc/tar.texi

@@ -2407,7 +2407,8 @@ superuser privileges and can be a pain to manage.
 @itemx -a
 
 During a @option{--create} operation, enables automatic compressed
-format recognition based on the archive suffix. @xref{gzip}.
+format recognition based on the archive suffix.  The effect of this
+option is cancelled by @option{--no-auto-compress}.  @xref{gzip}.
 
 @opsummary{backup}
 @item --backup=@var{backup-type}
@@ -2785,10 +2786,16 @@ incremental format.  @xref{Incremental Dumps}.
 
 @opsummary{lzma}
 @item --lzma
+@itemx -J
 
 This option tells @command{tar} to read or write archives through
 @command{lzma}.  @xref{gzip}.
 
+@item --lzop
+
+This option tells @command{tar} to read or write archives through
+@command{lzop}.  @xref{gzip}.
+
 @opsummary{mode}
 @item --mode=@var{permissions}
 
@@ -2843,6 +2850,12 @@ changed).  @xref{after}.
 An exclude pattern can match any subsequence of the name's components.
 @xref{controlling pattern-matching}.
 
+@opsummary{no-auto-compress}
+@item --no-auto-compress
+
+Disables automatic compressed format recognition based on the archive
+suffix.  @xref{--auto-compress}.  @xref{gzip}.
+
 @opsummary{no-check-device}
 @item --no-check-device
 Do not check device numbers when creating a list of modified files
@@ -3358,6 +3371,8 @@ them with the equivalent long option.
 
 @item -G @tab @ref{--incremental}.
 
+@item -J @tab @ref{--lzma}.
+
 @item -K @tab @ref{--starting-file}.
 
 @item -L @tab @ref{--tape-length}.
@@ -3411,7 +3426,7 @@ them with the equivalent long option.
 @item -o @tab When creating, @ref{--no-same-owner}, when extracting ---
 @ref{--portability}.
 
-The later usage is deprecated.  It is retained for compatibility with
+The latter usage is deprecated.  It is retained for compatibility with
 the earlier versions of @GNUTAR{}.  In future releases
 @option{-o} will be equivalent to @option{--no-same-owner} only.
 
@@ -8257,8 +8272,13 @@ switch to @samp{posix}.
 @cindex Compressed archives
 @cindex Storing archives in compressed format
 
+@cindex gzip
+@cindex bzip2
+@cindex lzma
+@cindex lzop
+@cindex compress
 @GNUTAR{} is able to create and read compressed archives.  It supports
-@command{gzip}, @command{bzip2} and @command{lzma} compression
+@command{gzip}, @command{bzip2}, @command{lzma} and @command{lzop} compression
 programs.  For backward compatibility, it also supports
 @command{compress} command, although we strongly recommend against
 using it, because it is by far less effective than other compression
@@ -8269,7 +8289,8 @@ Creating a compressed archive is simple: you just specify a
 commands.  The compression option is @option{-z} (@option{--gzip}) to
 create a @command{gzip} compressed archive, @option{-j}
 (@option{--bzip2}) to create a @command{bzip2} compressed archive,
-@option{--lzma} to create an @asis{LZMA} compressed archive and
+@option{-J} (@option{--lzma}) to create an @asis{LZMA} compressed
+archive, @option{--lzop} to create an @asis{LSOP} archive, and
 @option{-Z} (@option{--compress}) to use @command{compress} program.
 For example:
 
@@ -8309,6 +8330,12 @@ $ @kbd{tar tf archive.tar.gz}
 $ @kbd{tar xf archive.tar.gz}
 @end smallexample
 
+The format recognition algorithm is based on @dfn{signatures}, a
+special byte sequences in the beginning of file, that are specific for
+certain compression formats.  If this approach fails, @command{tar}
+falls back to using archive name suffix to determine its format
+(@xref{auto-compress}, for a list of recognized suffixes).
+
 The only case when you have to specify a decompression option while
 reading the archive is when reading from a pipe or from a tape drive
 that does not support random access.  However, in this case @GNUTAR{}
@@ -8344,7 +8371,7 @@ The following table summarizes compression options used by @GNUTAR{}.
 @item --auto-compress
 @itemx -a
 Select a compression program to use by the archive file name
-suffix. The following suffixes are recognized:
+suffix.  The following suffixes are recognized:
 
 @multitable @columnfractions 0.3 0.6
 @headitem Suffix @tab Compression program
@@ -8359,6 +8386,7 @@ suffix. The following suffixes are recognized:
 @item @samp{.tbz} @tab @command{bzip2}
 @item @samp{.lzma} @tab @command{lzma}
 @item @samp{.tlz} @tab @command{lzma}
+@item @samp{.lzo} @tab @command{lzop}
 @end multitable
 
 @opindex gzip
@@ -8409,8 +8437,14 @@ Filter the archive through @code{bzip2}.  Otherwise like @option{--gzip}.
 
 @opindex lzma
 @item --lzma
+@itemx -J
 Filter the archive through @command{lzma}.  Otherwise like @option{--gzip}.
 
+@opindex lzop
+@item --lzop
+Filter the archive through @command{lzop}.  Otherwise like
+@option{--gzip}.
+
 @opindex compress
 @opindex uncompress
 @item -Z

+ 43 - 17
src/buffer.c

@@ -198,11 +198,13 @@ compute_duration ()
 /* Compression detection */
 
 enum compress_type {
-  ct_none,
+  ct_tar,              /* Plain tar file */
+  ct_none,             /* Unknown compression type */
   ct_compress,
   ct_gzip,
   ct_bzip2,
-  ct_lzma
+  ct_lzma,
+  ct_lzop
 };
 
 struct zip_magic
@@ -215,11 +217,13 @@ 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" }, /* FIXME: ???? */
+  { ct_lzma,     6, "\xFFLZMA", "lzma", "-J" }, /* FIXME: ???? */
+  { ct_lzop,     4, "\211LZO",  "lzop", "--lzop" },
 };
 
 #define NMAGIC (sizeof(magic)/sizeof(magic[0]))
@@ -250,9 +254,9 @@ check_compressed_archive (bool *pshort)
 
   if (tar_checksum (record_start, true) == HEADER_SUCCESS)
     /* Probably a valid header */
-    return ct_none;
+    return ct_tar;
 
-  for (p = magic + 1; p < magic + NMAGIC; p++)
+  for (p = magic + 2; p < magic + NMAGIC; p++)
     if (memcmp (record_start->buffer, p->magic, p->length) == 0)
       return p->type;
 
@@ -272,14 +276,30 @@ open_compressed_archive ()
 
   if (!multi_volume_option)
     {
-      bool shortfile;
-      enum compress_type type = check_compressed_archive (&shortfile);
-
-      if (type == ct_none)
+      if (!use_compress_program_option)
 	{
-	  if (shortfile)
-	    ERROR ((0, 0, _("This does not look like a tar archive")));
-	  return archive;
+	  bool shortfile;
+	  enum compress_type type = check_compressed_archive (&shortfile);
+
+	  switch (type)
+	    {
+	    case ct_tar:
+	      if (shortfile)
+		ERROR ((0, 0, _("This does not look like a tar archive")));
+	      return archive;
+      
+	    case ct_none:
+	      if (shortfile)
+		ERROR ((0, 0, _("This does not look like a tar archive")));
+	      set_comression_program_by_suffix (archive_name_array[0], NULL);
+	      if (!use_compress_program_option)
+		return archive;
+	      break;
+
+	    default:
+	      use_compress_program_option = compress_program (type);
+	      break;
+	    }
 	}
       
       /* FD is not needed any more */
@@ -289,7 +309,6 @@ open_compressed_archive ()
 			  check_compressed_archive */
 
       /* Open compressed archive */
-      use_compress_program_option = compress_program (type);
       child_pid = sys_child_open_for_uncompress ();
       read_full_records = true;
     }
@@ -512,7 +531,7 @@ _open_archive (enum access_mode wanted_access)
 	    archive = STDIN_FILENO;
 
 	    type = check_compressed_archive (&shortfile);
-	    if (type != ct_none)
+	    if (type != ct_tar && type != ct_none)
 	      FATAL_ERROR ((0, 0,
 			    _("Archive is compressed. Use %s option"),
 			    compress_option (type)));
@@ -561,9 +580,16 @@ _open_archive (enum access_mode wanted_access)
 			   O_RDWR | O_CREAT | O_BINARY,
 			   MODE_RW, rsh_command_option);
 
-	if (check_compressed_archive (NULL) != ct_none)
-	  FATAL_ERROR ((0, 0,
-			_("Cannot update compressed archives")));
+	switch (check_compressed_archive (NULL))
+	  {
+	  case ct_none:
+	  case ct_tar:
+	    break;
+
+	  default:
+	    FATAL_ERROR ((0, 0,
+			  _("Cannot update compressed archives")));
+	  }
 	break;
       }
 

+ 1 - 0
src/suffix.c

@@ -39,6 +39,7 @@ struct compression_suffix compression_suffixes[] = {
   { S(tz2, bzip2) },
   { S(lzma, lzma) },
   { S(tlz, lzma) },
+  { S(lzo, lzop) },
 #undef S
 };
 

+ 14 - 7
src/tar.c

@@ -271,11 +271,11 @@ enum
   IGNORE_FAILED_READ_OPTION,
   INDEX_FILE_OPTION,
   KEEP_NEWER_FILES_OPTION,
-  LZMA_OPTION,
   MODE_OPTION,
   MTIME_OPTION,
   NEWER_MTIME_OPTION,
   NO_ANCHORED_OPTION,
+  NO_AUTO_COMPRESS_OPTION,
   NO_CHECK_DEVICE_OPTION,
   NO_DELAY_DIRECTORY_RESTORE_OPTION,
   NO_IGNORE_CASE_OPTION,
@@ -350,7 +350,7 @@ The version control may be set with --backup or VERSION_CONTROL, values are:\n\n
 
 /* NOTE:
 
-   Available option letters are DEIJQY and eqy. Consider the following
+   Available option letters are DEIQY and eqy. Consider the following
    assignments:
 
    [For Solaris tar compatibility =/= Is it important at all?]
@@ -592,6 +592,9 @@ static struct argp_option options[] = {
    N_("Compression options:"), GRID },
   {"auto-compress", 'a', 0, 0,
    N_("use archive suffix to determine the compression program"), GRID+1 },
+  {"no-auto-compress", NO_AUTO_COMPRESS_OPTION, 0, 0,
+   N_("do not use use archive suffix to determine the compression program"),
+   GRID+1 },
   {"bzip2", 'j', 0, 0,
    N_("filter the archive through bzip2"), GRID+1 },
   {"gzip", 'z', 0, 0,
@@ -601,7 +604,7 @@ static struct argp_option options[] = {
   {"compress", 'Z', 0, 0,
    N_("filter the archive through compress"), GRID+1 },
   {"uncompress", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
-  {"lzma", LZMA_OPTION, 0, 0,
+  {"lzma", 'J', 0, 0,
    N_("filter the archive through lzma"), GRID+1 },
   {"use-compress-program", USE_COMPRESS_PROGRAM_OPTION, N_("PROG"), 0,
    N_("filter through PROG (must accept -d)"), GRID+1 },
@@ -1262,6 +1265,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
     case 'a':
       args->compress_autodetect = true;
       break;
+
+    case NO_AUTO_COMPRESS_OPTION:
+      args->compress_autodetect = false;
+      break;
       
     case 'b':
       {
@@ -1355,6 +1362,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
       set_use_compress_program_option ("bzip2");
       break;
 
+    case 'J':
+      set_use_compress_program_option ("lzma");
+      break;
+      
     case 'k':
       /* Don't replace existing files.  */
       old_files_option = KEEP_OLD_FILES;
@@ -1386,10 +1397,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
       }
       break;
 
-    case LZMA_OPTION:
-      set_use_compress_program_option ("lzma");
-      break;
-      
     case 'm':
       touch_option = true;
       break;