5

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.

  • Did you transfer the file properly? If you ftp'ed, did you set binary before transfer? Also, check with tar tf dir.tar on Cygwin to see the table of contents. – unxnut Jan 7 '14 at 4:05
  • Yes, the file is ftp'd with binary set before transfer. tar tf dir.tar on Cygwin gives the full pathnames. This seems to be an incompatibility between GNU and Solaris implementations of tar. – Nomic Jan 7 '14 at 4:39
  • related, although definitely not a dupe:unix.stackexchange.com/questions/101561/…. this also talks a little about different tar implementations, not sure what exact implementation Solaris uses – strugee Jan 7 '14 at 5:32
  • Do any of your file names contain non-ASCII characters? If so, Checksumming problems seems to describe your situation. Try adding -i when extracting. (Answer updated accordingly.) – Mikel Jan 7 '14 at 17:12
  • No, all standard ASCII. Question updated. – Nomic Jan 7 '14 at 22:36
4

GNU tar formats suggests tar -c --format=posix or tar -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 using pax -r -x pax -f dir.tar, or likely just pax -r -f dir.tar.

Alternatively, if you have cpio installed on both systems, it seems like the crc format supports 1,023 character paths on both systems. That would look something like find -L dir | cpio -o -H crc > dir.cpio to create and cpio -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:

  • I second using cpio instead of tar for this instance. – Jenny D Jan 7 '14 at 7:38
  • There is a large (conservative) userbase on the Solaris system so a solution that uses Solaris tar is preferred. I tried using pax to extract the posix formatted GNU tarball but got more errors. It seems GNU and Solaris have different interpretations of the posix standard. Thanks for your suggestions! – Nomic Jan 9 '14 at 5:31
  • Yes, and there are multiple versions of the POSIX standard too. So much fun! Shame format=posix doesn't work. Mind adding the errors you get at the end of your question? Maybe we can fix those somehow. – Mikel Jan 9 '14 at 16:17
  • I've added the errors seen. Further research shows that star has an option to produce a suntar format so I will experiment with that as well. – Nomic Jan 21 '14 at 5:38
  • There is no star package available for cygwin. My next option is to either test for the limitations of ustar or try and emulate the Solaris 9 tar format using GNU's --pax-option – Nomic Jan 22 '14 at 11:23
3

Solaris tar and GNU tar have different interpretations of posix but both support ustar, which in turn supports long(ish) pathnames.

Using GNU tar on cygwin:

$ tar -c --format=ustar -f dir.tar dir

This creates a tarball which is happily extracted on Solaris 9 without errors. Perhaps not a universal solution but one that fits the constrained solution space. Looks like the 80s were useful after all!

  • The doc you linked to clearly says that ustar only supports up to 256 characters. There is an "extended ustar", but as far as I can see, that's what --format=posix produces. Did you test this? – Mikel Jan 9 '14 at 15:59
  • Yes, that's why --format=posix was my first choice, but it still produced the truncated names whereas --format=ustar did not. I will do some more testing to try and find out why this is so. I've removed the first sentence from my answer as I misinterpreted the linked page based on my test results. – Nomic Jan 9 '14 at 22:56
  • Question updated - the file names are being truncated at 100 characters, not 256. – Nomic Jan 10 '14 at 4:34
0

The main problem in GNU tar is that it does not contain code to control the archive format. GNU tar is too dumb to understand that POSIX.1-1988 may archive file names longer than 100 chars.

GNU tar in such a case switches to GNU proprietary extension in the middle of the archive and this is why Solaris tar will abort in the middle.

I recommend to use star from the schilytools source package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.