为什么我无法解压缩.tar.bz2或.tar.xz文件?

随心所欲

尝试从OpenBSD上的源进行构建时,我在解压缩文件时遇到问题。首先,我认为它只是损坏的文件,但是在许多不同的程序以及从不同的下载方法(curl -O,FTP,在Windows上下载并通过WinSCP赋予),甚至不同的同一个程序的文件(.xz.bz2.lz)我开始相信我必须做一些错误的。使用时出现的错误

tar xzvf file

gzip: stdin: unrecognized file format
tar: End of archive volume 1 reached
tar: Sorry, unable to determine archive format.

不同的程序,不同的下载方法甚至不同的文件都在发生这种情况,这让我发疯。

我现在无法解压缩的文件示例:gnutls-3.4.3.tar.xz并已gmp-6.0.0a.tar.bz2通过Windows下载并通过WinSCP二进制模式传输。

ls -L 输出:

-rw-r--r--   1 root  wheel  6546268 Jul 12 09:18 gnutls-3.4.3.tar.xz
-rw-r--r--   1 root  wheel  2319400 Jul 24  2015 gmp-6.0.0a.tar.bz2

od -x 输出:

od -x gnutls-3.4.3.tar.xz | head -10
0000000     37fd    587a    005a    0400    d6e6    46b4    0002    0121
0000020     0016    0000    2f74    a3e5    00e8    f06d    5d02    3300
0000040     8b9b    1912    a356    72d2    a129    5502    49fb    f64d
0000060     c492    64da    be73    7fde    4d79    9170    c055    27b9
0000100     8fc9    6caa    3f02    b551    e014    fd24    a2ad    c57d
0000120     ce49    59f3    da73    0ee9    0319    b7ea    c55c    5e2e
0000140     8fd8    7af6    4f97    b1a8    1ac9    d553    a703    1f1d
0000160     b226    682e    3e00    d2bc    a0f8    4b57    13d0    f887
0000200     7f84    c83f    94cd    154b    1dfe    37cd    25db    13d9
0000220     cdcd    5861    6558    acc3    0103    21ed    e8d9    979d

我的tar似乎甚至都不认为J是一种选择:

tar xJvf gmp-5.1.3.tar.xz
tar: unknown option J

从第二个命令输出错误:

tar xjvf gmp-6.0.0a.tar.bz2
tar: could not exec bzip2: No such file or directory
tar: End of archive volume 1 reached
tar: Sorry, unable to determine archive format.

更有用的错误输出:

tar xvf gnutls-3.4.3.tar.xz
tar: Cannot identify format. Searching...
tar: Cpio file name length 36039 is out of range
tar: Invalid header, starting valid header search.
tar: Cpio file name length 63118 is out of range
tar: Cpio file name length 38744 is out of range
<suppressed similar errors>
tar: Cpio file name in header is corrupted
tar: Cpio file name length 46161 is out of range
tar: Cpio file name length 32085 is out of range
<suppressed similar errors>
tar: Cpio file name in header is corrupted
<more suppressed similar errors>
tar: End of archive volume 1 reached
斯蒂芬·基特

z选项告诉tar您使用gunzip(或其内部等效文件)解压缩档案,并且仅适用于gzip压缩的档案,通常带有.tar.gz扩展名。

要使用其他压缩格式解压缩档案,您可以尝试

tar xvf file

看看您tar是否足够聪明以自行解决问题。如果不是,则可以告诉它要使用哪种解压缩工具,也可以解压缩并通过管道传递存档:

  • 用于.tar.bz2tar xjvf filebunzip2 -c file | tar xvf -
  • 用于.tar.xztar xJvf filexzcat file | tar xvf -
  • 用于.tar.lztar xjf file --lziplunzip -c file | tar xvf -

使用您正在使用的文件:

tar xJvf gnutls-3.4.3.tar.xz
tar xjvf gmp-6.0.0a.tar.bz2

或显然使用OpenBSD tar

xzcat gnutls-3.4.3.tar.xz | tar xvf -
bunzip2 -c gmp-6.0.0a.tar.bz2 | tar xvf -

你需要确保你有xzbunzip2安装; bunzip2可能与打包在一起bzip2

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章