[pacman-dev] [psuedo-patch] First attempt at FS#3492 and fix a copy-paste error

Dan McGee dpmcgee at gmail.com
Thu Jan 25 01:03:37 EST 2007


If you are interested in fixing this bug, let me know. Otherwise I'm
going to put this on the back burner for a bit and hopefully get back
to it later. If you do want to work on it and have questions, shoot me
an email or talk to me on IRC when I'm on (as toofishes).

* start to fixing FS #3492, fixed typecasts, clarified actions,
  added notes to code but not actual removal code that is
  necessary, as I'm not sure what the best plan of action is.
* copy and paste error, "resolving deps" -> "cleaning up"

Signed-off-by: Dan McGee <dpmcgee at gmail.com>

#
# old_revision [8b849d94fb042fa6b42cad8ff6938fe27406dadb]
#
# patch "lib/libalpm/add.c"
#  from [5340d7f7768bf9d8ec37b907a422350c510c8f39]
#    to [2e8010675af78d63c5f57b2eb7c71b0f4a2db455]
#
# patch "src/pacman/trans.c"
#  from [1f02954b56601d065e49e0c52c92e3af395c65fd]
#    to [41d5b28cb0602a8b59368da1b5b3ef1874048af1]
#
============================================================
--- lib/libalpm/add.c	5340d7f7768bf9d8ec37b907a422350c510c8f39
+++ lib/libalpm/add.c	2e8010675af78d63c5f57b2eb7c71b0f4a2db455
@@ -210,10 +210,9 @@ error:
 	return(-1);
 }

-
-static int name_cmp(const void *p1, const void *p2)
+static int pkg_cmp(const void *p1, const void *p2)
 {
-	return(strcmp(((pmpkg_t *)p1)->name, (const char *)p2));
+	return(strcmp(((pmdepmissing_t *)p1)->target, ((pmdepmissing_t
*)p2)->target));
 }

 int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
@@ -253,11 +252,26 @@ int _alpm_add_prepare(pmtrans_t *trans,
 			/* Attempt to resolve conflicts */
 			QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target,
miss->depend.name, NULL, &skip_this);
 			if(skip_this) {
-				pmpkg_t **pkg = NULL;
-				lp = alpm_list_remove(lp, (void *)miss->depend.name, name_cmp,
(void **)pkg);
-				FREEPKG(*pkg);
+				pmdepmissing_t *pkg = NULL;
+				lp = alpm_list_remove(lp, (void *)miss, pkg_cmp, (void*)&pkg);
+				/* TODO: We remove the conflict from the list but never actually remove
+				 * the package. Need to do this to fix FS #3492. The sync code should
+				 * provide an example of how to do this, as it handles replaces and
+				 * removes. We run into problems because we do a file conflict check
+				 * below and it fails there. A force flag will skip that part, but
+				 * still not remove the original package designated here for removal.
+				 * Better yet, dump all this shitty duplicate code and somehow combine
+				 * it with the sync code. */
+				FREE(pkg);
+				if(lp == NULL) {
+					break;
+				}
 			}
 		}
+		/* Removal code should go here, as described above. Instead of simply
+		 * removing items, perhaps throw them in another list to be removed, then
+		 * proceed as sync.c would? I'm not sure because I'm not familiar enough
+		 * with the codebase. */
 		if(lp != NULL) {
 			if(data) {
 				*data = lp;
@@ -283,8 +297,10 @@ int _alpm_add_prepare(pmtrans_t *trans,
 	_alpm_log(PM_LOG_FLOW1, _("cleaning up"));
 	for (lp=trans->packages; lp!=NULL; lp=lp->next) {
 		info=(pmpkg_t *)lp->data;
+		fprintf(stderr, "package: %s %s\n", info->name, info->version); /* DEBUG */
 		for (rmlist=info->removes; rmlist!=NULL; rmlist=rmlist->next) {
 			snprintf(rm_fname, PATH_MAX, "%s%s", handle->root, (char *)rmlist->data);
+			fprintf(stderr, "  removing %s\n", rm_fname); /* DEBUG */
 			remove(rm_fname);
 		}
 	}
============================================================
--- src/pacman/trans.c	1f02954b56601d065e49e0c52c92e3af395c65fd
+++ src/pacman/trans.c	41d5b28cb0602a8b59368da1b5b3ef1874048af1
@@ -60,7 +60,7 @@ void cb_trans_evt(pmtransevt_t event, vo
 			}
 			break;
 		case PM_TRANS_EVT_CLEANUP_START:
-			pm_fprintf(stderr, NL, _("resolving dependencies... "));
+			pm_fprintf(stderr, NL, _("cleaning up... "));
 			break;
 		case PM_TRANS_EVT_RESOLVEDEPS_START:
 			pm_fprintf(stderr, NL, _("resolving dependencies... "));




More information about the pacman-dev mailing list