[Toybox] Tar --transform is weird.
Rob Landley
rob at landley.net
Thu May 19 06:58:49 PDT 2022
The "only apply transforms to certain file types" selection is CONCEPTUALLY
broken because the directories leading to those entries participate in the
transform, and the directories have their own type (which is not listed), and
each directory is stored in its own entry because tar x doesn't mkdir -p. So if
you make a symlink and a file in a deepish hirerarchy but only adjust the
directory names of SOME entries, it's not gonna extract right? Let's try:
$ ln -s seven one/two/three/four/five/six
$ touch one/two/three/four/five/eight
And then tell debian's tar to modify the path of non-symlinks:
$ tar cv one --xform=s/three/zero/S | tar t
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/zero/
one/two/zero/four/
one/two/zero/four/five/
one/two/zero/four/five/eight
one/two/zero/four/five/six
The symlink's path is modified despite the S exclusion. What happens if I tell
it to apply a different change that includes the filename:
$ tar cv one --xform=s at five/six at seven@S | tar t
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/seven
The "do not apply to symlink" got ignored? How about JUST the filename?
8$ tar cv one --xform=s at six@seven at S | tar tone/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/seven
What does the S exclusion MEAN here?
landley at driftwood:~/toybox/toybox/sub8$ ls -ls one/two/three/four/five
total 0
0 -rw-r--r-- 1 landley landley 0 May 19 08:29 eight
0 lrwxrwxrwx 1 landley landley 5 May 19 08:29 six -> seven
$ tar cv one --xform=s at eight@nine at R | tar t
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
The "do not apply to regular files" exclusion is working...
$ tar cv one --xform=s at three@zero at R | tar t
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
Including for directory entries?
$ tar cv one --xform=s at three@zero at r | tar t
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/zero/
one/two/zero/four/
one/two/zero/four/five/
one/two/zero/four/five/eight
one/two/zero/four/five/six
$ tar cv one --xform=s at six@seven at r | tar tone/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/six
one/
one/two/
one/two/three/
one/two/three/four/
one/two/three/four/five/
one/two/three/four/five/eight
one/two/three/four/five/seven
So it thinks directories are regular files. It also thinks (dangling) SYMLINKS
are regular files...
$ tar c ccc --xform s/ccc/abd/S | tar t
abd
$ tar c ccc --xform s/ccc/abd/R | tar t
ccc
Ok, non-dangling symlinks with no directory component are ALSO regular files. It
seems to think EVERYTHING is a regular file. Great. (I have not poked much at
hardlinks yet because it seems a bit obscure?)
Sigh. I am trying to work out what to implement here, and it's... not well
specified. (Can I just NOT implement the /RHS part yet and call it good? So far
it looks like specifying "R" means "ignore this --xform" and everything else is
a NOP? Modulo the H exclusion I haven't tested yet because hardlinks don't come
up much...)
Rob
More information about the Toybox
mailing list