[pacman-dev] CVS update of pacman-lib (7 files)

Aaron Griffin aaron at archlinux.org
Mon Feb 26 03:43:02 EST 2007


    Date: Monday, February 26, 2007 @ 03:43:02
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib

Modified: scripts/makepkg (1.53 -> 1.54) src/pacman/deptest.c (1.14 -> 1.15)
          src/pacman/pacman.c (1.101 -> 1.102)
          src/pacman/query.c (1.25 -> 1.26)
          src/pacman/remove.c (1.28 -> 1.29)
          src/pacman/sync.c (1.114 -> 1.115) src/pacman/util.c (1.29 -> 1.30)

* pacman hidden arguments: removed -Y and -D.  -T is the only hidden arg now, to
  be used in place of -Y.  Also, -D was rather silly, as it does mostly what -S
  does.
* Cleaned up pacman_deptest - removed the goofy faketarget stuff (NEEDS testing
  still)
* libalpm function renames


----------------------+
 scripts/makepkg      |   10 +--
 src/pacman/deptest.c |  131 ++++++-------------------------------------------
 src/pacman/pacman.c  |   11 ----
 src/pacman/query.c   |    8 +-
 src/pacman/remove.c  |    4 -
 src/pacman/sync.c    |   12 ++--
 src/pacman/util.c    |    9 ++-
 7 files changed, 43 insertions(+), 142 deletions(-)


Index: pacman-lib/scripts/makepkg
diff -u pacman-lib/scripts/makepkg:1.53 pacman-lib/scripts/makepkg:1.54
--- pacman-lib/scripts/makepkg:1.53	Fri Feb 23 21:11:52 2007
+++ pacman-lib/scripts/makepkg	Mon Feb 26 03:43:02 2007
@@ -184,7 +184,7 @@
 
 	pmout=$(pacman $PACMAN_OPTS -T $*)
 	ret=$?
-	if [ $ret -eq 127 ]; then #unresolved deps
+	if [ $ret -eq 1 ]; then #unresolved deps
 		#strip out the pacman prefix from "requires: xyz"
 		echo $pmout | sed 's|requires:||g'
 	elif [ $ret -ne 0 ]; then
@@ -211,8 +211,8 @@
 				FAKEROOTKEY2=$FAKEROOTKEY
 				unset FAKEROOTKEY
 			fi
-			sudo pacman $PACMAN_OPTS -D $deplist
-			if [ "$?" = "127" ]; then
+			sudo pacman $PACMAN_OPTS -S $deplist
+			if [ $? -eq 1 ]; then
 				error "Failed to install missing dependencies."
 				exit 1
 			fi
@@ -223,8 +223,8 @@
 		elif [ "$DEP_BIN" = "1" ]; then
 			# install missing deps from binary packages (using pacman -S)
 			msg "Installing missing dependencies..."
-			pacman $PACMAN_OPTS -D $deplist
-			if [ "$?" = "127" ]; then
+			pacman $PACMAN_OPTS -S $deplist
+			if [ $? -eq 1 ]; then
 				error "Failed to install missing dependencies."
 				exit 1
 			fi
Index: pacman-lib/src/pacman/deptest.c
diff -u pacman-lib/src/pacman/deptest.c:1.14 pacman-lib/src/pacman/deptest.c:1.15
--- pacman-lib/src/pacman/deptest.c:1.14	Mon Feb 12 01:44:00 2007
+++ pacman-lib/src/pacman/deptest.c	Mon Feb 26 03:43:02 2007
@@ -36,131 +36,36 @@
 
 extern config_t *config;
 
-/* TODO this function is fairly messy, with the obscure return codes and the odd
- * 'dummy' packages and all these messy FREELISTs of synctargs
- */
 int pacman_deptest(alpm_list_t *targets)
 {
-	alpm_list_t *data, *i;
-	char *str;
 	int retval = 0;
+	pmdb_t *local;
+	pmpkg_t *pkg;
+	alpm_list_t *i, *provides;
 
 	if(targets == NULL) {
 		return(0);
 	}
+	
+	local = alpm_option_get_localdb();
 
-	/* we create a transaction to hold a dummy package to be able to use
-	 * deps checkings from alpm_trans_prepare() */
-	if(alpm_trans_init(PM_TRANS_TYPE_ADD, 0, NULL, NULL, NULL) == -1) {
-		ERR(NL, "%s", alpm_strerror(pm_errno));
-		if(pm_errno == PM_ERR_HANDLE_LOCK) {
-			MSG(NL, _("       if you're sure a package manager is not already running,\n"
-			  			"       you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
-		}
-		return(1);
-	}
-
-	/* We use a hidden facility from alpm_trans_addtarget() to add a dummy
-	 * target to the transaction (see the library code for details).
-	 * It allows us to use alpm_trans_prepare() to check dependencies of the
-	 * given target.
-	 */
-	str = (char *)malloc(strlen("name=dummy|version=1.0-1")+1);
-	if(str == NULL) {
-		ERR(NL, _("memory allocation failure\n"));
-		retval = 1;
-		goto cleanup;
-	}
-	strcpy(str, "name=dummy|version=1.0-1");
 	for(i = targets; i; i = alpm_list_next(i)) {
-		const char *targ = alpm_list_getdata(i);
-		str = (char *)realloc(str, strlen(str)+8+strlen(targ)+1);
-		strcat(str, "|depend=");
-		strcat(str, targ);
-	}
-	vprint(_("add target %s\n"), str);
-	if(alpm_trans_addtarget(str) == -1) {
-		FREE(str);
-		ERR(NL, _("could not add target (%s)\n"), alpm_strerror(pm_errno));
-		retval = 1;
-		goto cleanup;
-	}
-	FREE(str);
-
-	if(alpm_trans_prepare(&data) == -1) {
-		alpm_list_t *synctargs = NULL;
-		retval = 126;
-		/* return 126 = deps were missing, but successfully resolved
-		 * return 127 = deps were missing, and failed to resolve; OR
-		 *            = deps were missing, but no resolution was attempted; OR
-		 *            = unresolvable conflicts were found
-		 */
-		switch(pm_errno) {
-			case PM_ERR_UNSATISFIED_DEPS:
-				for(i = data; i; i = alpm_list_next(i)) {
-					pmdepmissing_t *miss = alpm_list_getdata(i);
-					if(!config->op_d_resolve) {
-						MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
-						switch(alpm_dep_get_mod(miss)) {
-							case PM_DEP_MOD_ANY:
-								break;
-							case PM_DEP_MOD_EQ:
-								MSG(CL, "=%s", alpm_dep_get_version(miss));
-								break;
-							case PM_DEP_MOD_GE:
-								MSG(CL, ">=%s", alpm_dep_get_version(miss));
-								break;
-							case PM_DEP_MOD_LE:
-								MSG(CL, "<=%s", alpm_dep_get_version(miss));
-								break;
-						}
-						MSG(CL, "\n");
-					}
-					synctargs = alpm_list_add(synctargs, strdup(alpm_dep_get_name(miss)));
-				}
-				alpm_list_free(data);
-			break;
-			case PM_ERR_CONFLICTING_DEPS:
-				/* we can't auto-resolve conflicts */
-				for(i = data; i; i = alpm_list_next(i)) {
-					pmdepmissing_t *miss = alpm_list_getdata(i);
-					MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss));
-				}
-				retval = 127;
-				alpm_list_free(data);
-			break;
-			default:
-				retval = 127;
-			break;
-		}
-
-		/* attempt to resolve missing dependencies */
-		/* TODO: handle version comparators (eg, glibc>=2.2.5) */
-		if(retval == 126 && synctargs != NULL) {
-			if(alpm_trans_release() == -1) {
-				ERR(NL, _("could not release transaction (%s)"), alpm_strerror(pm_errno));
-				FREELIST(synctargs);
-				return(1);
-			}
-			if(!config->op_d_resolve || pacman_sync(synctargs) != 0) {
-				/* error (or -D not used) */
-				retval = 127;
+		const char *pkgname;
+	 
+		pkgname = alpm_list_getdata(i);
+		/* find this package in the local DB */
+		pkg = alpm_db_get_pkg(local, pkgname);
+
+		if(!pkg) {
+			/* not found, can we find anything that provides this in the local DB? */
+			provides = alpm_db_whatprovides(local, pkgname);
+			if(!provides) {
+				/* nope, must be missing */
+				MSG(NL, _("requires: %s"), pkgname);
+				retval = 1;
 			}
-			FREELIST(synctargs);
-			return(retval);
 		}
-
-		FREELIST(synctargs);
 	}
-
-cleanup:
-	if(!config->op_d_resolve) {
-		if(alpm_trans_release() == -1) {
-			ERR(NL, _("could not release transaction (%s)"), alpm_strerror(pm_errno));
-			retval = 1;
-		}
-	}
-
 	return(retval);
 }
 
Index: pacman-lib/src/pacman/pacman.c
diff -u pacman-lib/src/pacman/pacman.c:1.101 pacman-lib/src/pacman/pacman.c:1.102
--- pacman-lib/src/pacman/pacman.c:1.101	Thu Feb 22 22:40:20 2007
+++ pacman-lib/src/pacman/pacman.c	Mon Feb 26 03:43:02 2007
@@ -217,7 +217,6 @@
 	static struct option opts[] =
 	{
 		{"add",        no_argument,       0, 'A'},
-		{"resolve",    no_argument,       0, 'D'}, /* used by 'makepkg -s' */
 		{"freshen",    no_argument,       0, 'F'},
 		{"query",      no_argument,       0, 'Q'},
 		{"remove",     no_argument,       0, 'R'},
@@ -264,7 +263,7 @@
 	struct stat st;
 	unsigned short logmask;
 
-	while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
+	while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
 		if(opt < 0) {
 			break;
 		}
@@ -316,11 +315,6 @@
 				alpm_option_set_cachedir(optarg);
 				break;
 			case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
-			case 'D':
-				config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
-				config->op_d_resolve = 1;
-				config->flags |= PM_TRANS_FLAG_ALLDEPS;
-				break;
 			case 'F':
 				config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
 				config->flags |= PM_TRANS_FLAG_FRESHEN;
@@ -331,9 +325,6 @@
 			case 'T': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST); break;
 			case 'U': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE); break;
 			case 'V': config->version = 1; break;
-			case 'Y':
-				config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST);
-				break;
 			case 'b':
 				if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
 					ERR(NL, _("'%s' is not a valid db path\n"), optarg);
Index: pacman-lib/src/pacman/query.c
diff -u pacman-lib/src/pacman/query.c:1.25 pacman-lib/src/pacman/query.c:1.26
--- pacman-lib/src/pacman/query.c:1.25	Sun Feb 11 23:45:22 2007
+++ pacman-lib/src/pacman/query.c	Mon Feb 26 03:43:02 2007
@@ -153,7 +153,7 @@
 					const char *grpname;
 
 					grpname = alpm_grp_get_name(grp);
-					pkgnames = alpm_grp_get_packages(grp);
+					pkgnames = alpm_grp_get_pkgs(grp);
 
 					for(p = pkgnames; p; p = alpm_list_next(p)) {
 						MSG(NL, "%s %s\n", grpname, (char *)alpm_list_getdata(p));
@@ -162,7 +162,7 @@
 			} else {
 				pmgrp_t *grp = alpm_db_readgrp(db_local, package);
 				if(grp) {
-					alpm_list_t *p, *pkgnames = alpm_grp_get_packages(grp);
+					alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp);
 					for(p = pkgnames; p; p = alpm_list_next(p)) {
 						MSG(NL, "%s %s\n", package, (char *)alpm_list_getdata(p));
 					}
@@ -217,7 +217,7 @@
 				pkgver = alpm_pkg_get_version(tmpp);
 
 				if(config->op_q_list || config->op_q_orphans || config->op_q_foreign) {
-					info = alpm_db_readpkg(db_local, (char *)pkgname);
+					info = alpm_db_get_pkg(db_local, (char *)pkgname);
 					if(info == NULL) {
 						/* something weird happened */
 						ERR(NL, _("package \"%s\" not found\n"), pkgname);
@@ -250,7 +250,7 @@
 				}
 			}
 		} else {
-			info = alpm_db_readpkg(db_local, package);
+			info = alpm_db_get_pkg(db_local, package);
 			if(info == NULL) {
 				ERR(NL, _("package \"%s\" not found\n"), package);
 				continue;
Index: pacman-lib/src/pacman/remove.c
diff -u pacman-lib/src/pacman/remove.c:1.28 pacman-lib/src/pacman/remove.c:1.29
--- pacman-lib/src/pacman/remove.c:1.28	Thu Feb  1 01:35:30 2007
+++ pacman-lib/src/pacman/remove.c	Mon Feb 26 03:43:02 2007
@@ -53,7 +53,7 @@
 		pmgrp_t *grp = alpm_db_readgrp(db_local, alpm_list_getdata(i));
 		if(grp) {
 			int all;
-			alpm_list_t *pkgnames = alpm_grp_get_packages(grp);
+			alpm_list_t *pkgnames = alpm_grp_get_pkgs(grp);
 
 			MSG(NL, _(":: group %s:\n"), alpm_grp_get_name(grp));
 			list_display("   ", pkgnames);
@@ -117,7 +117,7 @@
 	if(config->flags & PM_TRANS_FLAG_RECURSE || config->flags & PM_TRANS_FLAG_CASCADE) {
 		/* list transaction targets */
 		alpm_list_t *lst = NULL;
-		for(i = alpm_trans_get_packages(); i; i = alpm_list_next(i)) {
+		for(i = alpm_trans_get_pkgs(); i; i = alpm_list_next(i)) {
 			pmpkg_t *pkg = alpm_list_getdata(i);
 			lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
 		}
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.114 pacman-lib/src/pacman/sync.c:1.115
--- pacman-lib/src/pacman/sync.c:1.114	Fri Feb 23 02:50:35 2007
+++ pacman-lib/src/pacman/sync.c	Mon Feb 26 03:43:02 2007
@@ -292,7 +292,7 @@
 				if(grp) {
 					/* TODO this should be a lot cleaner, why two outputs? */
 					MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
-					list_display("   ", alpm_grp_get_packages(grp));
+					list_display("   ", alpm_grp_get_pkgs(grp));
 				}
 			}
 		}
@@ -305,7 +305,7 @@
 
 				MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
 				if(grp && level > 1) {
-					list_display("   ", alpm_grp_get_packages(grp));
+					list_display("   ", alpm_grp_get_pkgs(grp));
 				}
 			}
 		}
@@ -510,10 +510,10 @@
 		 * this can prevent some of the "syntax error" problems users can have
 		 * when sysupgrade'ing with an older version of pacman.
 		 */
-		data = alpm_trans_get_packages();
+		data = alpm_trans_get_pkgs();
 		for(i = data; i; i = alpm_list_next(i)) {
 			pmsyncpkg_t *sync = alpm_list_getdata(i);
-			pmpkg_t *spkg = alpm_sync_get_package(sync);
+			pmpkg_t *spkg = alpm_sync_get_pkg(sync);
 			if(strcmp("pacman", alpm_pkg_get_name(spkg)) == 0 && alpm_list_count(data) > 1) {
 				MSG(NL, _("\n:: pacman has detected a newer version of the \"pacman\" package.\n"));
 				MSG(NL, _(":: It is recommended that you allow pacman to upgrade itself\n"));
@@ -567,7 +567,7 @@
 						found++;
 						MSG(NL, _(":: group %s:\n"), targ);
 						/* remove dupe entries in case a package exists in multiple repos */
-						alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_packages(grp));
+						alpm_list_t *pkgs = alpm_list_remove_dupes(alpm_grp_get_pkgs(grp));
 						list_display("   ", pkgs);
 						if(yesno(_(":: Install whole content? [Y/n] "))) {
 							for(k = pkgs; k; k = alpm_list_next(k)) {
@@ -659,7 +659,7 @@
 		goto cleanup;
 	}
 
-	packages = alpm_trans_get_packages();
+	packages = alpm_trans_get_pkgs();
 	if(packages == NULL) {
 		/* nothing to do: just exit without complaining */
 		MSG(NL, _(" local database is up to date\n"));
Index: pacman-lib/src/pacman/util.c
diff -u pacman-lib/src/pacman/util.c:1.29 pacman-lib/src/pacman/util.c:1.30
--- pacman-lib/src/pacman/util.c:1.29	Sat Feb 10 04:34:59 2007
+++ pacman-lib/src/pacman/util.c	Mon Feb 26 03:43:02 2007
@@ -274,7 +274,7 @@
 
 	for(i = syncpkgs; i; i = alpm_list_next(i)) {
 		pmsyncpkg_t *sync = alpm_list_getdata(i);
-		pmpkg_t *pkg = alpm_sync_get_package(sync);
+		pmpkg_t *pkg = alpm_sync_get_pkg(sync);
 
 		/* If this sync record is a replacement, the data member contains
 		 * a list of packages to be removed due to the package that is being
@@ -381,9 +381,14 @@
 	const unsigned short chomp = alpm_option_get_chomp();
 	const unsigned int hashlen = proglen - 8;
 	const unsigned int hash = percent * hashlen / 100;
-	unsigned int lasthash = 0, mouth = 0;
+	static unsigned int lasthash = 0, mouth = 0;
 	unsigned int i;
 
+	if(percent == 0) {
+		lasthash = 0;
+		mouth = 0;
+	}
+
 	printf(" [");
 	for(i = hashlen; i > 1; --i) {
 		/* if special progress bar enabled */




More information about the pacman-dev mailing list