aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2009-08-11 22:05:39 +0000
committerJason Woodward2009-08-11 22:12:51 +0000
commit0b5deae5a1b10a92cc5d41c9ce61452751f6d495 (patch)
tree70a21c96cde3a8bd1d003ee228697522bc50a56c
parentf9f69604360f57cf4292837bcd14b1e7e7a2cf05 (diff)
downloadslapt-get-0b5deae5a1b10a92cc5d41c9ce61452751f6d495.tar.gz
updated conflict detection so that multiple conflicts are handled correctly (thanks Steve)
-rw-r--r--ChangeLog2
-rw-r--r--src/action.c62
-rw-r--r--src/transaction.c26
-rw-r--r--src/transaction.h2
4 files changed, 54 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index 4bda1d5..86c1ed2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
0.10.1d Aug 11, 2009
+ * updated conflict detection so that multiple conflicts are handled
+ correctly (thanks Steve)
* do not print empty strings as suggestions
* free priority strings and resources when parsing is complete
* updated Greek translation from George Vlahavas
diff --git a/src/action.c b/src/action.c
index 4992021..13bf5d3 100644
--- a/src/action.c
+++ b/src/action.c
@@ -85,16 +85,17 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config,
if ( slapt_add_deps_to_trans(global_config,tran,avail_pkgs,
installed_pkgs,pkg) == 0 ) {
- slapt_pkg_info_t *conflicted_pkg = NULL;
-
- /* if there is a conflict, we schedule the conflict for removal */
- if ( (conflicted_pkg = slapt_is_conflicted(tran,avail_pkgs,
- installed_pkgs,
- pkg)) != NULL
- && global_config->ignore_dep != SLAPT_TRUE
- ) {
- slapt_add_remove_to_transaction(tran,conflicted_pkg);
+
+ struct slapt_pkg_list *conflicts = slapt_is_conflicted(tran,avail_pkgs, installed_pkgs, pkg);
+
+ /* if there are conflicts, we schedule the conflicts for removal */
+ if (conflicts->pkg_count > 0 && global_config->ignore_dep != SLAPT_TRUE) {
+ unsigned int cindex = 0;
+ for (cindex = 0; cindex < conflicts->pkg_count;cindex++) {
+ slapt_add_remove_to_transaction(tran,conflicts->pkgs[cindex]);
+ }
}
+ slapt_free_pkg_list(conflicts);
slapt_add_install_to_transaction(tran,pkg);
} else {
@@ -113,16 +114,17 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config,
if ( slapt_add_deps_to_trans(global_config,tran,avail_pkgs,
installed_pkgs,pkg) == 0 ) {
- slapt_pkg_info_t *conflicted_pkg = NULL;
-
- if ( (conflicted_pkg = slapt_is_conflicted(tran,avail_pkgs,
- installed_pkgs,
- pkg)) != NULL
- && global_config->ignore_dep != SLAPT_TRUE
- ) {
- slapt_add_remove_to_transaction(tran,conflicted_pkg);
+
+ struct slapt_pkg_list *conflicts = slapt_is_conflicted(tran,avail_pkgs,
+ installed_pkgs, pkg);
+ if (conflicts->pkg_count > 0 && global_config->ignore_dep != SLAPT_TRUE) {
+ unsigned int cindex = 0;
+ for (cindex = 0;cindex < conflicts->pkg_count;cindex++) {
+ slapt_add_remove_to_transaction(tran,conflicts->pkgs[cindex]);
+ }
}
slapt_add_upgrade_to_transaction(tran,installed_pkg,pkg);
+ slapt_free_pkg_list(conflicts);
} else {
printf(gettext("Excluding %s, use --ignore-dep to override\n"),
@@ -540,15 +542,14 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
if ( slapt_is_excluded(global_config,slapt_upgrade_pkg) == 1 ) {
slapt_add_exclude_to_transaction(tran,slapt_upgrade_pkg);
} else {
+ struct slapt_pkg_list *conflicts = slapt_is_conflicted(tran,avail_pkgs,installed_pkgs,
+ slapt_upgrade_pkg);
/* add install if all deps are good and it doesn't have conflicts */
if (
(slapt_add_deps_to_trans(global_config,tran,avail_pkgs,
installed_pkgs,slapt_upgrade_pkg) == 0)
- && ( slapt_is_conflicted(tran,avail_pkgs,installed_pkgs,
- slapt_upgrade_pkg) == NULL
- && global_config->ignore_dep != SLAPT_TRUE
- )
+ && ( conflicts->pkg_count == 0 && global_config->ignore_dep != SLAPT_TRUE)
) {
slapt_add_install_to_transaction(tran,slapt_upgrade_pkg);
} else {
@@ -558,6 +559,8 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
slapt_add_exclude_to_transaction(tran,slapt_upgrade_pkg);
}
+ slapt_free_pkg_list(conflicts);
+
}
/* even if it's installed, check to see that the packages are different */
/* simply running a version comparison won't do it since sometimes the */
@@ -571,13 +574,14 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
|| slapt_is_excluded(global_config,slapt_upgrade_pkg) == 1 ) {
slapt_add_exclude_to_transaction(tran,slapt_upgrade_pkg);
} else {
+ struct slapt_pkg_list *conflicts = slapt_is_conflicted(tran,avail_pkgs,installed_pkgs,
+ slapt_upgrade_pkg);
+
/* if all deps are added and there is no conflicts, add on */
if (
(slapt_add_deps_to_trans(global_config,tran,avail_pkgs,
installed_pkgs,slapt_upgrade_pkg) == 0)
- && ( slapt_is_conflicted(tran,avail_pkgs,installed_pkgs,
- slapt_upgrade_pkg) == NULL
- && global_config->ignore_dep != SLAPT_TRUE)
+ && ( conflicts->pkg_count == 0 && global_config->ignore_dep != SLAPT_TRUE)
) {
slapt_add_upgrade_to_transaction(tran,installed_pkg,
slapt_upgrade_pkg);
@@ -587,6 +591,8 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
slapt_upgrade_pkg->name);
slapt_add_exclude_to_transaction(tran,slapt_upgrade_pkg);
}
+
+ slapt_free_pkg_list(conflicts);
}
}
@@ -669,13 +675,15 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
) {
slapt_add_exclude_to_transaction(tran,update_pkg);
} else {
+ struct slapt_pkg_list *conflicts = slapt_is_conflicted(tran,
+ avail_pkgs,installed_pkgs, update_pkg);
+
/* if all deps are added and there is no conflicts, add on */
if (
(slapt_add_deps_to_trans(global_config,tran,avail_pkgs,
installed_pkgs,update_pkg) == 0)
&& ( global_config->ignore_dep == SLAPT_TRUE
- || ( slapt_is_conflicted(tran,avail_pkgs,installed_pkgs,
- update_pkg) == NULL ))
+ || ( conflicts->pkg_count == 0 ) )
) {
slapt_add_upgrade_to_transaction(tran,installed_pkgs->pkgs[i],
update_pkg);
@@ -685,6 +693,8 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
update_pkg->name);
slapt_add_exclude_to_transaction(tran,update_pkg);
}
+
+ slapt_free_pkg_list(conflicts);
}
}
diff --git a/src/transaction.c b/src/transaction.c
index ac91858..7c26d3f 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -800,22 +800,25 @@ int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
/* loop through the deps */
for (c = 0; c < deps->pkg_count; ++c) {
+ unsigned int cindex = 0;
slapt_pkg_info_t *dep = deps->pkgs[c];
slapt_pkg_info_t *dep_installed = NULL;
- slapt_pkg_info_t *conflicted_pkg = NULL;
+ struct slapt_pkg_list *conflicts = NULL;
/*
* the dep wouldn't get this far if it where excluded,
* so we don't check for that here
*/
- conflicted_pkg =
+ conflicts =
slapt_is_conflicted(tran,avail_pkgs,installed_pkgs,dep);
- if (conflicted_pkg != NULL) {
- slapt_add_remove_to_transaction(tran,conflicted_pkg);
+ for (cindex = 0; cindex < conflicts->pkg_count;cindex++) {
+ slapt_add_remove_to_transaction(tran,conflicts->pkgs[cindex]);
}
+ slapt_free_pkg_list(conflicts);
+
dep_installed = slapt_get_newest_pkg(installed_pkgs,dep->name);
if (dep_installed == NULL) {
slapt_add_install_to_transaction(tran,dep);
@@ -833,13 +836,14 @@ int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
}
/* make sure pkg isn't conflicted with what's already in the transaction */
-slapt_pkg_info_t *slapt_is_conflicted(slapt_transaction_t *tran,
+struct slapt_pkg_list *slapt_is_conflicted(slapt_transaction_t *tran,
struct slapt_pkg_list *avail_pkgs,
struct slapt_pkg_list *installed_pkgs,
slapt_pkg_info_t *pkg)
{
unsigned int i;
struct slapt_pkg_list *conflicts = NULL;
+ struct slapt_pkg_list *conflicts_in_transaction = slapt_init_pkg_list();
/* if conflicts exist, check to see if they are installed
or in the current transaction
@@ -852,19 +856,19 @@ slapt_pkg_info_t *slapt_is_conflicted(slapt_transaction_t *tran,
|| slapt_get_newest_pkg(tran->install_pkgs,p->name) != NULL
) {
printf(gettext("%s, which is to be installed, conflicts with %s\n"), p->name,pkg->name);
- slapt_free_pkg_list(conflicts);
- return p;
+
+ slapt_add_pkg_to_pkg_list(conflicts_in_transaction, p);
}
if (slapt_get_newest_pkg(installed_pkgs,p->name) != NULL) {
printf(gettext("Installed %s conflicts with %s\n"), p->name,pkg->name);
- slapt_free_pkg_list(conflicts);
- return p;
+
+ slapt_add_pkg_to_pkg_list(conflicts_in_transaction, p);
}
}
slapt_free_pkg_list(conflicts);
- return NULL;
+ return conflicts_in_transaction;
}
static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
@@ -876,7 +880,7 @@ static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
}
while (isspace(pkg->suggests[position]) != 0)
- ++position;
+ ++position;
while (position < len) {
int total_len = 0,rest_len = 0;
diff --git a/src/transaction.h b/src/transaction.h
index e961917..38f8e5c 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -83,7 +83,7 @@ int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
check to see if a package has a conflict already present in the transaction
returns conflicted package or NULL if none
*/
-slapt_pkg_info_t *slapt_is_conflicted(slapt_transaction_t *tran,
+struct slapt_pkg_list *slapt_is_conflicted(slapt_transaction_t *tran,
struct slapt_pkg_list *avail_pkgs,
struct slapt_pkg_list *installed_pkgs,
slapt_pkg_info_t *pkg);