LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-20-2020, 11:32 AM   #1
phalange
Member
 
Registered: May 2018
Distribution: Slackware, FreeBSD, Nixos, Arch
Posts: 261

Rep: Reputation: 125Reputation: 125
tar making a fuss


So I've been playing with a lot of RPI images lately and some come compressed as *xz and *bz2 files.

tar -xf has been more often than not kicking up this error:

Code:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
Using Ark 2.19 that comes with Slackware gives no trouble. I just extract the img file as expected.

On -Current with tar 1.32
 
Old 05-20-2020, 11:59 AM   #2
karlmag
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 38

Rep: Reputation: Disabled
Quote:
Originally Posted by phalange View Post
So I've been playing with a lot of RPI images lately and some come compressed as *xz and *bz2 files.

tar -xf has been more often than not kicking up this error:

Code:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
Using Ark 2.19 that comes with Slackware gives no trouble. I just extract the img file as expected.

On -Current with tar 1.32


From tars manpage;
Code:
       -j, --bzip2
              Filter the archive through bzip2(1).

       -J, --xz
              Filter the archive through xz(1).

Also; what does the 'file' command say about the files?


--
KarlMag
 
Old 05-20-2020, 12:19 PM   #3
phalange
Member
 
Registered: May 2018
Distribution: Slackware, FreeBSD, Nixos, Arch
Posts: 261

Original Poster
Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by karlmag View Post
From tars manpage;
Code:
-j, -J
same result

Quote:
Originally Posted by karlmag View Post
Also; what does the 'file' command say about the files?
*.img.bz2: bzip2 compressed data, block size = 900k
 
Old 05-20-2020, 12:24 PM   #4
shruggy
Member
 
Registered: Mar 2020
Posts: 667

Rep: Reputation: Disabled
Quote:
Originally Posted by phalange View Post
*.img.bz2: bzip2 compressed data, block size = 900k
This ^.
Quote:
Ark manages various archive formats, including tar, gzip, bzip2, rar and zip,
as well as CD-ROM images.
 
1 members found this post helpful.
Old 05-20-2020, 12:30 PM   #5
phalange
Member
 
Registered: May 2018
Distribution: Slackware, FreeBSD, Nixos, Arch
Posts: 261

Original Poster
Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by shruggy View Post
This ^.
So is the issue that I've been looking at tar.bz2 files for so many years that I mistakenly assumed these are tar archives when they are not, and thus fall outside the functionality of the tar program? Seems like this may be the case.
 
Old 05-20-2020, 12:31 PM   #6
shruggy
Member
 
Registered: Mar 2020
Posts: 667

Rep: Reputation: Disabled
I believe those images were created with dd. They a just byte-for-byte copies of SD card contents. Ark uses libarchive internally, and libarchive can handle "raw" archive format whatever that means. Edit. Raw just means compressed data without any archive structure.

This also means that bsdtar, which also uses libarchive, may be able to handle those archives as well.

Last edited by shruggy; 05-20-2020 at 12:56 PM.
 
Old 05-20-2020, 12:40 PM   #7
phalange
Member
 
Registered: May 2018
Distribution: Slackware, FreeBSD, Nixos, Arch
Posts: 261

Original Poster
Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by shruggy View Post
I believe the images are just created with dd.
Ok cool. I just tried bunzip2 *.bz2 and it did the trick. I've not used bunzip2 maybe ever.
 
Old 05-20-2020, 12:58 PM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,395

Rep: Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639Reputation: 4639
In general tar should automatically detect bzip2 format and also you can use -j to [un]compress.
So it was not the usual case.
Anyway, if your problem solved please mark the thread solved.
 
Old 05-20-2020, 01:01 PM   #9
phalange
Member
 
Registered: May 2018
Distribution: Slackware, FreeBSD, Nixos, Arch
Posts: 261

Original Poster
Rep: Reputation: 125Reputation: 125
Thanks folks, looks like I asked tar to do something it's not meant to do. bunzip2 program solved the problem.
 
Old 05-20-2020, 01:35 PM   #10
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 467

Rep: Reputation: 185Reputation: 185
Quote:
Originally Posted by karlmag View Post
From tars manpage;
Code:
       -j, --bzip2
              Filter the archive through bzip2(1).

       -J, --xz
              Filter the archive through xz(1).
GNU tar recognizes archive types automatically since 2004 https://www.gnu.org/software/tar/:
Quote:
Compressed archives are recognised automatically, it is no longer necessary to specify -Z, -z, or -j options to read them. Thus, you can now run tar tf archive.tar.gz and expect it to work!
 
Old 05-20-2020, 02:40 PM   #11
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 6,962

Rep: Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643
Quote:
Originally Posted by average_user View Post
GNU tar recognizes archive types automatically since 2004 https://www.gnu.org/software/tar/:
This doesn't always work, but usually does. If you are piping into tar, you need to manually specify the archive type and it seems that OP found another exception to the rule.
 
1 members found this post helpful.
Old 05-20-2020, 03:04 PM   #12
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 467

Rep: Reputation: 185Reputation: 185
You don't pass a file name when you read contents of an archive from standard input so it obviously doesn't work.

And OP has not found "exception to the rule" but uses tar on non-tar files so in other words they don't know what they're doing.

Anyway, there is no need to remember what programs you should use to extract a given archive file and with what parameters, just create `ext' function that looks like that:

Code:
$ type ext
ext is a function
ext ()
{
    if [ -f "$1" ]; then
        case "$1" in
            *.tar.bz2)
                tar xvjf "$1"
            ;;
            *.tar.gz)
                tar xvzf "$1"
            ;;
            *.tar.xz)
                tar Jxvf $1
            ;;
            *.bz2)
                bunzip2 "$1"
            ;;
            *.rar)
                unrar x "$1"
            ;;
            *.gz)
                gunzip "$1"
            ;;
            *.tar)
                tar xvf "$1"
            ;;
            *.tbz2)
                tar xvjf "$1"
            ;;
            *.tgz)
                tar xvzf "$1"
            ;;
            *.zip)
                unzip "$1"
            ;;
            *.Z)
                uncompress "$1"
            ;;
            *.7z)
                7z x "$1"
            ;;
            *.txz)
                tar Jxvf "$1"
            ;;
            *)
                echo "'$1' cannot be extracted";
                return 1
            ;;
        esac;
    else
        echo "'$1' is not a valid file";
        return 1;
    fi;
    return 0
}

Last edited by average_user; 05-20-2020 at 03:11 PM.
 
2 members found this post helpful.
Old 05-20-2020, 03:27 PM   #13
phalange
Member
 
Registered: May 2018
Distribution: Slackware, FreeBSD, Nixos, Arch
Posts: 261

Original Poster
Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by average_user View Post
And OP has not found "exception to the rule" but uses tar on non-tar files so in other words they don't know what they're doing.
Thanks for the suggestion. This thread in not an invitation for a personal attack.
 
Old 05-20-2020, 03:44 PM   #14
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 467

Rep: Reputation: 185Reputation: 185
Stating facts is hardly a personal attack, you cannot be so fragile. You use the wrong tool for the job.
 
2 members found this post helpful.
Old 05-20-2020, 04:16 PM   #15
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 6,962

Rep: Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643Reputation: 4643
Quote:
Originally Posted by average_user View Post
Stating facts is hardly a personal attack, you cannot be so fragile. You use the wrong tool for the job.
And that sure is a nice way of letting OP know that "I'm better than you and you should know it".

You could've simply stated that the files were not created by tar and so tar doesn't know what to do unless you specify it, but instead you have to be a jerk about it and slam OP instead of using it as a simple teaching moment.

There once was a time when you didn't know what you were doing with tar, other aspects of computers, or life in general. You have to start somewhere. Even if someone has a ton of experience, sometimes brainfarts happen or it's just something they haven't run into. That's no reason to be rude.

I'm not saying this as someone who was offended or speculating whether or not OP was offended, but in a forum where we like to spread knowledge about Slackware and Linux, you can use some tact when presenting information that is contrary to what they originally thought.
 
3 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
LXer: No, Google is not making the Android SDK proprietary. What’s the fuss about? LXer Syndicated Linux News 0 01-04-2013 09:12 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
XFree86 distributed under a new license; distro's making a fuss: why?? qanopus General 24 03-11-2004 02:24 PM
How do I un tar a .tar, .tar.z, .tar.gz file vofkid Linux - Newbie 4 03-15-2002 02:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration