I'm having a problem unpacking files when I try to build from source on my OpenBSD First I thought it was just corrupted files but after it happened to many different programs and from different methods of download (curl -O
, FTP, download on Windows and transfer via WinSCP) and even different files of the same program (.xz
, .bz2
, .lz
) I came to believe I must be doing something wrong. The error I get when using
tar xzvf file
is
gzip: stdin: unrecognized file format
tar: End of archive volume 1 reached
tar: Sorry, unable to determine archive format.
It's happening with different programs, with different download methods and even different files, and this is making me crazy.
Examples of files I can't unpack right now : gnutls-3.4.3.tar.xz
and gmp-6.0.0a.tar.bz2
downloaded via Windows and transferred via WinSCP binary mode.
ls -L
output:
-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
output:
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
My tar seems to not even recognize J
as an option:
tar xJvf gmp-5.1.3.tar.xz
tar: unknown option J
And error output from the second command :
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.
More useful error output :
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
Best Answer
The
z
option tellstar
to decompress an archive usinggunzip
(or its internal equivalent), and is appropriate only forgzip
-compressed archives, typically with a.tar.gz
extension.To decompress archives using other compression formats, you can try
to see if your
tar
is clever enough to figure things out on its own. If it isn't, you can either tell it what decompression tool to use, or decompress and pipe the archive:.tar.bz2
:tar xjvf file
orbunzip2 -c file | tar xvf -
.tar.xz
:tar xJvf file
orxzcat file | tar xvf -
.tar.lz
:tar xjf file --lzip
orlunzip -c file | tar xvf -
With the files you're using:
or apparently with OpenBSD
tar
:You need to make sure you have
xz
andbunzip2
installed;bunzip2
may be packaged withbzip2
.