Hi,
I made a patch to enable the --regex option with pacman -R.
Seems to work fine here, but please review it.

Melko
From f63c4d4643276bbcd4b8dff68d782d10fb73bc35 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/remove.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

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

Reply via email to