2011/8/15 Michel Hermier <[email protected]> > Hi, > 2 comments: > - You forgot to change the --help and manual (maybe --regex is should go > to general options since it's quite usable to any target but upgrade). > Vmiklos comment on this? >
you're right, I checked pacman-g2 man page, and it was already there as general option (maybe we have to change this?), so I forgot to check the --help, for now I've fixed the -R help to display that (if we'll have it as general option we can move later).
From eb94d0e951fdd81dfa54ee0797c59febfc6a3c77 Mon Sep 17 00:00:00 2001 From: Melko <[email protected]> Date: Sat, 13 Aug 2011 16:26:20 +0200 Subject: [PATCH] pacman -R: enable --regex option --- src/pacman-g2/pacman-g2.c | 1 + src/pacman-g2/remove.c | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c index 0436abd..d67bf4b 100644 --- a/src/pacman-g2/pacman-g2.c +++ b/src/pacman-g2/pacman-g2.c @@ -134,6 +134,7 @@ static void usage(int op, char *myname) printf(_(" -k, --dbonly only remove database entry, do not remove files\n")); printf(_(" -n, --nosave remove configuration files as well\n")); printf(_(" -s, --recursive remove dependencies also (that won't break packages)\n")); + printf(_(" --regex treat targets as regexs if no package found\n")); } else if(op == PM_OP_UPGRADE) { if(config->flags & PM_TRANS_FLAG_FRESHEN) { printf(_("usage: %s {-F --freshen} [options] <file>\n"), myname); diff --git a/src/pacman-g2/remove.c b/src/pacman-g2/remove.c index 2641661..08fef54 100644 --- a/src/pacman-g2/remove.c +++ b/src/pacman-g2/remove.c @@ -89,9 +89,30 @@ int removepkg(list_t *targets) /* and add targets to it */ for(i = finaltargs; i; i = i->next) { if(pacman_trans_addtarget(i->data) == -1) { - ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, pacman_strerror(pm_errno)); - retval = 1; - goto cleanup; + int found=0; + /* check for regex */ + if(config->regex) { + PM_LIST *k; + for(k = pacman_db_getpkgcache(db_local); k; k = pacman_list_next(k)) { + PM_PKG *p = pacman_list_getdata(k); + char *pkgname = pacman_pkg_getinfo(p, PM_PKG_NAME); + int match = pacman_reg_match(pkgname, i->data); + if(match == -1) { + ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, pacman_strerror(pm_errno)); + retval = 1; + goto cleanup; + } + else if(match) { + pacman_trans_addtarget(pkgname); + found++; + } + } + } + if(!found) { + ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, pacman_strerror(pm_errno)); + retval = 1; + goto cleanup; + } } } -- 1.7.6
_______________________________________________ Frugalware-devel mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-devel
