I am maintaining a legacy cygwin (with GNU tar v1.21) system and a legacy Solaris 9 system. The configuration of the Solaris 9 system is fixed and cannot be upgraded (i.e. I can't install gnu tar for Solaris).
I am trying to create a tarball on the cygwin system that can extracted on the Solaris 9 system but unfortunately the directory structure (which is also fixed and cannot be renamed) plus file names exceed 100 characters and I've run into the Great Tar Wars of the last millennium. There is a large (conservative) userbase on the Solaris system so a solution that uses Solaris tar is preferred.
Here are the errors I'm experiencing.
Creating the tar on cygwin:
$ tar -cf dir.tar dir
or
$ tar -c --posix -f dir.tar dir
Gives the following on Solaris:
$ tar -xif dir.tar
tar: directory checksum errors
And the file names in dir are truncated. (i.e. ignoring checksum errors doesn't help)
How do I create a tarball with long pathnames using GNU tar that can be extracted by Solaris tar?
Edit #2: Unable to use Schily Tar (star)
It appears that Joerg Schilling has been able to emulate the Solaris 7/8/9 tar format and provides a suntar
option to create a Solaris tarball using star.
Unfortunately star
is not available on cygwin. 🙁
Edit #1: Using –format=posix gives errors when extracting
Errors when extracting –format=posix gnu tarballs using pax on Solaris 9
On cygwin:
$ ls example/this_is_a_path_name_greater_than_one_hundred_characters/when_combined_with_this_file_name_which_is_also_rather_long.txt | wc -m
128
$ tar -c --format=posix -f example.tar example
On Solaris:
$ pax -r -f example.tar
pax: ./PaxHeaders.4440/example : Unknown filetype
pax: example/PaxHeaders.4440/this_is_a_path_name_greater_than_one_hundred_characters : Unknown filetype
pax: example/this_is_a_path_name_greater_than_one_hundred_characters/PaxHeaders.4440/when_combined_with_t : Unknown filetype
Similar errors are given when extracting using Solaris tar.
Best Answer
GNU tar formats suggests
tar -c --format=posix
ortar -c --format=pax
is the only way to create a portable tar file containing path names longer than 255 characters.The Solaris tar man page doesn't mention supporting that format, but the Solaris pax man page does.
So first, I'd try to create the archive on your Cygwin (or Linux) system using
tar -c --format=posix -f dir.tar dir
, and to extract it on your Solaris system usingpax -r -x pax -f dir.tar
, or likely justpax -r -f dir.tar
.Alternatively, if you have
cpio
installed on both systems, it seems like thecrc
format supports 1,023 character paths on both systems. That would look something likefind -L dir | cpio -o -H crc > dir.cpio
to create andcpio -i -d < dir.cpio
to extract it.Finally, you could try adding the
-i
flag to ignore directory checksum errors when extracting on Solaris, e.g.tar -x -i -f dir.tar
. Checksumming problems says this can be needed if any of the file names in the tar archive are non-ASCII.Other reading: