From b4317a740ac2d4f5e4d1aa56a97171c52be70d02 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Thu, 16 Jul 2009 14:55:45 +0200 Subject: Change the interface for target loading -int alpm_trans_sysupgrade(int enable_downgrade); -int alpm_trans_sync(char *target); -int alpm_trans_add(char *target); -int alpm_trans_remove(char *target); +int alpm_sync_sysupgrade(int enable_downgrade); +int alpm_sync_target(char *target); +int alpm_sync_dbtarget(char *db, char *target); +int alpm_add_target(char *target); +int alpm_remove_target(char *target); * functions renaming * add new sync_dbtarget which allows to specify the db * repo/ syntax handling is moved to frontend ( should implement FS#15141) * group handling is moved to backend ( see http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html ) --- src/pacman/remove.c | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) (limited to 'src/pacman/remove.c') diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 258460c8..ced4e12f 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -57,44 +57,17 @@ 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 *targ = alpm_list_getdata(i); - if(alpm_trans_remove(targ) == -1) { - if(pm_errno == PM_ERR_PKG_NOT_FOUND) { - printf(_("%s not found, searching for group...\n"), targ); - pmgrp_t *grp = alpm_db_readgrp(db_local, targ); - if(grp == NULL) { - pm_fprintf(stderr, PM_LOG_ERROR, _("'%s': not found in local db\n"), targ); - retval = 1; - goto cleanup; - } else { - alpm_list_t *p, *pkgnames = NULL; - /* convert packages to package names */ - for(p = alpm_grp_get_pkgs(grp); p; p = alpm_list_next(p)) { - pmpkg_t *pkg = alpm_list_getdata(p); - pkgnames = alpm_list_add(pkgnames, (void *)alpm_pkg_get_name(pkg)); - } - printf(_(":: group %s:\n"), targ); - list_display(" ", pkgnames); - int all = yesno(_(" Remove whole content?")); - for(p = pkgnames; p; p = alpm_list_next(p)) { - char *pkgn = alpm_list_getdata(p); - if(all || yesno(_(":: Remove %s from group %s?"), pkgn, targ)) { - if(alpm_trans_remove(pkgn) == -1) { - pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, - alpm_strerrorlast()); - retval = 1; - alpm_list_free(pkgnames); - goto cleanup; - } - } - } - alpm_list_free(pkgnames); - } - } else { - pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast()); - retval = 1; - goto cleanup; - } + char *target = alpm_list_getdata(i); + char *targ = strchr(target, '/'); + if(targ && strncmp(target, "local", 5) == 0) { + targ++; + } else { + targ = target; + } + if(alpm_remove_target(targ) == -1) { + pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", targ, alpm_strerrorlast()); + retval = 1; + goto cleanup; } } -- cgit v1.2.3