[Toybox] Tar --transform is weird.
enh
enh at google.com
Mon May 23 17:45:33 PDT 2022
https://android.googlesource.com/kernel/common/+/refs/heads/android-mainline/scripts/Makefile.package#49
and
https://android.googlesource.com/kernel/build/+/d68a8336a396a98820de2b3432ce5206fe70c854/build.sh#668
are the only two usages i've ever seen (and internal code search didn't
have any others when i asked it).
sadly i've forgotten how to search debian packages again... but apparently
i did remember last time this came up:
http://lists.landley.net/htdig.cgi/toybox-landley.net/2020-October/012074.html
On Thu, May 19, 2022 at 6:53 AM Rob Landley <rob at landley.net> wrote:
> 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
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20220523/c1550312/attachment-0001.htm>
More information about the Toybox
mailing list