On Tue, Jan 08, 2008 at 09:16:52PM +0100, Xavier wrote:
Dan McGee wrote:
This seems like a feature introduced to solve a problem the wrong way. If people didn't release broken packages, this really wouldn't be necessary.
Any reason not to just kill it completely?
No, as Nathan said, it's broken. And I think it's not possible to fix it with the current sync dbs, so we might as well remove it. And the implementation is rather simple anyway.
My test repo and community has the BUILDDATE field in it, but core and extra do not. I have a patch that works for simple cases, but I'm sure it fails for versioned dependencies. I've included the patch if anyone wants to mess with it. I'm fine with removing it. From: Nathan Jones <nathanj@insightbb.com> Date: Tue, 8 Jan 2008 14:14:05 -0500 Subject: [PATCH] Make UpdateDelay work. Previously, _alpm_pkg_istoonew was using pmpkg_t.date for comparing dates, but that variable was never being set. Change it to use pmpkg_t.builddate instead. Remove pmpkg_t.date since it is not used. Change alpm_pkg_compare_versions to return a 2 when the package is not supposed to be upgraded due to UpgradeDelay so that the sync functions can know not to include that package. Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- lib/libalpm/package.c | 16 ++++++++++++---- lib/libalpm/package.h | 1 - lib/libalpm/sync.c | 8 ++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 657de7d..ff03be0 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -824,7 +824,13 @@ void _alpm_pkg_free(pmpkg_t *pkg) FREE(pkg); } -/* Is pkgB an upgrade for pkgA ? */ +/* Is pkg an upgrade for local_pkg ? + * + * returns: + * 0 - new package is older than local + * 1 - new package is newer + * 2 - new package is newer but is not yet past UpgradeDelay time + */ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg) { int cmp = 0; @@ -851,13 +857,14 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg) alpm_db_get_name(db), alpm_pkg_get_version(pkg)); cmp = 0; } else if(cmp > 0) { + cmp = 1; /* we have an upgrade, make sure we should actually do it */ if(_alpm_pkg_istoonew(pkg)) { /* package too new (UpgradeDelay) */ _alpm_log(PM_LOG_WARNING, _("%s-%s: delaying upgrade of package (%s)\n"), alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg), alpm_pkg_get_version(pkg)); - cmp = 0; + cmp = 2; } } @@ -1157,10 +1164,11 @@ int _alpm_pkg_istoonew(pmpkg_t *pkg) ALPM_LOG_FUNC; - if (!handle->upgradedelay) + if (!handle->upgradedelay) { return 0; + } time(&t); - return((pkg->date + handle->upgradedelay) > t); + return((pkg->builddate + handle->upgradedelay) > t); } /** Test if a package should be ignored. diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 7ef41f9..f818ae2 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -61,7 +61,6 @@ struct __pmpkg_t { unsigned long isize; unsigned short scriptlet; unsigned short force; - time_t date; pmpkgreason_t reason; alpm_list_t *licenses; alpm_list_t *replaces; diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index ec4af9f..0b3b411 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -238,7 +238,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, } /* compare versions and see if we need to upgrade */ - if(alpm_pkg_compare_versions(local, spkg)) { + if(alpm_pkg_compare_versions(local, spkg) == 1) { _alpm_log(PM_LOG_DEBUG, "%s elected for upgrade (%s => %s)\n", alpm_pkg_get_name(local), alpm_pkg_get_version(local), alpm_pkg_get_version(spkg)); @@ -354,7 +354,8 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy local = _alpm_db_get_pkgfromcache(db_local, alpm_pkg_get_name(spkg)); if(local) { - if(alpm_pkg_compare_versions(local, spkg) == 0) { + int cmp = alpm_pkg_compare_versions(local, spkg); + if(cmp == 0) { /* spkg is NOT an upgrade */ if(trans->flags & PM_TRANS_FLAG_NEEDED) { _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"), @@ -364,6 +365,9 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"), alpm_pkg_get_name(local), alpm_pkg_get_version(local)); } + } else if (cmp == 2) { + /* not upgrading (UpgradeDelay) */ + return(0); } } -- 1.5.3.7