summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-02-06 17:39:32 +0000
committerAaron Griffin <aaron@archlinux.org>2007-02-06 17:39:32 +0000
commit67ea493ec24caa7279b35a28d96e5d6f2c271f59 (patch)
treef4da3d53a46e5e4901e13d421e0e505befb64b45 /lib/libalpm
parent26e7d16d0edd023efa10db56b745c3501f2d5db9 (diff)
Attempt to unify the -S and -Su version comparissons for when a package is newer
See FS#5388
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/package.c32
-rw-r--r--lib/libalpm/sync.c34
2 files changed, 35 insertions, 31 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index e93da71e..66fa14bb 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -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)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 9cf973fa..3dcde337 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -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) {