From 41dae689520b0af0b5226117e77572a24954f075 Mon Sep 17 00:00:00 2001
From: Allan McRae <allan@archlinux.org>
Date: Tue, 17 Jul 2012 19:13:03 +1000
Subject: pactest: Do not remove symlink to directory if a to be installed
 package uses it

If a pacakge has a directory symlink (e.g. /lib -> usr/lib), do not
allow it to be removed if any other package is trying to install a
file into that path (e.g. /lib/foo).  This is because the local
database can become invalidated if the symlink is removed after the
package with file /lib/foo is installed (sync702.py).  If the symlink
is removed before the file is installed (sync701.py), the upgrade is
actually a success, but we can not guarantee the ordering so both
cases should fail.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
---
 test/pacman/tests/sync701.py | 22 ++++++++++++++++++++++
 test/pacman/tests/sync702.py | 22 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 test/pacman/tests/sync701.py
 create mode 100644 test/pacman/tests/sync702.py

(limited to 'test/pacman/tests')

diff --git a/test/pacman/tests/sync701.py b/test/pacman/tests/sync701.py
new file mode 100644
index 00000000..201f6028
--- /dev/null
+++ b/test/pacman/tests/sync701.py
@@ -0,0 +1,22 @@
+self.description = "do not remove directory symlink if incoming package has file in its path (order 1)"
+
+lp = pmpkg("pkg1")
+lp.files = ["usr/lib/foo",
+            "lib -> usr/lib"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg1", "1.0-2")
+p1.files = ["usr/lib/foo"]
+self.addpkg2db("sync", p1)
+
+p2 = pmpkg("pkg2")
+p2.files = ["lib/bar"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg1 pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_VERSION=pkg1|1.0-1")
+self.addrule("!PKG_EXIST=pkg2")
+
+self.expectfailure = True
diff --git a/test/pacman/tests/sync702.py b/test/pacman/tests/sync702.py
new file mode 100644
index 00000000..ee4eef95
--- /dev/null
+++ b/test/pacman/tests/sync702.py
@@ -0,0 +1,22 @@
+self.description = "do not remove directory symlink if incoming package has file in its path (order 2)"
+
+lp = pmpkg("pkg2")
+lp.files = ["usr/lib/foo",
+            "lib -> usr/lib"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg1")
+p1.files = ["lib/bar"]
+self.addpkg2db("sync", p1)
+
+p2 = pmpkg("pkg2", "1.0-2")
+p2.files = ["usr/lib/foo"]
+self.addpkg2db("sync", p2)
+
+self.args = "-S pkg1 pkg2"
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_VERSION=pkg2|1.0-1")
+self.addrule("!PKG_EXIST=pkg1")
+
+self.expectfailure = True
-- 
cgit v1.2.3-70-g09d2