7

I am attempting to extract a tarball (*.tgz, to be exact) and receiving terminal errors on extracted symlinks. Unfortunately, I cannot simply recreate the archive as this is a legacy archive for a system that no longer exists which was created before I was even out of high school (have to love working for a big company).

I have consulted the almighty Google; however all I can seem to find is information for excluding / following symlinks at creation time. The exact error I am receiving is something of a misnomer (error: read-only filesystem) and comes from the fact that a very large portion of the data payload is contained within numerous squash / cram / loop filesystems. The symlinks are referencing data within them which, obviously, cannot be mounted due to errors while extracting said tarball. Chicken; meet egg.

So, in short:

How can I extract a *.tgz archive to completion while either ignoring symlinks or ignoring resultant symlink errors?

For reference:

$ tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
$ uname -a
Linux localhost.localdomain 3.7.9-205.fc18.x86_64 #1 SMP Sun Feb 24 20:10:02 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
1
  • 1
    I don't understand the problem. Please post a transcript of untarring, and the output of tar -xvf. Are these symlinks to directories? May 20, 2013 at 21:21

2 Answers 2

7

-h (or --dereference) to dereference will only work upon creation.

Reference: http://www.gnu.org/software/tar/manual/tar.html#SEC138

According to a similar answer here: How do I dereference links when extracting from a tar file? you can mount the archive then copy from it, though I have not tested this myself.

2
  • Handy little tidbit to know, thanks! For those who may come looking later: AVFS does work, however it is not immediately available for Fedora 18 x64. It can, however be download without issue and locally installed via yum (use yum; it will grab the FUSE dependency for you). Once I was 'in' the *.tgz archive, the copy went off without a hitch. May 20, 2013 at 22:21
  • Just putting in a thought from the linked question, the avfs mounting method does not cover use cases where this needs to be done inside of a containerized build system. Fuse is not available and would require a privileged container. So a method to do this without fuse is needed. Mar 30, 2023 at 18:38
0

What you like can easily be done. Call:

star -x f=archive.tgz -find ! -type l

Recent star sources are in the schilytools package. star is the oldest free tar implementation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .