[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] [PATCH] Test and document --keep-directory-symlink
From: |
Pavel Raiskup |
Subject: |
[Bug-tar] [PATCH] Test and document --keep-directory-symlink |
Date: |
Tue, 28 Feb 2017 09:55:09 +0100 |
* doc/tar.1: Document the option.
* tests/extrac20.at: New testcase.
* tests/Makefile.am: Mention extrac20.
* tests/testsuite.at: Likewise.
---
doc/tar.1 | 3 ++
tests/Makefile.am | 1 +
tests/extrac20.at | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/testsuite.at | 1 +
4 files changed, 156 insertions(+)
create mode 100644 tests/extrac20.at
diff --git a/doc/tar.1 b/doc/tar.1
index d66d3e6..f5c1fca 100644
--- a/doc/tar.1
+++ b/doc/tar.1
@@ -333,6 +333,9 @@ Don't replace existing files when extracting.
\fB\-\-keep\-newer\-files\fR
Don't replace existing files that are newer than their archive copies.
.TP
+\fB\-\-keep\-directory\-symlink\fR
+Don't replace existing symlinks to directories when extracting.
+.TP
\fB\-\-no\-overwrite\-dir\fR
Preserve metadata of existing directories.
.TP
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 502a37c..92516fb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -107,6 +107,7 @@ TESTSUITE_AT = \
extrac17.at\
extrac18.at\
extrac19.at\
+ extrac20.at\
filerem01.at\
filerem02.at\
gzip.at\
diff --git a/tests/extrac20.at b/tests/extrac20.at
new file mode 100644
index 0000000..dd9b00d
--- /dev/null
+++ b/tests/extrac20.at
@@ -0,0 +1,151 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+#
+# Test suite for GNU tar.
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This file is part of GNU tar.
+
+# GNU tar is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# GNU tar is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([keep-directory-symlink])
+AT_KEYWORDS([extrac20 extract old-files keep-old-files])
+
+AT_TAR_CHECK([
+AT_SORT_PREREQ
+
+for i in a b c
+do
+ dir=in$i
+ mkdir -p $dir/root/dir $dir/root/dirsymlink
+ touch $dir/root/dirsymlink/file$i
+ test $i != a && touch $dir/root/dirsymlink/file.conflict
+ tar cf archive$i.tar -C $dir root
+done
+
+prep()
+{
+ echo "== $1 =="
+ echo "== $1 ==" >&2
+ backup_dir=$1
+ dir=out
+ mkdir -p $dir/root/dir
+ ln -s dir $dir/root/dirsymlink
+ test $round = normal && cd $dir >/dev/null
+}
+
+clean()
+{
+ test $round = normal && cd .. >/dev/null
+ find $dir | sort
+ mv $dir $backup_dir
+}
+
+# Expand to '-f ../$1' or '-f $1 -C $dir' depending on $round variable
+file_spec()
+{
+ if test $round = normal
+ then
+ echo "-f ../$1"
+ else
+ echo "-f $1 -C $dir"
+ fi
+}
+
+for round in normal dir
+do
+ # Check that 'dirsymlink' replaces 'dir'
+ prep without_option_$round
+ tar -x `file_spec archivea.tar` || exit 1
+ tar -x `file_spec archiveb.tar` || exit 1
+ clean
+
+ # Keep directory symlink must keep root/dirsymlink
+ prep with_option_$round
+ tar -x --keep-directory-symlink `file_spec archivea.tar` || exit 1
+ tar -x --keep-directory-symlink `file_spec archiveb.tar` || exit 1
+ clean
+
+ prep collision_$round
+ tar -x --keep-directory-symlink `file_spec archivea.tar` --keep-old-files ||
exit 1
+ tar -x --keep-directory-symlink `file_spec archiveb.tar` --keep-old-files ||
exit 1
+ tar -x --keep-directory-symlink `file_spec archivec.tar` --keep-old-files &&
exit 1
+ clean
+done
+],
+[0],
+[== without_option_normal ==
+out
+out/root
+out/root/dir
+out/root/dirsymlink
+out/root/dirsymlink/file.conflict
+out/root/dirsymlink/filea
+out/root/dirsymlink/fileb
+== with_option_normal ==
+out
+out/root
+out/root/dir
+out/root/dir/file.conflict
+out/root/dir/filea
+out/root/dir/fileb
+out/root/dirsymlink
+== collision_normal ==
+out
+out/root
+out/root/dir
+out/root/dir/file.conflict
+out/root/dir/filea
+out/root/dir/fileb
+out/root/dir/filec
+out/root/dirsymlink
+== without_option_dir ==
+out
+out/root
+out/root/dir
+out/root/dirsymlink
+out/root/dirsymlink/file.conflict
+out/root/dirsymlink/filea
+out/root/dirsymlink/fileb
+== with_option_dir ==
+out
+out/root
+out/root/dir
+out/root/dir/file.conflict
+out/root/dir/filea
+out/root/dir/fileb
+out/root/dirsymlink
+== collision_dir ==
+out
+out/root
+out/root/dir
+out/root/dir/file.conflict
+out/root/dir/filea
+out/root/dir/fileb
+out/root/dir/filec
+out/root/dirsymlink
+],
+[== without_option_normal ==
+== with_option_normal ==
+== collision_normal ==
+tar: root/dirsymlink/file.conflict: Cannot open: File exists
+tar: Exiting with failure status due to previous errors
+== without_option_dir ==
+== with_option_dir ==
+== collision_dir ==
+tar: root/dirsymlink/file.conflict: Cannot open: File exists
+tar: Exiting with failure status due to previous errors
+])
+
+AT_CLEANUP
+
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 607639c..483a7ea 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -306,6 +306,7 @@ m4_include([extrac16.at])
m4_include([extrac17.at])
m4_include([extrac18.at])
m4_include([extrac19.at])
+m4_include([extrac20.at])
m4_include([backup01.at])
AT_BANNER([Volume label operations])
--
2.9.3
- [Bug-tar] [PATCH] Test and document --keep-directory-symlink,
Pavel Raiskup <=