Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Lachu:SystemServices
PackageKit
n-0063-alpm-Support-replaces-with-version-expre...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File n-0063-alpm-Support-replaces-with-version-expressions.patch of Package PackageKit
From cad6e2ff9a960f6a6b5caccbbe6402c7d3cb6fa5 Mon Sep 17 00:00:00 2001 From: Aleix Pol <aleixpol@kde.org> Date: Tue, 21 Dec 2021 16:04:54 +0100 Subject: [PATCH 063/102] alpm: Support replaces with version expressions We were just checking filenames, now using alpm_dep_from_string() we make follow the pkgname<1.0 kind of notation. diff --git a/backends/alpm/pk-alpm-sync.c b/backends/alpm/pk-alpm-sync.c index 8c7ded998..b9886bd5b 100644 --- a/backends/alpm/pk-alpm-sync.c +++ b/backends/alpm/pk-alpm-sync.c @@ -61,6 +61,11 @@ pk_alpm_transaction_sync_targets (PkBackendJob *job, const gchar **packages, gbo } pkg = alpm_db_get_pkg (i->data, name); + alpm_pkg_t *dep_to_remove = pk_alpm_pkg_replaces(priv->localdb, pkg); + if (dep_to_remove) { + g_debug("scheduling to remove %s for %s", alpm_pkg_get_name(dep_to_remove), name); + alpm_remove_pkg(priv->alpm, dep_to_remove); + } if (update) { // libalpm only checks for ignorepkgs on an update const alpm_list_t *ignorepkgs, *ignoregroups, *group_iter; diff --git a/backends/alpm/pk-alpm-update.c b/backends/alpm/pk-alpm-update.c index 8f8d90a14..08bb7b457 100644 --- a/backends/alpm/pk-alpm-update.c +++ b/backends/alpm/pk-alpm-update.c @@ -331,13 +331,42 @@ pk_alpm_pkg_is_syncfirst (alpm_list_t *syncfirsts, alpm_pkg_t *pkg) return FALSE; } -static gboolean -pk_alpm_pkg_replaces (alpm_pkg_t *pkg, const gchar *name) +static int dep_vercmp(const char *version1, alpm_depmod_t mod, + const char *version2) { + int equal = 0; + + if(mod == ALPM_DEP_MOD_ANY) { + equal = 1; + } else { + int cmp = alpm_pkg_vercmp(version1, version2); + switch(mod) { + case ALPM_DEP_MOD_EQ: equal = (cmp == 0); break; + case ALPM_DEP_MOD_GE: equal = (cmp >= 0); break; + case ALPM_DEP_MOD_LE: equal = (cmp <= 0); break; + case ALPM_DEP_MOD_LT: equal = (cmp < 0); break; + case ALPM_DEP_MOD_GT: equal = (cmp > 0); break; + default: equal = 1; break; + } + } + return equal; +} + +alpm_pkg_t * +pk_alpm_pkg_replaces (alpm_db_t *db, alpm_pkg_t *pkg) +{ + g_return_val_if_fail (db != NULL, FALSE); g_return_val_if_fail (pkg != NULL, FALSE); - g_return_val_if_fail (name != NULL, FALSE); + gboolean ret = FALSE; - return alpm_list_find_str (alpm_pkg_get_replaces (pkg), name) != NULL; + for (alpm_list_t *list = alpm_pkg_get_replaces (pkg); list != NULL && !ret; list = list->next) { + alpm_depend_t *depend = list->data; + alpm_pkg_t *deppkg = alpm_db_get_pkg(db, depend->name); + if (deppkg && dep_vercmp(alpm_pkg_get_version(deppkg), depend->mod, depend->version)) { + return deppkg; + } + } + return NULL; } static alpm_pkg_t * @@ -360,12 +389,6 @@ pk_alpm_pkg_find_update (alpm_pkg_t *pkg, const alpm_list_t *dbs) } return NULL; } - - i = alpm_db_get_pkgcache (dbs->data); - for (; i != NULL; i = i->next) { - if (pk_alpm_pkg_replaces (i->data, name)) - return i->data; - } } return NULL; diff --git a/backends/alpm/pk-alpm-update.h b/backends/alpm/pk-alpm-update.h index a1c4419f6..7f38bfaed 100644 --- a/backends/alpm/pk-alpm-update.h +++ b/backends/alpm/pk-alpm-update.h @@ -25,3 +25,6 @@ gboolean pk_alpm_refresh_databases (PkBackendJob *job, gint force, alpm_list_t *dbs, GError **error); + +alpm_pkg_t * +pk_alpm_pkg_replaces (alpm_db_t *db, alpm_pkg_t *pkg); -- 2.35.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor