[pacman-dev] [PATCH] libalpm: Fix installing update of a replaced package

Allan McRae allan at archlinux.org
Sun Mar 3 14:45:08 EST 2013


On 04/03/13 05:43, Allan McRae wrote:
> On 01/03/13 04:06, Olivier Brunel wrote:
>> During a sysupgrade, if a package is replaced by another, and an update for the
>> former package is found (on another repo) the replaced package would be
>> re-installed.
>>
>> Signed-off-by: Olivier Brunel <i.am.jack.mail at gmail.com>
>> ---
>> I'm not really familiar with inner workings of ALPM, so this is probably not the
>> best way to do this.
>>
>>  lib/libalpm/sync.c            | 13 ++++++++++++-
>>  test/pacman/tests/sync1104.py | 18 ++++++++++++++++++
>>  2 files changed, 30 insertions(+), 1 deletion(-)
>>  create mode 100644 test/pacman/tests/sync1104.py
>>
>> diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
>> index 204456d..31f5870 100644
>> --- a/lib/libalpm/sync.c
>> +++ b/lib/libalpm/sync.c
>> @@ -351,6 +351,16 @@ finish:
>>  	return ret;
>>  }
>>  
>> +static int _cmp_pkg (alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
>> +{
>> +	if (!pkg1)
>> +		return 1;
>> +	else if (!pkg2)
>> +		return -1;
>> +	else
>> +		return strcmp (pkg1->name, pkg2->name);
>> +}
>> +
> 
> we have _alpm_pkg_cmp() in package.h
> 
>>  int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
>>  {
>>  	alpm_list_t *i, *j;
>> @@ -408,7 +418,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
>>  		   building up a list of packages which could not be resolved. */
>>  		for(i = trans->add; i; i = i->next) {
>>  			alpm_pkg_t *pkg = i->data;
>> -			if(_alpm_resolvedeps(handle, localpkgs, pkg, trans->add,
>> +			if(!alpm_list_find(remove, pkg, (alpm_list_fn_cmp) _cmp_pkg)
>> +					&& _alpm_resolvedeps(handle, localpkgs, pkg, trans->add,
> 
> Hrm...  I think it would be best just to remove the packages from
> trans->add one the are flagged to be removed.  I.e. about 10 lines above
> this.   (I am assuming that can be done...).
> 
>>  						&resolved, remove, data) == -1) {
>>  				unresolvable = alpm_list_add(unresolvable, pkg);
>>  			}
>> diff --git a/test/pacman/tests/sync1104.py b/test/pacman/tests/sync1104.py
>> new file mode 100644
>> index 0000000..5cec98a
>> --- /dev/null
>> +++ b/test/pacman/tests/sync1104.py
>> @@ -0,0 +1,18 @@
>> +self.description = "Don't update (reinstall) a replaced package"
>> +
>> +lp = pmpkg("old", "1-1")
>> +self.addpkg2db("local", lp)
>> +
>> +p1 = pmpkg("new")
>> +p1.provides = ["old"]
>> +p1.replaces = ["old"]
>> +self.addpkg2db("sync1", p1)
>> +
>> +p2 = pmpkg("old", "1-2")
>> +self.addpkg2db("sync2", p2)
>> +
>> +self.args = "-Su"
>> +
>> +self.addrule("PACMAN_RETCODE=0")
>> +self.addrule("!PKG_EXIST=old")
>> +self.addrule("PKG_EXIST=new")
>>
> 

Forgot to add - awesome for adding a pactest here!




More information about the pacman-dev mailing list