diff options
Diffstat (limited to 'src/pacman/remove.c')
-rw-r--r-- | src/pacman/remove.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/pacman/remove.c b/src/pacman/remove.c index e7453c8d..472adb52 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -1,7 +1,7 @@ /* * remove.c * - * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org> + * Copyright (c) 2006-2012 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * * This program is free software; you can redistribute it and/or modify @@ -18,8 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" - +#include <fnmatch.h> #include <stdlib.h> #include <stdio.h> @@ -31,10 +30,15 @@ #include "util.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) { alpm_pkg_t *pkg; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); alpm_list_t *p; if((pkg = alpm_db_get_pkg(db_local, target)) != NULL) { @@ -48,13 +52,13 @@ static int remove_target(const char *target) } /* fallback to group */ - alpm_group_t *grp = alpm_db_readgroup(db_local, target); + alpm_group_t *grp = alpm_db_get_group(db_local, target); if(grp == NULL) { pm_printf(ALPM_LOG_ERROR, _("target not found: %s\n"), target); return -1; } for(p = grp->packages; p; p = alpm_list_next(p)) { - pkg = alpm_list_getdata(p); + pkg = p->data; if(alpm_remove_pkg(config->handle, pkg) == -1) { pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target, alpm_strerror(alpm_errno(config->handle))); @@ -89,7 +93,7 @@ int pacman_remove(alpm_list_t *targets) /* Step 1: add targets to the created transaction */ for(i = targets; i; i = alpm_list_next(i)) { - char *target = alpm_list_getdata(i); + char *target = i->data; char *targ = strchr(target, '/'); if(targ && strncmp(target, "local", 5) == 0) { targ++; @@ -98,25 +102,22 @@ int pacman_remove(alpm_list_t *targets) } if(remove_target(targ) == -1) { retval = 1; - goto cleanup; } } + if(retval == 1) { + goto cleanup; + } + /* Step 2: prepare the transaction based on its type, targets and flags */ if(alpm_trans_prepare(config->handle, &data) == -1) { - enum _alpm_errno_t err = alpm_errno(config->handle); + alpm_errno_t err = alpm_errno(config->handle); pm_printf(ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), alpm_strerror(err)); switch(err) { - case ALPM_ERR_PKG_INVALID_ARCH: - for(i = data; i; i = alpm_list_next(i)) { - char *pkg = alpm_list_getdata(i); - printf(_(":: package %s does not have a valid architecture\n"), pkg); - } - break; case ALPM_ERR_UNSATISFIED_DEPS: for(i = data; i; i = alpm_list_next(i)) { - alpm_depmissing_t *miss = alpm_list_getdata(i); + alpm_depmissing_t *miss = i->data; char *depstring = alpm_dep_compute_string(miss->depend); printf(_(":: %s: requires %s\n"), miss->target, depstring); free(depstring); @@ -133,8 +134,8 @@ int pacman_remove(alpm_list_t *targets) /* Search for holdpkg in target list */ int holdpkg = 0; for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) { - alpm_pkg_t *pkg = alpm_list_getdata(i); - if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) { + alpm_pkg_t *pkg = i->data; + 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"), alpm_pkg_get_name(pkg)); holdpkg = 1; |