#775247 tar: transform applied to symlink targets incorrectly when changing directory level

Package:
tar
Source:
tar
Description:
GNU version of the tar archiving utility
Submitter:
Frank Heckenbach
Date:
2015-01-13 02:54:06 UTC
Severity:
normal
#775247#5
Date:
2015-01-13 02:51:32 UTC
From:
To:
Transform by default also applies to symlink targets. In most cases,
that's useful:

% touch foo
% ln -s foo bar
% tar --transform=s/o/u/ -cf baz foo bar
% tar tvf baz
-rw------- frank/frank       0 2015-01-13 03:35 fuo
lrwxrwxrwx frank/frank       0 2015-01-13 03:35 bar -> fuo

So far, so good.

However, when the transform adds (or removes) a directory level, the
resulting symlink is broken:

% tar --transform=s,^,sub/, -cf baz foo bar
% tar tvf baz
-rw------- frank/frank       0 2015-01-13 03:35 sub/foo
lrwxrwxrwx frank/frank       0 2015-01-13 03:35 sub/bar -> sub/foo

I know it's not a trivial problem. With both above transforms
combined, tar would need to apply the first and not the second to
the target. Or more generally, apply the whole transform to the
target, then if it's a relative link, add or remove the necessary
directory levels ...

For my current problem, the "S" flag will help me out since all
affected symlinks are local, but in more complicated cases, it might
not suffice.