From 07c130900965a08b48b3d5c8af083b3ebc0eed13 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Fri, 29 Dec 2006 17:04:58 +0000 Subject: * Removed latest fix from TODO.autoconf * Attempted fix for FS#6100 - "-Spd foo" failure * Beginning of refactoring from Dan McGee --- TODO.autoconf | 7 --- lib/libalpm/sync.c | 148 +++++++++++++++++++++++++++++------------------------ src/pacman/sync.c | 46 ++++++++--------- 3 files changed, 104 insertions(+), 97 deletions(-) diff --git a/TODO.autoconf b/TODO.autoconf index 22e1740f..b212e9a3 100644 --- a/TODO.autoconf +++ b/TODO.autoconf @@ -1,12 +1,5 @@ TODO for autoconf/automake: -pacman's Makefile.am and configure.in -===================================== - -- find out how can we prevent automake/autoconf to build pacman.static binary, if we - are configured using --disable-static flag. Now if builded with this option, then pacman.static - compile fails, because there will be no libalpm.a (just .so) - global ====== diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index e31a891f..65e27d9a 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -118,7 +118,10 @@ static int istoonew(pmpkg_t *pkg) return((pkg->date + handle->upgradedelay) > t); } -int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync) +/* Find recommended replacements for packages during a sync. + * (refactored from _alpm_sync_prepare) + */ +static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync) { pmlist_t *i, *j, *k; @@ -178,80 +181,91 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync } } } + return(0); +error: + return(-1); +} - /* match installed packages with the sync dbs and compare versions */ - _alpm_log(PM_LOG_FLOW1, _("checking for package upgrades")); - for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) { - int cmp; - int replace=0; - pmpkg_t *local = i->data; - pmpkg_t *spkg = NULL; - pmsyncpkg_t *sync; - - for(j = dbs_sync; !spkg && j; j = j->next) { - spkg = _alpm_db_get_pkgfromcache(j->data, local->name); - } - if(spkg == NULL) { - _alpm_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name); - continue; - } - - /* we don't care about a to-be-replaced package's newer version */ - for(j = trans->packages; j && !replace; j=j->next) { - sync = j->data; - if(sync->type == PM_SYNC_TYPE_REPLACE) { - if(_alpm_pkg_isin(spkg->name, sync->data)) { - replace=1; - } +int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync) +{ + pmlist_t *i, *j; + + /* check for "recommended" package replacements */ + _alpm_log(PM_LOG_FLOW1, _("checking for package replacements")); + if( find_replacements(trans, db_local, dbs_sync) == 0 ) { + /* match installed packages with the sync dbs and compare versions */ + _alpm_log(PM_LOG_FLOW1, _("checking for package upgrades")); + for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) { + int cmp; + int replace=0; + pmpkg_t *local = i->data; + pmpkg_t *spkg = NULL; + pmsyncpkg_t *sync; + + for(j = dbs_sync; !spkg && j; j = j->next) { + spkg = _alpm_db_get_pkgfromcache(j->data, local->name); + } + if(spkg == NULL) { + _alpm_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name); + continue; } - } - if(replace) { - _alpm_log(PM_LOG_DEBUG, _("'%s' is already elected for removal -- skipping"), - local->name); - continue; - } - /* compare versions and see if we need to upgrade */ - cmp = _alpm_versioncmp(local->version, spkg->version); - if(cmp > 0 && !spkg->force) { - /* local version is newer */ - pmdb_t *db = spkg->data; - _alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"), - local->name, local->version, db->treename, spkg->version); - } else if(cmp == 0) { - /* versions are identical */ - } else if(_alpm_list_is_strin(spkg->name, handle->ignorepkg)) { - /* package should be ignored (IgnorePkg) */ - _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"), - local->name, local->version, spkg->version); - } else if(istoonew(spkg)) { - /* package too new (UpgradeDelay) */ - _alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)"), - local->name, local->version, spkg->version); - /* check if spkg->name is already in the packages list. */ - } else { - _alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"), - local->name, local->version, local->version, spkg->version); - if(!find_pkginsync(spkg->name, trans->packages)) { - pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version); - if(dummy == NULL) { - goto error; - } - sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy); - if(sync == NULL) { - FREEPKG(dummy); - goto error; + /* we don't care about a to-be-replaced package's newer version */ + for(j = trans->packages; j && !replace; j=j->next) { + sync = j->data; + if(sync->type == PM_SYNC_TYPE_REPLACE) { + if(_alpm_pkg_isin(spkg->name, sync->data)) { + replace=1; + } } - trans->packages = _alpm_list_add(trans->packages, sync); + } + if(replace) { + _alpm_log(PM_LOG_DEBUG, _("'%s' is already elected for removal -- skipping"), + local->name); + continue; + } + + /* compare versions and see if we need to upgrade */ + cmp = _alpm_versioncmp(local->version, spkg->version); + if(cmp > 0 && !spkg->force) { + /* local version is newer */ + pmdb_t *db = spkg->data; + _alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"), + local->name, local->version, db->treename, spkg->version); + } else if(cmp == 0) { + /* versions are identical */ + } else if(_alpm_list_is_strin(spkg->name, handle->ignorepkg)) { + /* package should be ignored (IgnorePkg) */ + _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"), + local->name, local->version, spkg->version); + } else if(istoonew(spkg)) { + /* package too new (UpgradeDelay) */ + _alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)"), + local->name, local->version, spkg->version); + /* check if spkg->name is already in the packages list. */ } else { - /* spkg->name is already in the packages list -- just ignore it */ + _alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"), + local->name, local->version, local->version, spkg->version); + if(!find_pkginsync(spkg->name, trans->packages)) { + pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version); + if(dummy == NULL) { + goto error; + } + sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy); + if(sync == NULL) { + FREEPKG(dummy); + goto error; + } + trans->packages = _alpm_list_add(trans->packages, sync); + } else { + /* spkg->name is already in the packages list -- just ignore it */ + } } } - } - return(0); - -error: + return(0); + } + /* if we're here, it's an error */ return(-1); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 604cf4c2..6718bd92 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -664,46 +664,46 @@ int pacman_sync(list_t *targets) if(!confirm) { goto cleanup; } - } - /* Step 3: actually perform the installation - */ - if(alpm_trans_commit(&data) == -1) { - ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); - switch(pm_errno) { + /* Step 3: actually perform the installation + */ + if(alpm_trans_commit(&data) == -1) { + ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); + switch(pm_errno) { case PM_ERR_FILE_CONFLICTS: for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) { pmconflict_t *conflict = alpm_list_getdata(lp); switch(alpm_conflict_get_type(conflict)) { - case PM_CONFLICT_TYPE_TARGET: - MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"), - config->root, - alpm_conflict_get_file(conflict), - alpm_conflict_get_target(conflict), - alpm_conflict_get_ctarget(conflict)); + case PM_CONFLICT_TYPE_TARGET: + MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"), + config->root, + alpm_conflict_get_file(conflict), + alpm_conflict_get_target(conflict), + alpm_conflict_get_ctarget(conflict)); break; - case PM_CONFLICT_TYPE_FILE: - MSG(NL, _("%s: %s%s exists in filesystem"), - alpm_conflict_get_target(conflict), - config->root, - alpm_conflict_get_file(conflict)); + case PM_CONFLICT_TYPE_FILE: + MSG(NL, _("%s: %s%s exists in filesystem"), + alpm_conflict_get_target(conflict), + config->root, + alpm_conflict_get_file(conflict)); break; } } MSG(NL, _("\nerrors occurred, no packages were upgraded.\n")); - break; + break; case PM_ERR_PKG_CORRUPTED: for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) { MSG(NL, "%s", (char*)alpm_list_getdata(lp)); } MSG(NL, _("\nerrors occurred, no packages were upgraded.\n")); - break; + break; default: - break; + break; + } + retval = 1; + goto cleanup; } - retval = 1; - goto cleanup; - } + }/* else 'print uris' requested. We're done at this point */ /* Step 4: release transaction resources */ -- cgit v1.2.3-70-g09d2