Why is this archive failing to create symlinks?

Solution 1:

Pylsa's comment said it all. I didn't consider the fact that I'm working on a VMware shared folder from a Windows machine with NTFS partitions. Extracting the archive anywhere on the virtual machine works fine.

Solution 2:

I'm coming a bit late to this party, but had the same problem yesterday. If the filesystem does not support symlinks and you despite want all the contents from the archive to be accessible, it might be a workaround to copy those files (which should be symlinked).

The archive I wanted to extract had 20+ symlinks, so I decided to generate the cpcommands by a script. I just need to provide the stderr output of tar (via a file by tar ... 2> /tmp/tar-stderr.txt) and the target folder. I decided to not yet execute the cp commands, but pipe them to a file which I can check before I chmod +x and execute it. Feel free to improve the script, pipe tar directly to it (e.g. by exchanging stdout/stderr), use somehow tee to provide the ignored messages of tar...

#!/bin/sh
(export DIR=/your/extraction/target/directory; echo \#\!/bin/sh -e; cat /tmp/tar-stderr.txt | grep 'Cannot create symlink to' | sed -e 's7^tar: \.\([^:]\+\): Cannot create symlink to .\([^:]\+\).*$7\1:\27' -e "s7^\(.\+\)/\([^:]\+\):\(.\+\).\$7cd $DIR\1 \&\& cp \3 \2;7")

EDIT: Explanation of script added:

The grep filters the lines of interest. My sed commands are simple, but use 7 as field delimiter instead of the common /. With this I can search for and/or write /.

The first sed expression filters the relevant information (relative path and the 2 filenames) and puts a : as delimiter. The second distinguishes filename from path and throws away the ' at the very end; the final output then is a cp command.