summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-02-09 16:43:23 +0000
committerJason Woodward2005-02-09 16:43:23 +0000
commit8f4805802db4ffae5682b50db5f643cb51566e42 (patch)
tree3f4acbb73071533fb63a8995d218c3c5ad215407 /src
parentb95db7ec205b7e395fd5ba0a13b87e0b254cc73d (diff)
downloadslapt-get-8f4805802db4ffae5682b50db5f643cb51566e42.tar.gz
added search_transaction_by_pkg() to make checks more specific
Diffstat (limited to 'src')
-rw-r--r--src/transaction.c36
-rw-r--r--src/transaction.h1
2 files changed, 32 insertions, 5 deletions
diff --git a/src/transaction.c b/src/transaction.c
index 4428014..4fc4cf0 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -297,7 +297,7 @@ void add_install_to_transaction(transaction_t *tran,pkg_info_t *pkg){
pkg_info_t **tmp_list;
/* don't add if already present in the transaction */
- if( search_transaction(tran,pkg->name) == 1 ) return;
+ if( search_transaction_by_pkg(tran,pkg) == 1 ) return;
#if DEBUG == 1
printf("adding install of %s-%s@%s to transaction\n",
@@ -330,7 +330,7 @@ void add_remove_to_transaction(transaction_t *tran,pkg_info_t *pkg){
pkg_info_t **tmp_list;
/* don't add if already present in the transaction */
- if( search_transaction(tran,pkg->name) == 1 ) return;
+ if( search_transaction_by_pkg(tran,pkg) == 1 ) return;
#if DEBUG == 1
printf("adding remove of %s-%s@%s to transaction\n",
@@ -361,7 +361,7 @@ void add_exclude_to_transaction(transaction_t *tran,pkg_info_t *pkg){
pkg_info_t **tmp_list;
/* don't add if already present in the transaction */
- if( search_transaction(tran,pkg->name) == 1 ) return;
+ if( search_transaction_by_pkg(tran,pkg) == 1 ) return;
#if DEBUG == 1
printf("adding exclude of %s-%s@%s to transaction\n",
@@ -394,7 +394,7 @@ void add_upgrade_to_transaction(
pkg_upgrade_t **tmp_list;
/* don't add if already present in the transaction */
- if( search_transaction(tran,upgrade_pkg->name) == 1 ) return;
+ if( search_transaction_by_pkg(tran,upgrade_pkg) == 1 ) return;
#if DEBUG == 1
printf("adding upgrade of %s-%s@%s to transaction\n",
@@ -508,7 +508,7 @@ transaction_t *remove_from_transaction(transaction_t *tran,pkg_info_t *pkg){
unsigned int i;
transaction_t *new_tran = NULL;
- if( search_transaction(tran,pkg->name) == 0 )
+ if( search_transaction_by_pkg(tran,pkg) == 0 )
return tran;
/* since this is a pointer, slapt_malloc before calling init */
@@ -711,3 +711,29 @@ static int disk_space(const rc_config *global_config,int space_needed ){
return 0;
}
+int search_transaction_by_pkg(transaction_t *tran,pkg_info_t *pkg){
+ unsigned int i,found = 1, not_found = 0;
+
+ for(i = 0; i < tran->install_pkgs->pkg_count;i++){
+ if(( strcmp(pkg->name,tran->install_pkgs->pkgs[i]->name)==0 )
+ && (strcmp(pkg->version,tran->install_pkgs->pkgs[i]->version)==0))
+ return found;
+ }
+ for(i = 0; i < tran->upgrade_pkgs->pkg_count;i++){
+ if(( strcmp(pkg->name,tran->upgrade_pkgs->pkgs[i]->upgrade->name)==0 )
+ && (strcmp(pkg->version,tran->upgrade_pkgs->pkgs[i]->upgrade->version)==0 ))
+ return found;
+ }
+ for(i = 0; i < tran->remove_pkgs->pkg_count;i++){
+ if(( strcmp(pkg->name,tran->remove_pkgs->pkgs[i]->name)==0 )
+ && (strcmp(pkg->version,tran->remove_pkgs->pkgs[i]->version)==0 ))
+ return found;
+ }
+ for(i = 0; i < tran->exclude_pkgs->pkg_count;i++){
+ if(( strcmp(pkg->name,tran->exclude_pkgs->pkgs[i]->name)==0 )
+ && (strcmp(pkg->version,tran->exclude_pkgs->pkgs[i]->version)==0 ))
+ return found;
+ }
+ return not_found;
+}
+
diff --git a/src/transaction.h b/src/transaction.h
index 728dd74..4324cd0 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -38,6 +38,7 @@ void add_remove_to_transaction(transaction_t *,pkg_info_t *pkg);
void add_upgrade_to_transaction(transaction_t *,pkg_info_t *installed_pkg,pkg_info_t *upgrade_pkg);
void add_exclude_to_transaction(transaction_t *,pkg_info_t *pkg);
int search_transaction(transaction_t *,char *pkg_name);
+int search_transaction_by_pkg(transaction_t *tran,pkg_info_t *pkg);
void free_transaction(transaction_t *);
transaction_t *remove_from_transaction(transaction_t *tran,pkg_info_t *pkg);
int add_deps_to_trans(const rc_config *global_config, transaction_t *tran, struct pkg_list *avail_pkgs, struct pkg_list *installed_pkgs, pkg_info_t *pkg);