help-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-tar] Trouble with tar -xzf when using --files-from=-


From: Reuti
Subject: Re: [Help-tar] Trouble with tar -xzf when using --files-from=-
Date: Wed, 21 Oct 2015 13:59:18 +0200

> Am 21.10.2015 um 13:10 schrieb Reuti <address@hidden>:
> 
> 
>> Am 21.10.2015 um 12:32 schrieb Reuti <address@hidden>:
>> 
>> Hi,
>> 
>> 
>>> Am 21.10.2015 um 03:20 schrieb Tony Olekshy <address@hidden>:
>>> 
>>> Hello.
>>> 
>>> I'm having trouble understanding why I can't pipe the output of a
>>> tar -tzf a.tgz ... through to a tar -xzf a.tgz --files=from=- ...
>>> without producing what appear to be spurious messages. In practice
>>> I want to place a filter in that pipeline to select just what to
>>> extract, but the following script simplifies that out to just show
>>> the problem I'm encountering.
>> 
>> Accessing "." in the archive will move its pointer already to the end:
>> 
>> $ echo . | tar tf archive.tgz --files-from=-
>> ./
>> ./foo/
>> ./foo/bar
> 
> Ah, although I missed the --no-recursion at the first glance: its position is 
> important. It must appear before the --files-from=- in your case.

When you created the archive with:

$TAR -vczf $TEST/archive.tgz --files-from=- --no-recursion

it should include several copies of the files, as the --no-recursion has no 
further argument on the command line it would operate on. But it acts global 
instead.

IMO this is the real bug which was discovered by the original issue. It's still 
present in 1.28 AFAICS. There is a test "23 recurse: toggle" which might cover 
it, but it succeeds.

-- Reuti


> Nevertheless I wonder: --no-recursion is listed under "local file selection", 
> it's behavior during extraction sounds like --exact-match as there are plain 
> files in an archive I would say, not directories.
> 
> -- Reuti
> 
> 
>> BTW: there is the option -C to easy to write to any directory with `tar`.
>> 
>> -- Reuti
>> 
>> 
>>> Here are my test script and my questions thereto. Any insight you
>>> can provide me with would be appreciated.
>>> 
>>> #!/bin/bash
>>> #-----------------------------------------------------------------------
>>> #
>>> #   Subject: Trouble with tar -xzf when using --files-from=-
>>> #
>>> #   From Tony Olekshy, Avra Software Lab Inc., 2015-10-20.
>>> #
>>> #   The following has been reproduced with the GNU tar 1.26 that came
>>> #   with Fedora release 18, with GNU tar 1.27.1 and 1.28 which I just
>>> #   compiled on Fedora release 18, and with the GNU tar 1.23 that came
>>> #   with Red Hat Enterprise Linux Server release 6.6.
>>> #
>>> #   Step 5 below produces these messages:
>>> #
>>> #       tar: ./foo: Not found in archive
>>> #       tar: ./foo/bar: Not found in archive
>>> #       tar: Exiting with failure status due to previous errors
>>> #
>>> #   But step 6 shows that ./foo & ./foo/bar were in fact correctly
>>> #   extracted into $TEST/into, so they were found in the archive!
>>> #
>>> #   My questions are: Why does step 5 produce those messages?
>>> #   What am I misunderstanding, or is there some bug in tar?
>>> #
>>> set -v #----------------------------------------------------------------
>>> 
>>> : Step 1: Create the testing environment...
>>> :
>>> export TAR=/bin/tar TEST=~/test
>>> 
>>> echo; $TAR --version | grep 'GNU tar'
>>> 
>>> mkdir -p $TEST/from/foo $TEST/into
>>> rm -rf $TEST/archive.tgz $TEST/into/*
>>> date > $TEST/from/foo/bar
>>> 
>>> : Step 2: Show the contents of $TEST...
>>> :
>>> echo; cd $TEST; find . | sort | xargs ls -ld
>>> 
>>> : Step 3: Create $TEST/archive.tgz...
>>> :
>>> cd $TEST/from; find .   \
>>>                      \
>>>  | $TAR -vczf $TEST/archive.tgz --files-from=- --no-recursion
>>> 
>>> : Step 4: Show the contents of archive.tgz...
>>> :
>>> cd $TEST; $TAR -tzf $TEST/archive.tgz
>>> 
>>> : Step 5: Extract files from archive.tgz using --files-from...
>>> :
>>> cd $TEST; $TAR -tzf $TEST/archive.tgz | ( cd $TEST/into;
>>> 
>>>  $TAR -vxzf $TEST/archive.tgz --files-from=- --no-recursion )
>>> 
>>> : Step 6: Show the contents of $TEST...
>>> :
>>> echo; cd $TEST; find . | sort | xargs ls -ld
>>> 
>>> exit #------------------------------------------------------------------
>>> 
>>> Here is the output from running that script...
>>> 
>>> : Step 1: Create the testing environment...
>>> :
>>> export TAR=/bin/tar TEST=~/test
>>> 
>>> echo; $TAR --version | grep 'GNU tar'
>>> 
>>> tar (GNU tar) 1.26
>>> 
>>> mkdir -p $TEST/from/foo $TEST/into
>>> rm -rf $TEST/archive.tgz $TEST/into/*
>>> date > $TEST/from/foo/bar
>>> 
>>> : Step 2: Show the contents of $TEST...
>>> :
>>> echo; cd $TEST; find . | sort | xargs ls -ld
>>> 
>>> drwxr-x--- 4 olekshy olekshy 4096 Oct 20 18:52 ./
>>> drwxr-x--- 3 olekshy olekshy 4096 Oct 20 18:37 ./from/
>>> drwxr-x--- 2 olekshy olekshy 4096 Oct 20 18:37 ./from/foo/
>>> -rw-r----- 1 olekshy olekshy   29 Oct 20 18:52 ./from/foo/bar
>>> drwxr-x--- 2 olekshy olekshy 4096 Oct 20 18:52 ./into/
>>> 
>>> : Step 3: Create $TEST/archive.tgz...
>>> :
>>> cd $TEST/from; find .   \
>>>                      \
>>>  | $TAR -vczf $TEST/archive.tgz --files-from=- --no-recursion
>>> ./
>>> ./foo/
>>> ./foo/bar
>>> 
>>> : Step 4: Show the contents of archive.tgz...
>>> :
>>> cd $TEST; $TAR -tzf $TEST/archive.tgz
>>> ./
>>> ./foo/
>>> ./foo/bar
>>> 
>>> : Step 5: Extract files from archive.tgz using --files-from...
>>> :
>>> cd $TEST; $TAR -tzf $TEST/archive.tgz | ( cd $TEST/into;
>>> 
>>>  $TAR -vxzf $TEST/archive.tgz --files-from=- --no-recursion )
>>> ./
>>> ./foo/
>>> ./foo/bar
>>> /bin/tar: ./foo: Not found in archive
>>> /bin/tar: ./foo/bar: Not found in archive
>>> /bin/tar: Exiting with failure status due to previous errors
>>> 
>>> : Step 6: Show the contents of $TEST...
>>> :
>>> echo; cd $TEST; find . | sort | xargs ls -ld
>>> 
>>> drwxr-x--- 4 olekshy olekshy 4096 Oct 20 18:52 ./
>>> -rw-r----- 1 olekshy olekshy  195 Oct 20 18:52 ./archive.tgz
>>> drwxr-x--- 3 olekshy olekshy 4096 Oct 20 18:37 ./from/
>>> drwxr-x--- 2 olekshy olekshy 4096 Oct 20 18:37 ./from/foo/
>>> -rw-r----- 1 olekshy olekshy   29 Oct 20 18:52 ./from/foo/bar
>>> drwxr-x--- 3 olekshy olekshy 4096 Oct 20 18:37 ./into/
>>> drwxr-x--- 2 olekshy olekshy 4096 Oct 20 18:37 ./into/foo/
>>> -rw-r----- 1 olekshy olekshy   29 Oct 20 18:52 ./into/foo/bar
>>> 
>>> exit #------------------------------------------------------------------
>>> 
>>> Sincerely Yours,
>>> Tony Olekshy
>>> Avra Software Lab Inc.
>>> 
>> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]