[Toybox] Tar --transform is weird.

scsijon scsijon at lamiaworks.com
Thu May 19 16:55:27 PDT 2022


Sorry for the toppost but i don't know where this should go.

My understanding is that you should be putting the S flag at the START 
of the transform= line, not the end as it's actioned in order from the = 
and s is also a transform flag so is actioned first and would overwrite 
the S flag, ie the S would be ignored.


https://www.gnu.org/software/tar/manual/html_section/transform.html#transform 
is the refreance page for this. Look about halfway down for 's' and 'S'.

regards

scsijon

On 20/5/22 06:08, toybox-request at lists.landley.net wrote:
>     1. Tar --transform is weird. (Rob Landley)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 19 May 2022 08:58:49 -0500
> From: Rob Landley <rob at landley.net>
> To: toybox <toybox at lists.landley.net>
> Subject: [Toybox] Tar --transform is weird.
> Message-ID: <1b5fb309-a720-d7a5-c7f3-5b1f7f2833df at landley.net>
> Content-Type: text/plain; charset=UTF-8
>
> 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
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>
>
> ------------------------------
>
> End of Toybox Digest, Vol 127, Issue 16
> ***************************************


More information about the Toybox mailing list