1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Attempt to unify the -S and -Su version comparissons for when a package is newer

See FS#5388
This commit is contained in:
Aaron Griffin 2007-02-06 17:39:32 +00:00
parent 26e7d16d0e
commit 67ea493ec2
2 changed files with 35 additions and 31 deletions

View File

@ -122,6 +122,38 @@ void _alpm_pkg_free(void *data)
return;
}
/* Is pkgB an upgrade for pkgA ? */
int alpm_pkg_compare_versions(pmpkg_t *pkgA, pmpkg_t *pkgB)
{
if(spkg->force) {
/* skip the version compare call if this is a 'force' package */
return(1);
}
/* compare versions and see if we need to upgrade */
int cmp = alpm_versioncmp(pkgA->version, pkgB->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);
cmp = 0;
} else if(alpm_list_find_str(handle->ignorepkg, spkg->name)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
local->name, local->version, spkg->version);
cmp = 0;
} else if(_alpm_pkg_istoonew(spkg)) {
/* package too new (UpgradeDelay) */
_alpm_log(PM_LOG_DEBUG, _("%s-%s: delaying upgrade of package (%s)"),
local->name, local->version, spkg->version);
cmp = 0;
}
return(cmp);
}
/* Helper function for comparing packages
*/
int _alpm_pkg_cmp(const void *p1, const void *p2)

View File

@ -229,24 +229,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
}
/* 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_find_str(handle->ignorepkg, spkg->name)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
local->name, local->version, spkg->version);
} else if(_alpm_pkg_istoonew(spkg)) {
/* package too new (UpgradeDelay) */
_alpm_log(PM_LOG_DEBUG, _("%s-%s: delaying upgrade of package (%s)"),
local->name, local->version, spkg->version);
/* check if spkg->name is already in the packages list. */
} else {
if(alpm_pkg_compare_versions(local, spkg)) {
_alpm_log(PM_LOG_DEBUG, _("%s-%s elected for upgrade (%s => %s)"),
local->name, local->version, local->version, spkg->version);
if(!find_pkginsync(spkg->name, trans->packages)) {
@ -260,8 +243,6 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
goto error;
}
trans->packages = alpm_list_add(trans->packages, sync);
} else {
/* spkg->name is already in the packages list -- just ignore it */
}
}
}
@ -344,17 +325,8 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
local = _alpm_db_get_pkgfromcache(db_local, spkg->name);
if(local) {
cmp = alpm_versioncmp(local->version, spkg->version);
if(cmp > 0 && !spkg->force) {
/* local version is newer -- get confirmation before adding */
int resp = 0;
QUESTION(trans, PM_TRANS_CONV_LOCAL_NEWER, local, NULL, NULL, &resp);
if(!resp) {
_alpm_log(PM_LOG_WARNING, _("%s-%s: local version is newer -- skipping"), local->name, local->version);
return(0);
}
} else if(cmp == 0) {
/* versions are identical -- get confirmation before adding */
if(alpm_pkg_compare_versions(local, spkg) == 0) {
/* spkg is NOT an upgrade, get confirmation before adding */
int resp = 0;
QUESTION(trans, PM_TRANS_CONV_LOCAL_UPTODATE, local, NULL, NULL, &resp);
if(!resp) {