[pacman-dev] [PATCH v2 1/2] libalpm/sync.c: change alpm_sync_newversion() to alpm_sync_get_new_version()
The behaviour of "pacman -Qu" was very strange... It would only consider packages from repos with Usage = Search (or All), and ignore those with Usage = Sync, Install or Upgrade. This is because the function alpm_sync_newversion() used ALPM_DB_USAGE_SEARCH for its filtering. Given this function is documented (at least in the source) to "Check for new version of pkg in sync repos", I would expect that to look at all repos. However, just changing this parameter, would result in a fairly silent change in behaviour of this function. Instead, rename the function and remove this filtering altogether. Users of this function can filter the dbs passed to this function to achieve their desired output. Signed-off-by: Allan McRae <allan@archlinux.org> --- This patch should address the comments Andrew made. I have not added the helper function for filtering databases by alpm_usage_type yet, but did file a bug to track it (FS#61333). lib/libalpm/alpm.h | 2 +- lib/libalpm/sync.c | 6 +----- src/pacman/query.c | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 597e11bd..bbce0971 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -1452,7 +1452,7 @@ alpm_list_t *alpm_find_group_pkgs(alpm_list_t *dbs, const char *name); * Sync */ -alpm_pkg_t *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync); +alpm_pkg_t *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync); /** @addtogroup alpm_api_trans Transaction Functions * Functions to manipulate libalpm transactions diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 05f58fad..de579eac 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -51,7 +51,7 @@ /** Check for new version of pkg in sync repos * (only the first occurrence is considered in sync) */ -alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync) +alpm_pkg_t SYMEXPORT *alpm_sync_get_new_version(alpm_pkg_t *pkg, alpm_list_t *dbs_sync) { alpm_list_t *i; alpm_pkg_t *spkg = NULL; @@ -61,10 +61,6 @@ alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_syn for(i = dbs_sync; !spkg && i; i = i->next) { alpm_db_t *db = i->data; - if(!(db->usage & ALPM_DB_USAGE_SEARCH)) { - continue; - } - spkg = _alpm_db_get_pkgfromcache(db, pkg->name); } diff --git a/src/pacman/query.c b/src/pacman/query.c index 00c39638..9ac6e930 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -286,7 +286,7 @@ static int filter(alpm_pkg_t *pkg) return 0; } /* check if this pkg is outdated */ - if(config->op_q_upgrade && (alpm_sync_newversion(pkg, + if(config->op_q_upgrade && (alpm_sync_get_new_version(pkg, alpm_get_syncdbs(config->handle)) == NULL)) { return 0; } @@ -325,7 +325,7 @@ static int display(alpm_pkg_t *pkg) colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); if(config->op_q_upgrade) { - alpm_pkg_t *newpkg = alpm_sync_newversion(pkg, alpm_get_syncdbs(config->handle)); + alpm_pkg_t *newpkg = alpm_sync_get_new_version(pkg, alpm_get_syncdbs(config->handle)); printf(" -> %s%s%s", colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor); if(alpm_pkg_should_ignore(config->handle, pkg)) { -- 2.20.0
List all available updates in -Qu output, but include [ignored] beside those that will not be updated in a -Su operation due to thier repo Usage value (in addition to those that are Ignored). Fixes FS#59854. The following people provided initial patches to print [ignored] on -Qu operations, which highlighted a larger problem to be fixed first: With-thanks-to: morganamilo <morganamilo@gmail.com> With-thanks-to: Michael Straube <michael.straube@posteo.de> Signed-off-by: Allan McRae <allan@archlinux.org> --- src/pacman/query.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index 9ac6e930..3e728257 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -325,10 +325,14 @@ static int display(alpm_pkg_t *pkg) colstr->version, alpm_pkg_get_version(pkg), colstr->nocolor); if(config->op_q_upgrade) { + int usage; alpm_pkg_t *newpkg = alpm_sync_get_new_version(pkg, alpm_get_syncdbs(config->handle)); + alpm_db_t *db = alpm_pkg_get_db(newpkg); + alpm_db_get_usage(db, &usage); + printf(" -> %s%s%s", colstr->version, alpm_pkg_get_version(newpkg), colstr->nocolor); - if(alpm_pkg_should_ignore(config->handle, pkg)) { + if(alpm_pkg_should_ignore(config->handle, pkg) || !(usage & ALPM_DB_USAGE_UPGRADE)) { printf(" %s", _("[ignored]")); } } -- 2.20.0
participants (1)
-
Allan McRae