summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-10-30 13:33:14 -0400
committerDave Reisner <dreisner@archlinux.org>2011-11-13 14:19:00 -0500
commit902305f1633298ff0ef7cd2bfbed0e91aae91646 (patch)
tree84b45ee05d773a42b301a98f06153a00de2b9835 /lib/libalpm
parent64d54f674150fdcf4b925f7f27067c7ec0446863 (diff)
downloadpacman-902305f1633298ff0ef7cd2bfbed0e91aae91646.tar.xz
add support for back end fnmatch'd options
This is work originally provided by Sascha Kruse on FS#20360 with only minor adjustments to the implementation. It's been expanded to cover: NoUpgrade, NoExtract, IgnorePkg, IgnoreGroup. Adds tests ignore008, sync139, sync502, and sync503. Also satisfies FS#18988. Original-work-by: Sascha Kruse <knopwob@googlemail.com> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c4
-rw-r--r--lib/libalpm/package.c4
-rw-r--r--lib/libalpm/remove.c4
-rw-r--r--lib/libalpm/util.c6
-rw-r--r--lib/libalpm/util.h1
5 files changed, 13 insertions, 6 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index d66ab934..44b852f2 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -179,7 +179,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
}
/* if a file is in NoExtract then we never extract it */
- if(alpm_list_find_str(handle->noextract, entryname)) {
+ if(alpm_list_find(handle->noextract, entryname, _alpm_fnmatch)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "%s is in NoExtract, skipping extraction\n",
entryname);
alpm_logaction(handle, "note: %s is in NoExtract, skipping extraction\n",
@@ -259,7 +259,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
} else if(S_ISREG(entrymode)) {
/* case 4,7: */
/* if file is in NoUpgrade, don't touch it */
- if(alpm_list_find_str(handle->noupgrade, entryname)) {
+ if(alpm_list_find(handle->noupgrade, entryname, _alpm_fnmatch)) {
notouch = 1;
} else {
alpm_backup_t *backup;
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index e0f4ff26..2a971770 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -690,14 +690,14 @@ int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
alpm_list_t *groups = NULL;
/* first see if the package is ignored */
- if(alpm_list_find_str(handle->ignorepkg, pkg->name)) {
+ if(alpm_list_find(handle->ignorepkg, pkg->name, _alpm_fnmatch)) {
return 1;
}
/* next see if the package is in a group that is ignored */
for(groups = alpm_pkg_get_groups(pkg); groups; groups = groups->next) {
char *grp = groups->data;
- if(alpm_list_find_str(handle->ignoregroup, grp)) {
+ if(alpm_list_find(handle->ignoregroup, grp, _alpm_fnmatch)) {
return 1;
}
}
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index cf137ae8..d7e06bc8 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -216,7 +216,7 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file,
{
char filepath[PATH_MAX];
- if(alpm_list_find_str(skip_remove, file->name)) {
+ if(alpm_list_find(skip_remove, file->name, _alpm_fnmatch)) {
/* return success because we will never actually remove this file */
return 1;
}
@@ -251,7 +251,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_str(skip_remove, fileobj->name)) {
+ if(alpm_list_find(skip_remove, fileobj->name, _alpm_fnmatch)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"%s is in skip_remove, skipping removal\n", file);
return 1;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index cbc5bdfb..5070cb93 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -34,6 +34,7 @@
#include <limits.h>
#include <sys/wait.h>
#include <locale.h> /* setlocale */
+#include <fnmatch.h>
/* libarchive */
#include <archive.h>
@@ -1188,6 +1189,11 @@ int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int a
return ret;
}
+int _alpm_fnmatch(const void *pattern, const void *string)
+{
+ return fnmatch(pattern, string, 0);
+}
+
#ifndef HAVE_STRNDUP
/* A quick and dirty implementation derived from glibc */
static size_t strnlen(const char *s, size_t max)
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 61dc8e55..df16543c 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -140,6 +140,7 @@ alpm_time_t _alpm_parsedate(const char *line);
int _alpm_raw_cmp(const char *first, const char *second);
int _alpm_raw_ncmp(const char *first, const char *second, size_t max);
int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int amode);
+int _alpm_fnmatch(const void *pattern, const void *string);
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);