[pacman-dev] [PATCH] libalpm: Search for replacers before literals

Allan McRae allan at archlinux.org
Mon Mar 4 02:53:57 EST 2013


On 04/03/13 10:10, Olivier Brunel wrote:
> Since 882bff36 literals would be searched before replacers, resulting in a
> package being replaced by another not actually being replaced under certain
> conditions (e.g. they're both in the same repo).
> 
> This change effectively reversed the expectations in test sync132. This patch
> switches the order back to replacers first, thus making sure if a package is
> replacing another one, the change will always happen, even if both are in the
> same repo.
> 
> Note that a package replacing another one in a repo with higher priority will
> not be done, see FS#11737
> 
> Signed-off-by: Olivier Brunel <i.am.jack.mail at gmail.com>
> ---

Awesome!   Quick querys to save me looking...

Is this in addition to your last patch or replacing it?

If it is replacing, it would be good to have the pactest from the last
patch included.

Also, we should make sure that there is a pactest for the cases in FS#11737.

Allan

>  lib/libalpm/sync.c              | 26 ++++++++++++++------------
>  test/pacman/tests/replace102.py |  2 --
>  test/pacman/tests/sync132.py    |  4 ++--
>  3 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
> index 204456d..01e9e0c 100644
> --- a/lib/libalpm/sync.c
> +++ b/lib/libalpm/sync.c
> @@ -209,24 +209,26 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade)
>  			continue;
>  		}
>  
> -		/* Search for literal then replacers in each sync database. */
> +		/* Search for replacers then literal (if no replacer) in each sync database. */
>  		for(j = handle->dbs_sync; j; j = j->next) {
>  			alpm_db_t *sdb = j->data;
>  			/* Check sdb */
> -			alpm_pkg_t *spkg = _alpm_db_get_pkgfromcache(sdb, lpkg->name);
> -			int literal_upgrade = 0;
> -			if(spkg) {
> -				literal_upgrade = check_literal(handle, lpkg, spkg, enable_downgrade);
> -				if(literal_upgrade) {
> -					trans->add = alpm_list_add(trans->add, spkg);
> -				}
> +			alpm_list_t *replacers;
> +			replacers = check_replacers(handle, lpkg, sdb);
> +			if(replacers) {
> +				trans->add = alpm_list_join(trans->add, replacers);
>  				/* jump to next local package */
>  				break;
>  			} else {
> -				alpm_list_t *replacers;
> -				replacers = check_replacers(handle, lpkg, sdb);
> -				if(replacers) {
> -					trans->add = alpm_list_join(trans->add, replacers);
> +				alpm_pkg_t *spkg = _alpm_db_get_pkgfromcache(sdb, lpkg->name);
> +				if(spkg) {
> +					int literal_upgrade = 0;
> +					literal_upgrade = check_literal(handle, lpkg, spkg, enable_downgrade);
> +					if(literal_upgrade) {
> +						trans->add = alpm_list_add(trans->add, spkg);
> +					}
> +					/* jump to next local package */
> +					break;
>  				}
>  			}
>  		}
> diff --git a/test/pacman/tests/replace102.py b/test/pacman/tests/replace102.py
> index ca05d4e..fe0bdad 100644
> --- a/test/pacman/tests/replace102.py
> +++ b/test/pacman/tests/replace102.py
> @@ -21,5 +21,3 @@
>  self.addrule("!PKG_EXIST=python-yaml")
>  self.addrule("PKG_VERSION=python2-yaml|5-1")
>  self.addrule("FILE_EXIST=lib/python2/file")
> -
> -self.expectfailure = True
> diff --git a/test/pacman/tests/sync132.py b/test/pacman/tests/sync132.py
> index 2d671c7..5e85727 100644
> --- a/test/pacman/tests/sync132.py
> +++ b/test/pacman/tests/sync132.py
> @@ -14,5 +14,5 @@
>  self.args = "-Su"
>  
>  self.addrule("PACMAN_RETCODE=0")
> -self.addrule("!PKG_EXIST=pkg1")
> -self.addrule("PKG_EXIST=pkg2")
> +self.addrule("PKG_EXIST=pkg1")
> +self.addrule("!PKG_EXIST=pkg2")
> 



More information about the pacman-dev mailing list