From 7285c012b92b93fc7a508491c7d4833219a9ddbd Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Tue, 22 Feb 2011 08:30:12 +0100 Subject: [PATCH] Match wildcards in Ignore*, HoldPkg Signed-off-by: Sascha Kruse --- doc/pacman.conf.5.txt | 5 +++-- lib/libalpm/package.c | 16 ++++++++++++---- src/pacman/remove.c | 10 +++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index cb4c589..e7169c6 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -78,10 +78,11 @@ Options *HoldPkg =* package ...:: If a user tries to '\--remove' a package that's listed in `HoldPkg`, pacman will ask for confirmation before proceeding. + Shell-like wildcards will get expanded. *IgnorePkg =* package ...:: Instructs pacman to ignore any upgrades for this package when performing - a '\--sysupgrade'. + a '\--sysupgrade'. Shell-like wildcards will get expanded. *SyncFirst =* package ...:: Instructs pacman to check for newer version of these packages before any @@ -94,7 +95,7 @@ Options *IgnoreGroup =* group ...:: Instructs pacman to ignore any upgrades for all packages in this - group when performing a '\--sysupgrade'. + group when performing a '\--sysupgrade'. Shell-like wildcards will get expanded. *Include =* path:: Include another config file. This file can include repositories or diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 0a1102c..818a0c5 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -30,6 +30,7 @@ #include #include #include +#include /* libalpm */ #include "package.h" @@ -559,6 +560,13 @@ pmpkg_t *_alpm_pkg_find(alpm_list_t *haystack, const char *needle) return(NULL); } +static int fnmatch_cmp(const void *pattern, const void *string) +{ + const char *pat = pattern; + const char *str = string; + return fnmatch(pat, str, 0); +} + /** Test if a package should be ignored. * * Checks if the package is ignored via IgnorePkg, or if the package is @@ -573,14 +581,14 @@ int _alpm_pkg_should_ignore(pmpkg_t *pkg) alpm_list_t *groups = NULL; /* first see if the package is ignored */ - if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) { + if(alpm_list_find(handle->ignorepkg, alpm_pkg_get_name(pkg), fnmatch_cmp)) { return(1); } /* next see if the package is in a group that is ignored */ - for(groups = handle->ignoregrp; groups; groups = alpm_list_next(groups)) { - char *grp = (char *)alpm_list_getdata(groups); - if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) { + for(groups = alpm_pkg_get_groups(pkg); groups; groups = alpm_list_next(groups)) { + const char *group = alpm_list_getdata(groups); + if(alpm_list_find(handle->ignoregrp, group, fnmatch_cmp)) { return(1); } } diff --git a/src/pacman/remove.c b/src/pacman/remove.c index fb02e24..019e2a7 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -61,6 +62,13 @@ static int remove_target(char *target) return(0); } +static int fnmatch_cmp(const void *pattern, const void *string) +{ + const char *pat = pattern; + const char *str = string; + return fnmatch(pat, str, 0); +} + /** * @brief Remove a specified list of packages. * @@ -131,7 +139,7 @@ int pacman_remove(alpm_list_t *targets) int holdpkg = 0; for(i = alpm_trans_get_remove(); i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); - if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) { + if(alpm_list_find(config->holdpkg, alpm_pkg_get_name(pkg), fnmatch_cmp)) { pm_printf(PM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"), alpm_pkg_get_name(pkg)); holdpkg = 1; -- 1.7.4.1