Is there an efficient way to verify a written tar-archive with transformed file names?
Assume I have a file called
foo and want to store it in the archive as
bar, I would create the archive
foobar.tar like so:
$ tar -cf foobar.tar --transform="flags=r;s|foo|bar|" foo $ tar --list -f foobar.tar bar
Now if I add the
--verify option, this will result in an error:
$ tar --verify -cf foobar.tar --transform="flags=r;s|foo|bar|" foo tar: Archive contains transformed file names. tar: Verification may fail to locate original files. tar: bar: Warning: Cannot stat: No such file or directory
I have unsuccessfully tried to fall-back on the
--compare flag on the already created (and transformed) archive like-so,
$ tar --compare -f foobar.tar --transform="flags=r;s|foo|bar|" foo tar: foo: Not found in archive tar: Exiting with failure status due to previous errors
--transform flag seems to be ignored. Another idea I had was to create the archive with original file names first, verify it during that step and then apply the transformation afterwards. However, I could not find any flag which tells
tar to do in-situ transformations of file names. Here's an example using
-u, which did not work (since
-u only updates/appends given files).
$ tar --verify -f foobar.tar foo $ tar --transform="flags=r;s|foo|bar|" -uf foobar.tar $ tar --list -f foobar.tar foo
I wish to write a program to manipulate the tar-headers manually or to implement my own verification routine. Anyhow, I would prefer sticking with standard UNIX tools. Furthermore, since I am working with very large archives, I want to avoid expensive operations such as generating temporary files.