[pacman-dev] [PATCH] remove.c: honor inverted patterns in noupgrade
Andrew Gregory
andrew.gregory.8 at gmail.com
Sat Nov 29 23:02:56 UTC 2014
Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
lib/libalpm/remove.c | 4 ++--
test/pacman/tests/TESTS | 1 +
test/pacman/tests/noupgrade-inverted.py | 19 +++++++++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
create mode 100644 test/pacman/tests/noupgrade-inverted.py
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index dd061e5..f9b24ef 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -326,7 +326,7 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file,
{
char filepath[PATH_MAX];
- if(alpm_list_find(skip_remove, file->name, _alpm_fnmatch)) {
+ if(_alpm_fnmatch_patterns(skip_remove, file->name) == 0) {
/* return success because we will never actually remove this file */
return 1;
}
@@ -451,7 +451,7 @@ static int unlink_file(alpm_handle_t *handle, alpm_pkg_t *oldpkg,
/* check the remove skip list before removing the file.
* see the big comment block in db_find_fileconflicts() for an
* explanation. */
- if(alpm_list_find(skip_remove, fileobj->name, _alpm_fnmatch)) {
+ if(_alpm_fnmatch_patterns(skip_remove, fileobj->name) == 0) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s is in skip_remove, skipping removal\n", file);
return 1;
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS
index 052cf4b..12adf6d 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -63,6 +63,7 @@ TESTS += test/pacman/tests/ldconfig003.py
TESTS += test/pacman/tests/mode001.py
TESTS += test/pacman/tests/mode002.py
TESTS += test/pacman/tests/mode003.py
+TESTS += test/pacman/tests/noupgrade-inverted.py
TESTS += test/pacman/tests/pacman001.py
TESTS += test/pacman/tests/pacman002.py
TESTS += test/pacman/tests/pacman003.py
diff --git a/test/pacman/tests/noupgrade-inverted.py b/test/pacman/tests/noupgrade-inverted.py
new file mode 100644
index 0000000..8e7f1ea
--- /dev/null
+++ b/test/pacman/tests/noupgrade-inverted.py
@@ -0,0 +1,19 @@
+self.description = "Upgrade a package with files that match negated NoUpgrade patterns"
+
+lp = pmpkg("foobar")
+lp.files = ["foo/bar", "foo/baz"]
+self.addpkg2db("local", lp)
+
+p = pmpkg("foobar", "1.0-2")
+p.files = ["foo/bar"]
+self.addpkg(p)
+
+self.option["NoUpgrade"] = ["foo/*", "!foo/bar", "!foo/baz"]
+
+self.args = "-U %s" % p.filename()
+
+self.addrule("PKG_VERSION=foobar|1.0-2")
+self.addrule("!FILE_EXIST=foo/baz")
+self.addrule("FILE_MODIFIED=foo/bar")
+self.addrule("!FILE_PACNEW=foo/bar")
+self.addrule("!FILE_PACSAVE=foo/bar")
--
2.1.3
More information about the pacman-dev
mailing list