diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2016-02-22 03:46:35 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2016-02-23 03:15:43 +0100 |
commit | 2ee7a8d89ad693617307260604e1d58757fd2978 (patch) | |
tree | 4168d3e07cd4a8ebe21180ac8bc0e27fb05821dd /lib/libalpm/add.c | |
parent | f63854fa96f658ca5bdf2c21a1cd33cf4e3fbdbd (diff) | |
download | pacman-2ee7a8d89ad693617307260604e1d58757fd2978.tar.gz pacman-2ee7a8d89ad693617307260604e1d58757fd2978.tar.xz |
do not rely on localdb for hook matching
Relying on localdb to determine which trigger operations should match is
completely broken for PostTransaction hooks because the localdb has
already been updated. Store a copy of the old version of any packages
being updated to use instead.
Fixes FS#47996
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r-- | lib/libalpm/add.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 2639fa79..f5c9a957 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -409,9 +409,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg, ASSERT(trans != NULL, return -1); /* see if this is an upgrade. if so, remove the old package first */ - alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db, newpkg->name); - if(local) { - int cmp = _alpm_pkg_compare_versions(newpkg, local); + if((oldpkg = newpkg->oldpkg)) { + int cmp = _alpm_pkg_compare_versions(newpkg, oldpkg); if(cmp < 0) { log_msg = "downgrading"; progress = ALPM_PROGRESS_DOWNGRADE_START; @@ -427,14 +426,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg, } is_upgrade = 1; - /* we'll need to save some record for backup checks later */ - if(_alpm_pkg_dup(local, &oldpkg) == -1) { - ret = -1; - goto cleanup; - } - /* copy over the install reason */ - newpkg->reason = alpm_pkg_get_reason(local); + newpkg->reason = alpm_pkg_get_reason(oldpkg); } else { event.operation = ALPM_PACKAGE_INSTALL; } @@ -630,7 +623,6 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg, EVENT(handle, &event); cleanup: - _alpm_pkg_free(oldpkg); return ret; } |