[pacman-dev] CVS update of pacman-lib/src/pacman (sync.c)

Aaron Griffin aaron at archlinux.org
Thu Feb 15 20:58:51 EST 2007


    Date: Thursday, February 15, 2007 @ 20:58:51
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib/src/pacman

Modified: sync.c (1.110 -> 1.111)

* Bugfix for FS#6427: Allow -Si to use "repository/package" syntax
* Also don't stop searching when one package is not found (output and continue)


--------+
 sync.c |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 52 insertions(+), 10 deletions(-)


Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.110 pacman-lib/src/pacman/sync.c:1.111
--- pacman-lib/src/pacman/sync.c:1.110	Wed Feb 14 14:35:41 2007
+++ pacman-lib/src/pacman/sync.c	Thu Feb 15 20:58:51 2007
@@ -318,24 +318,66 @@
 
 	if(targets) {
 		for(i = targets; i; i = alpm_list_next(i)) {
-			int found = 0;
+			pmdb_t *db = NULL;
+			int foundpkg = 0;
 
-			for(j = syncs; j && !found; j = alpm_list_next(j)) {
-				pmdb_t *db = alpm_list_getdata(j);
+			char target[512]; /* TODO is this enough space? */
+			char *repo = NULL, *pkgstr = NULL;
 
-				for(k = alpm_db_getpkgcache(db); !found && k; k = alpm_list_next(k)) {
+			strncpy(target, i->data, 512);
+			pkgstr = strchr(target, '/');
+			if(pkgstr) {
+				repo = target;
+				*pkgstr = '\0';
+				++pkgstr;
+
+				for(j = syncs; j; j = alpm_list_next(j)) {
+					db = alpm_list_getdata(j);
+					if(strcmp(repo, alpm_db_get_name(db)) == 0) {
+						break;
+					}
+					db = NULL;
+				}
+				
+				if(!db) {
+					ERR(NL, _("repository '%s' does not exist"), repo);
+					return(1);
+				}
+				
+				for(k = alpm_db_getpkgcache(db); k; k = alpm_list_next(k)) {
 					pmpkg_t *pkg = alpm_list_getdata(k);
 
-					if(!strcmp(alpm_pkg_get_name(pkg), alpm_list_getdata(i))) {
+					if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
 						dump_pkg_sync(pkg, alpm_db_get_name(db));
 						MSG(NL, "\n");
-						found = 1;
+						foundpkg = 1;
+						break;
 					}
 				}
-			}
-			if(!found) {
-				ERR(NL, _("package \"%s\" was not found.\n"), (char *)i->data);
-				break;
+				
+				if(!foundpkg) {
+					ERR(NL, _("package '%s' was not found in repository '%s'"), pkgstr, repo);
+				}
+			} else {
+				pkgstr = target;
+						
+				for(j = syncs; j; j = alpm_list_next(j)) {
+					pmdb_t *db = alpm_list_getdata(j);
+
+					for(k = alpm_db_getpkgcache(db); k; k = alpm_list_next(k)) {
+						pmpkg_t *pkg = alpm_list_getdata(k);
+
+						if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
+							dump_pkg_sync(pkg, alpm_db_get_name(db));
+							MSG(NL, "\n");
+							foundpkg = 1;
+							break;
+						}
+					}
+				}
+				if(!foundpkg) {
+					ERR(NL, _("package '%s' was not found."), pkgstr);
+				}
 			}
 		}
 	} else {




More information about the pacman-dev mailing list