CC: | Ivan Shmakov <oneingray [...] gmail.com> |
Subject: | a ptarfilter (ptarmap, ptarsplit) application, please? |
Date: | Mon, 07 Nov 2011 01:43:28 +0700 |
To: | bug-Archive-Tar [...] rt.cpan.org |
From: | Ivan Shmakov <oneingray [...] gmail.com> |
Occasionally, it's necessary to process each of the files in the
archive with an arbitrary filter program. It'd be nice if
Archive::Tar could contain a program allowing one to do just
that. (Without unpacking the whole archive first, of course.)
Possible usage example (assuming no archive member has a
vertical line character as part of its filename):
$ tar -C /bin/ -c -- bash dash \
| ptarmap -v -- bash -c 'sha1sum | sed -e "s|-|${FILE}|"'
bash
add19e504c254758f2ea8dcda3821c77fafb4923 bash
dash
7f123974c1814d026a26e79981453881efb49916 dash
$
I've posted a possible implementation to news:alt.sources
recently [1], but I believe it requires some more polishing.
(Check the Bugs list in its README.)
BTW, given that a Tar archive could be viewed as a sequence of
“sub-archives”, I see a lot of similarity between the command
suggested and split(1) (especially its GNU incarnation.)
Therefore, one might try to implement more sophisticated usage
patterns, like:
$ ptarsplit --member-bytes=1M -- my.tar my.x
(no more than 1 MiB of data per each of the resulting Tar
archives; unless there're individual members of larger size);
$ ptarsplit --members=16 -- my.tar my.x
(no more than 16 archive members per each of the resulting Tar
archives; may be combined with --member-bytes=);
$ ptarsplit --exec --members=1 --no-header --no-trailer \
-- bash -c 'sha1sum | sed -e "s|-|${FILE}|"' \
< my.tar
(like [1]; perhaps a ptarmap wrapper, or a --map option, for
this mode.)
TIA.
[1] news:87d3d6blw0.fsf@violet.siamics.net
http://groups.google.com/group/alt.sources/browse_thread/thread/99533bf17ccff3fb
--
FSF associate member #7257
Message body not shown because it is not plain text.