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

* I made "alpm_versioncmp" public a while back, without noticing this was already done (alpm_pkg_vercmp). I dropped this change, making versioncmp "private" again. (alpm_versioncmp -> _alpm_versioncmp, hidden symbol)

* Make alpm_get_upgrades use the same version check that -Su and -S use.
This commit is contained in:
Aaron Griffin 2007-02-09 21:08:10 +00:00
parent 0ae434d9e1
commit f8cd4858ca
7 changed files with 11 additions and 30 deletions

View File

@ -158,7 +158,7 @@ int SYMHIDDEN _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
if(trans->flags & PM_TRANS_FLAG_FRESHEN) {
/* only upgrade/install this package if it is already installed and at a lesser version */
dummy = _alpm_db_get_pkgfromcache(db, pkgname);
if(dummy == NULL || alpm_versioncmp(dummy->version, pkgver) >= 0) {
if(dummy == NULL || _alpm_versioncmp(dummy->version, pkgver) >= 0) {
pm_errno = PM_ERR_PKG_CANT_FRESH;
goto error;
}
@ -170,7 +170,7 @@ int SYMHIDDEN _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
for(i = trans->packages; i; i = i->next) {
pmpkg_t *pkg = i->data;
if(strcmp(pkg->name, pkgname) == 0) {
if(alpm_versioncmp(pkg->version, pkgver) < 0) {
if(_alpm_versioncmp(pkg->version, pkgver) < 0) {
pmpkg_t *newpkg;
_alpm_log(PM_LOG_WARNING, _("replacing older version %s-%s by %s in target list"),
pkg->name, pkg->version, pkgver);

View File

@ -561,7 +561,7 @@ int SYMEXPORT alpm_pkg_vercmp(const char *ver1, const char *ver2)
{
ALPM_LOG_FUNC;
return(alpm_versioncmp(ver1, ver2));
return(_alpm_versioncmp(ver1, ver2));
}
/* internal */
@ -1175,25 +1175,7 @@ alpm_list_t *alpm_get_upgrades()
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_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);
alpm_list_t *s;

View File

@ -482,9 +482,6 @@ extern enum _pmerrno_t pm_errno;
char *alpm_strerror(int err);
/* Version Compare */
int alpm_versioncmp(const char *a, const char *b);
alpm_list_t *alpm_get_upgrades();
#ifdef __cplusplus

View File

@ -135,7 +135,7 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
}
/* compare versions and see if we need to upgrade */
cmp = alpm_versioncmp(local_pkg->version, pkg->version);
cmp = _alpm_versioncmp(local_pkg->version, pkg->version);
if(cmp != 0 && pkg->force) {
cmp = 1;

View File

@ -148,7 +148,7 @@ static int strverscmp (s1, s2)
#endif
/* this function was taken from rpm 4.0.4 and rewritten */
int SYMEXPORT alpm_versioncmp(const char *a, const char *b)
int _alpm_versioncmp(const char *a, const char *b)
{
char str1[64], str2[64];
char *ptr1, *ptr2;
@ -238,7 +238,7 @@ int SYMEXPORT alpm_versioncmp(const char *a, const char *b)
if((!*one) && (!*two)) {
/* compare release numbers */
if(rel1 && rel2) return(alpm_versioncmp(rel1, rel2));
if(rel1 && rel2) return(_alpm_versioncmp(rel1, rel2));
return(0);
}
@ -256,7 +256,7 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
if(dep->mod == PM_DEP_MOD_ANY) {
equal = 1;
} else {
int cmp = alpm_versioncmp(pkg->version, dep->version);
int cmp = _alpm_versioncmp(pkg->version, dep->version);
switch(dep->mod) {
case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
case PM_DEP_MOD_GE: equal = (cmp >= 0); break;

View File

@ -27,6 +27,8 @@
#include "package.h"
int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
int _alpm_versioncmp(const char *a, const char *b)
#endif

View File

@ -45,7 +45,7 @@ int main(int argc, char *argv[])
return(0);
}
ret = alpm_versioncmp(s1, s2);
ret = alpm_pkg_vercmp(s1, s2);
printf("%d\n", ret);
return(ret);
}