Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid compressed data--format violated?

Tags:

linux

bash

tar

I want to extract data from xxx.tar.gz file by using tar -zxvf command, but something wrong occurs to me, here's the detail:

suse11-configserver:/home/webapp/wiki # tar -zxvf dokuwiki.20151010.tar.gz

./dokuwiki/

./dokuwiki/._.htaccess.dist

./dokuwiki/.htaccess.dist

./dokuwiki/bin/

./dokuwiki/conf/

./dokuwiki/._COPYING

./dokuwiki/COPYING

tar: Jump to the next head

gzip: stdin: invalid compressed data--format violated

tar: Child returned status 1

tar: Error is not recoverable: exiting now

But this command tar -zxvf dokuwiki.20151010.tar.gz goes well in the MacOS x System, I can not figure out the reason.

like image 650
Tangoo Avatar asked Oct 10 '15 09:10

Tangoo


3 Answers

Your command is correct. But it seems the file is corrupted. It's easy to tell, when some files are correctly extracted (for example ./dokuwiki/.htaccess.dist), but not the rest.

Recreate the dokuwiki.20151010.tar.gz file, and make sure it doesn't report errors while doing so. If you downloaded the file from somewhere, verify the checksum, or at least the file size.

The bottomline is, either the file was incorrectly created or downloaded. The command you have should work fine with a .tar.gz file.

like image 168
janos Avatar answered Nov 14 '22 15:11

janos


Alternative Location of Gzip's fixgz Utility

In case you can no longer find fixgz on gzip.org's website, here is a link to a version available on archive.org: https://web.archive.org/web/20180624175352/http://www.gzip.org/fixgz.zip.

Source Code for fixgz Utility

Also, in case that disappears as well, below is the source code for the fixgz utility:

/* fixgz attempts to fix a binary file transferred in ascii mode by
 * removing each extra CR when it followed by LF.
 * usage: fixgz  bad.gz fixed.gz

 * Copyright 1998 Jean-loup Gailly <[email protected]>
 *   This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the author be held liable for any damages
 * arising from the use of this software.

 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely.
 */

#include <stdio.h>

int main(argc, argv)
     int argc;
     char **argv;
{
    int c1, c2; /* input bytes */
    FILE *in;   /* corrupted input file */
    FILE *out;  /* fixed output file */

    if (argc <= 2) {
    fprintf(stderr, "usage: fixgz bad.gz fixed.gz\n");
    exit(1);
    }
    in  = fopen(argv[1], "rb");
    if (in == NULL) {
    fprintf(stderr, "fixgz: cannot open %s\n", argv[1]);
    exit(1);
    }
    out = fopen(argv[2], "wb");
    if (in == NULL) {
    fprintf(stderr, "fixgz: cannot create %s\n", argv[2]);
    exit(1);
    }

    c1 = fgetc(in);

    while ((c2 = fgetc(in)) != EOF) {
    if (c1 != '\r' || c2 != '\n') {
        fputc(c1, out);
    }
    c1 = c2;
    }
    if (c1 != EOF) {
    fputc(c1, out);
    }
    exit(0);
    return 0; /* avoid warning */
}

like image 34
Jonathan B. Avatar answered Nov 14 '22 14:11

Jonathan B.


Gzip has a prospective fix for this error in their FAQ. The provided utility didn't help in my case, but it's possible it would fix your archive. According to gzip:

If you have transferred a file in ASCII mode and you no longer have access to the original, you can try the program fixgz to remove the extra CR (carriage return) bytes inserted by the transfer. A Windows 9x/NT/2000/ME/XP binary is here. But there is absolutely no guarantee that this will actually fix your file. Conclusion: never transfer binary files in ASCII mode.

like image 1
tdehr Avatar answered Nov 14 '22 14:11

tdehr