Untangling tar...

Glenn L. McGrath bug1 at iinet.net.au
Tue Dec 13 21:46:58 UTC 2005


On Mon, 29 Aug 2005 21:46:27 -0500
Rob Landley <rob at landley.net> wrote:

> So, the fix that went into 1.01 recently added bzip2 support to tar (by 
> calling bzip2 as an external executable).  But it's dependent on -z support 
> rather than -j support.
>
> I'm trying to untangle the CONFIG option tree for tar, and preferably prune 
> it, and my brain is hurting.  I started by trying to collapse together 
> TAR_GZIP and TAR_BZIP2 into TAR_ZIP, and it broke because the "create" and 
> "extract" logic are sort of independent but not really.  We shell out to 
> external commands for the create case, but in the extract case we use the 
> built-in functionality to recognize the header type, and pulling on any of 
> the dangling threads of this reveals an enormous tangle underneath.  
> Apparently, making -z and -j be the same option forces the build to suck in 
> the gzip and bunzip2 logic...
> 
> Is there anybody here who currently understands this code?  I'd really rather 
> avoid going through it with a chainsaw, but making minor changes here keeps 
> breaking seemingly unrelated things.  (In _theory_ tar -z and -j support 
> don't require built-in gzip/gunzip/bzip/bunzip because it can shell out.  In 
> practice, it's not that simple...)

Some basics about tar

The archive creation and archive extraction have completly different
backends, they do share some code at the front related to argument
parsing.

In the config section for tar some options may only work in extraction
and not creation.

The archive creation code dates back to when Bruce Perens was hacking
on busybox.

I worked on most of the archive extaction code and placed any
common extraction code in libunarchive, so if you touch stuff in
libunarchive expect it to effect multiple applets. The whole point of
libunarchive is to share the same code that is needed to extract
different formats.

It was my intention that when i got the extraction code to a state that
i was happy with to go back and apply the same principles to archive
creation. That hasnt happened.

It should be possible to add tar.bz2 creation without touching anything
in libunarchive, perhaps a seperate config option should be made for
bz2 creation to seperate it from libunarchiving code.

I will have a bit of a look and see what i can work out.


Glenn



More information about the busybox mailing list