add fnmatch support for HoldPkg
Adds test remove031. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
This commit is contained in:
parent
902305f163
commit
10241a6d76
3 changed files with 20 additions and 2 deletions
|
@ -86,7 +86,8 @@ Options
|
||||||
|
|
||||||
*HoldPkg =* package ...::
|
*HoldPkg =* package ...::
|
||||||
If a user tries to '\--remove' a package that's listed in `HoldPkg`,
|
If a user tries to '\--remove' a package that's listed in `HoldPkg`,
|
||||||
pacman will ask for confirmation before proceeding.
|
pacman will ask for confirmation before proceeding. Shell-style glob
|
||||||
|
patterns are allowed.
|
||||||
|
|
||||||
*IgnorePkg =* package ...::
|
*IgnorePkg =* package ...::
|
||||||
Instructs pacman to ignore any upgrades for this package when performing
|
Instructs pacman to ignore any upgrades for this package when performing
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <fnmatch.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -31,6 +32,11 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
|
static int fnmatch_cmp(const void *pattern, const void *string)
|
||||||
|
{
|
||||||
|
return fnmatch(pattern, string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int remove_target(const char *target)
|
static int remove_target(const char *target)
|
||||||
{
|
{
|
||||||
alpm_pkg_t *pkg;
|
alpm_pkg_t *pkg;
|
||||||
|
@ -134,7 +140,7 @@ int pacman_remove(alpm_list_t *targets)
|
||||||
int holdpkg = 0;
|
int holdpkg = 0;
|
||||||
for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) {
|
for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) {
|
||||||
alpm_pkg_t *pkg = i->data;
|
alpm_pkg_t *pkg = i->data;
|
||||||
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(ALPM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"),
|
pm_printf(ALPM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"),
|
||||||
alpm_pkg_get_name(pkg));
|
alpm_pkg_get_name(pkg));
|
||||||
holdpkg = 1;
|
holdpkg = 1;
|
||||||
|
|
11
test/pacman/tests/remove031.py
Normal file
11
test/pacman/tests/remove031.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
self.description = "Remove a package in HoldPkg"
|
||||||
|
|
||||||
|
p1 = pmpkg("foopkg")
|
||||||
|
self.addpkg2db("local", p1)
|
||||||
|
|
||||||
|
self.option["HoldPkg"] = ["???pkg"]
|
||||||
|
|
||||||
|
self.args = "-R %s" % p1.name
|
||||||
|
|
||||||
|
self.addrule("PACMAN_RETCODE=1")
|
||||||
|
self.addrule("PKG_EXIST=foopkg")
|
Loading…
Add table
Reference in a new issue