This can seem like some strange and absurd thing, but bsdtar on Linux is quite an interesting topic.
As many of you know, I’m one of the Gentoo/FreeBSD developers; one of the things we want to be sure that is not changed when we use Gentoo/FreeBSD respect normal FreeBSD is the userland, not only the libc but also the utils. That’s why we avoid replacing BSD utils and BSD libraries with version not used by default FreeBSD installations.
For this, we usually prefix ‘g’ to the comamnd names when they collides with BSD’s commands, so we have gsed gmake gtar gm4 and so on.
But another interesting thing to do is using BSD userland on Linux, and this is quite always possible without problems. The bsdtar package is one of the best examples of that.
bsdtar handles few file formats which aren’t managed by GNU tar, like zip files or cpio files, and handles them directly without spawn bzip2/gzip process and then another tar.
This makes a slight improvement in the time needed to extract things:
flame@enterprise ~/test $ time tar xf /var/portage/distfiles/kdelibs-3.4.1.tar.bz2 real 0m17.072s user 0m5.763s sys 0m1.190s [ in the mean time the directory was removed ] flame@enterprise ~/test $ time bsdtar xf /var/portage/distfiles/kdelibs-3.4.1.tar.bz2 real 0m14.421s user 0m5.581s sys 0m1.288s
and also the size is in favour of bsdtar:
flame@enterprise ~ $ ls -l `which tar` `which bsdtar` -rwxr-xr-x 1 root root 266568 mar 18 19:34 /bin/tar -rwxr-xr-x 1 root root 171392 giu 16 00:39 /usr/bin/bsdtar
(note: dates are expressed in italian also if I have LANG=“en_US”, don’t ask me why).
bsdtar and GNU tar shares the same basic syntax, also if they aren’t compatible for strange extensive syntax which is not POSIX anyway.
If you want to try it, it’s in portage as app-arch/bsdtar, it doesn’t overwrite your tar as it’s installed as bsdtar (and then linked to tar if $USERLAND == “BSD”) so it’s safe. I’m wondering if there’s a way to provide a selection of tar tools to use, as portage uses a quite portable syntax which doesn’t seem to have problems with bsdtar anyway.
I hope someone will find that useful.. I for one I’ve set alias tar=bsdtar in my bashrc file.
P.S.: obviously linking tar to bsdtar isn’t supported and nobody will ever support you if you do that, so please really avoid that, thanks.