Blame SOURCES/tar-1.26-keep-directory-symlink-doc-and-test.patch

f4af7d
From 49b5cd11bc3d64b0316cfc5b7245d25e4f7f4fcd Mon Sep 17 00:00:00 2001
f4af7d
From: Pavel Raiskup <praiskup@redhat.com>
f4af7d
Date: Thu, 19 Oct 2017 16:53:00 +0200
f4af7d
Subject: [PATCH] test keep-directory-symlink
f4af7d
f4af7d
Upstream commit:
f4af7d
From d06126f814563b01e598b85a8cc233604a2948f2 Mon Sep 17 00:00:00 2001
f4af7d
From: Pavel Raiskup <praiskup@redhat.com>
f4af7d
Date: Tue, 28 Feb 2017 09:55:09 +0100
f4af7d
Subject: [PATCH] Test and document --keep-directory-symlink
f4af7d
f4af7d
* doc/tar.1: Document the option.
f4af7d
* tests/extrac20.at: New testcase.
f4af7d
* tests/Makefile.am: Mention extrac20.
f4af7d
* tests/testsuite.at: Likewise.
f4af7d
---
f4af7d
 tests/Makefile.am  |   1 +
f4af7d
 tests/extrac20.at  | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++
f4af7d
 tests/testsuite.at |   2 +-
f4af7d
 3 files changed, 153 insertions(+), 1 deletion(-)
f4af7d
 create mode 100644 tests/extrac20.at
f4af7d
f4af7d
diff --git a/tests/Makefile.am b/tests/Makefile.am
f4af7d
index 094b71c..bd8d3e8 100644
f4af7d
--- a/tests/Makefile.am
f4af7d
+++ b/tests/Makefile.am
f4af7d
@@ -79,6 +79,7 @@ TESTSUITE_AT = \
f4af7d
  extrac09.at\
f4af7d
  extrac18.at\
f4af7d
  extrac19.at\
f4af7d
+ extrac20.at\
f4af7d
  extrac10.at\
f4af7d
  extrac11.at\
f4af7d
  extrac12.at\
f4af7d
diff --git a/tests/extrac20.at b/tests/extrac20.at
f4af7d
new file mode 100644
f4af7d
index 0000000..dd9b00d
f4af7d
--- /dev/null
f4af7d
+++ b/tests/extrac20.at
f4af7d
@@ -0,0 +1,151 @@
f4af7d
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
f4af7d
+#
f4af7d
+# Test suite for GNU tar.
f4af7d
+# Copyright 2017 Free Software Foundation, Inc.
f4af7d
+
f4af7d
+# This file is part of GNU tar.
f4af7d
+
f4af7d
+# GNU tar is free software; you can redistribute it and/or modify
f4af7d
+# it under the terms of the GNU General Public License as published by
f4af7d
+# the Free Software Foundation; either version 3 of the License, or
f4af7d
+# (at your option) any later version.
f4af7d
+
f4af7d
+# GNU tar is distributed in the hope that it will be useful,
f4af7d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f4af7d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f4af7d
+# GNU General Public License for more details.
f4af7d
+
f4af7d
+# You should have received a copy of the GNU General Public License
f4af7d
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
f4af7d
+
f4af7d
+AT_SETUP([keep-directory-symlink])
f4af7d
+AT_KEYWORDS([extrac20 extract old-files keep-old-files])
f4af7d
+
f4af7d
+AT_TAR_CHECK([
f4af7d
+AT_SORT_PREREQ
f4af7d
+
f4af7d
+for i in a b c
f4af7d
+do
f4af7d
+  dir=in$i
f4af7d
+  mkdir -p $dir/root/dir $dir/root/dirsymlink
f4af7d
+  touch $dir/root/dirsymlink/file$i
f4af7d
+  test $i != a && touch $dir/root/dirsymlink/file.conflict
f4af7d
+  tar cf archive$i.tar -C $dir root
f4af7d
+done
f4af7d
+
f4af7d
+prep()
f4af7d
+{
f4af7d
+  echo "== $1 =="
f4af7d
+  echo "== $1 ==" >&2
f4af7d
+  backup_dir=$1
f4af7d
+  dir=out
f4af7d
+  mkdir -p $dir/root/dir
f4af7d
+  ln -s dir $dir/root/dirsymlink
f4af7d
+  test $round = normal && cd $dir >/dev/null
f4af7d
+}
f4af7d
+
f4af7d
+clean()
f4af7d
+{
f4af7d
+  test $round = normal && cd .. >/dev/null
f4af7d
+  find $dir | sort
f4af7d
+  mv $dir $backup_dir
f4af7d
+}
f4af7d
+
f4af7d
+# Expand to '-f ../$1' or '-f $1 -C $dir' depending on $round variable
f4af7d
+file_spec()
f4af7d
+{
f4af7d
+  if test $round = normal
f4af7d
+  then
f4af7d
+    echo "-f ../$1"
f4af7d
+  else
f4af7d
+    echo "-f $1 -C $dir"
f4af7d
+  fi
f4af7d
+}
f4af7d
+
f4af7d
+for round in normal dir
f4af7d
+do
f4af7d
+  # Check that 'dirsymlink' replaces 'dir'
f4af7d
+  prep without_option_$round
f4af7d
+  tar -x `file_spec archivea.tar` || exit 1
f4af7d
+  tar -x `file_spec archiveb.tar` || exit 1
f4af7d
+  clean
f4af7d
+
f4af7d
+  # Keep directory symlink must keep root/dirsymlink
f4af7d
+  prep with_option_$round
f4af7d
+  tar -x --keep-directory-symlink `file_spec archivea.tar` || exit 1
f4af7d
+  tar -x --keep-directory-symlink `file_spec archiveb.tar` || exit 1
f4af7d
+  clean
f4af7d
+
f4af7d
+  prep collision_$round
f4af7d
+  tar -x --keep-directory-symlink `file_spec archivea.tar` --keep-old-files || exit 1
f4af7d
+  tar -x --keep-directory-symlink `file_spec archiveb.tar` --keep-old-files || exit 1
f4af7d
+  tar -x --keep-directory-symlink `file_spec archivec.tar` --keep-old-files && exit 1
f4af7d
+  clean
f4af7d
+done
f4af7d
+],
f4af7d
+[0],
f4af7d
+[== without_option_normal ==
f4af7d
+out
f4af7d
+out/root
f4af7d
+out/root/dir
f4af7d
+out/root/dirsymlink
f4af7d
+out/root/dirsymlink/file.conflict
f4af7d
+out/root/dirsymlink/filea
f4af7d
+out/root/dirsymlink/fileb
f4af7d
+== with_option_normal ==
f4af7d
+out
f4af7d
+out/root
f4af7d
+out/root/dir
f4af7d
+out/root/dir/file.conflict
f4af7d
+out/root/dir/filea
f4af7d
+out/root/dir/fileb
f4af7d
+out/root/dirsymlink
f4af7d
+== collision_normal ==
f4af7d
+out
f4af7d
+out/root
f4af7d
+out/root/dir
f4af7d
+out/root/dir/file.conflict
f4af7d
+out/root/dir/filea
f4af7d
+out/root/dir/fileb
f4af7d
+out/root/dir/filec
f4af7d
+out/root/dirsymlink
f4af7d
+== without_option_dir ==
f4af7d
+out
f4af7d
+out/root
f4af7d
+out/root/dir
f4af7d
+out/root/dirsymlink
f4af7d
+out/root/dirsymlink/file.conflict
f4af7d
+out/root/dirsymlink/filea
f4af7d
+out/root/dirsymlink/fileb
f4af7d
+== with_option_dir ==
f4af7d
+out
f4af7d
+out/root
f4af7d
+out/root/dir
f4af7d
+out/root/dir/file.conflict
f4af7d
+out/root/dir/filea
f4af7d
+out/root/dir/fileb
f4af7d
+out/root/dirsymlink
f4af7d
+== collision_dir ==
f4af7d
+out
f4af7d
+out/root
f4af7d
+out/root/dir
f4af7d
+out/root/dir/file.conflict
f4af7d
+out/root/dir/filea
f4af7d
+out/root/dir/fileb
f4af7d
+out/root/dir/filec
f4af7d
+out/root/dirsymlink
f4af7d
+],
f4af7d
+[== without_option_normal ==
f4af7d
+== with_option_normal ==
f4af7d
+== collision_normal ==
f4af7d
+tar: root/dirsymlink/file.conflict: Cannot open: File exists
f4af7d
+tar: Exiting with failure status due to previous errors
f4af7d
+== without_option_dir ==
f4af7d
+== with_option_dir ==
f4af7d
+== collision_dir ==
f4af7d
+tar: root/dirsymlink/file.conflict: Cannot open: File exists
f4af7d
+tar: Exiting with failure status due to previous errors
f4af7d
+])
f4af7d
+
f4af7d
+AT_CLEANUP
f4af7d
+
f4af7d
diff --git a/tests/testsuite.at b/tests/testsuite.at
f4af7d
index f7f00ee..b540948 100644
f4af7d
--- a/tests/testsuite.at
f4af7d
+++ b/tests/testsuite.at
f4af7d
@@ -234,9 +234,9 @@ m4_include([extrac14.at])
f4af7d
 m4_include([extrac15.at])
f4af7d
 m4_include([extrac16.at])
f4af7d
 m4_include([extrac17.at])
f4af7d
-
f4af7d
 m4_include([extrac18.at])
f4af7d
 m4_include([extrac19.at])
f4af7d
+m4_include([extrac20.at])
f4af7d
 
f4af7d
 m4_include([label01.at])
f4af7d
 m4_include([label02.at])
f4af7d
-- 
f4af7d
2.13.6
f4af7d