summaryrefslogtreecommitdiffstats
path: root/src/pacman/remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/remove.c')
-rw-r--r--src/pacman/remove.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 1cdf5d36..3de57695 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -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,6 +30,11 @@
#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;
@@ -54,7 +58,7 @@ static int remove_target(const char *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,28 @@ 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);
+ const char *pkg = i->data;
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 +140,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;