• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

``tar --newer-mtime'' behaviour change or BUG?

yks

Member


Messages: 49

#1
It seems that recently the `tar' behaviour regarding the options `--newer-mtime'' and `--newer-mtime-than'' has changed.
At least, in FreeBSD 7.2 the command
Code:
tar czf <file> --newer-mtime <date> .
created an archive of ALL files, with their relative paths, which had been modified ever since, and in FreeBSD 8.0 this includes only the files, all path components of which had been modified, which is very inconvenient. (This relates to the /usr/bin/tar program)
I created an example: 3 dirs with 2 files in each
Code:
# find . |xargs ls -l
.:
drwxr-xr-x  2 yks  yks  512 Jan 19 14:21 dir1
drwxr-xr-x  2 yks  yks  512 Jan 19 14:21 dir2
drwxr-xr-x  2 yks  yks  512 Jan 19 14:21 dir3

./dir1:
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file1
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file2

./dir2:
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file1
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file2

./dir3:
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file1
-rw-r--r--  1 yks  yks  0 Jan 19 14:21 file2
Then we execute commands:
Code:
$ which tar
/usr/bin/tar
$ touch lastmod
$ find . -name file1 | xargs touch
$ tar czf a.tar.gz --newer-mtime-than lastmod .
$ tar tf a.tar.gz
We expect the newer files with name `file1' to be added to the archive, regardless of their directories' modification time (we modified files but not the directories).
And we see two different archives:
FreeBSD 7.2 tar version: bsdtar 2.5.5 - libarchive 2.5.5
Code:
./
./dir1/
./dir2/
./dir3/
./dir3/file1
./dir2/file1
./dir1/file1
FreeBSD 8.0 tar version: bsdtar 2.7.0 - libarchive 2.7.0:
Code:
./
No files were added in 8.0!


After executing
Code:
$ touch *
which `touch'ed dir1, dir2, dir3,
the tar DOES add the required files into the archive, but it's not always possible to upward-recursively `touch' the directories in which the newer files reside.
The option `--newer-mtime' works analogously, i.e. when feeding it the date of the `lastmod' file, the results are the same.
Is this a bug, a feature, or what, and if a feature, then is it possible to emulate previous behaviour, and to add the issue to `man'?