[pacman-dev] [PATCH] pacman_query: move error messages into relevant if statements
This ensures any additions to these test do not have to rely on the correct error condition being set by libalpm. Signed-off-by: Allan McRae <allan@archlinux.org> --- src/pacman/query.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index 0cc12e6..1d102a9 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -460,27 +460,27 @@ int pacman_query(alpm_list_t *targets) if(config->op_q_isfile) { alpm_pkg_load(config->handle, strname, 1, 0, &pkg); + + if(pkg == NULL) { + pm_printf(ALPM_LOG_ERROR, + _("could not load package '%s': %s\n"), strname, + alpm_strerror(alpm_errno(config->handle))); + } } else { pkg = alpm_db_get_pkg(db_local, strname); + + if(pkg == NULL) { + pm_printf(ALPM_LOG_ERROR, + _("package '%s' was not found\n"), strname); + if(!config->op_q_isfile && access(strname, R_OK) == 0) { + pm_printf(ALPM_LOG_WARNING, + _("'%s' is a file, you might want to use %s.\n"), + strname, "-p/--file"); + } + } } if(pkg == NULL) { - switch(alpm_errno(config->handle)) { - case ALPM_ERR_PKG_NOT_FOUND: - pm_printf(ALPM_LOG_ERROR, - _("package '%s' was not found\n"), strname); - if(!config->op_q_isfile && access(strname, R_OK) == 0) { - pm_printf(ALPM_LOG_WARNING, - _("'%s' is a file, you might want to use %s.\n"), - strname, "-p/--file"); - } - break; - default: - pm_printf(ALPM_LOG_ERROR, - _("could not load package '%s': %s\n"), strname, - alpm_strerror(alpm_errno(config->handle))); - break; - } ret = 1; continue; } -- 2.7.4
It is useful to be able to use "pacman -Qi" on any dependency, even if that dependency is a provide. For example, on Arch Linux systems, "sh" is provided by the "bash" package, and many packages depend on "sh". Querying the package that provides the "sh" dependency currently requires first searching for "sh". This patch allows the use of "pacman -Qi" on a provide. Fixes FS#20650. Signed-off-by: Allan McRae <allan@archlinux.org> --- src/pacman/query.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pacman/query.c b/src/pacman/query.c index 1d102a9..34d7fcb 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -468,6 +468,9 @@ int pacman_query(alpm_list_t *targets) } } else { pkg = alpm_db_get_pkg(db_local, strname); + if(pkg == NULL) { + pkg = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), strname); + } if(pkg == NULL) { pm_printf(ALPM_LOG_ERROR, -- 2.7.4
On 04/02/16 at 04:08pm, Allan McRae wrote:
It is useful to be able to use "pacman -Qi" on any dependency, even if that dependency is a provide. For example, on Arch Linux systems, "sh" is provided by the "bash" package, and many packages depend on "sh". Querying the package that provides the "sh" dependency currently requires first searching for "sh".
This patch allows the use of "pacman -Qi" on a provide.
Fixes FS#20650.
Signed-off-by: Allan McRae <allan@archlinux.org> ---
ACK.
src/pacman/query.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/pacman/query.c b/src/pacman/query.c index 1d102a9..34d7fcb 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -468,6 +468,9 @@ int pacman_query(alpm_list_t *targets) } } else { pkg = alpm_db_get_pkg(db_local, strname); + if(pkg == NULL) { + pkg = alpm_find_satisfier(alpm_db_get_pkgcache(db_local), strname); + }
if(pkg == NULL) { pm_printf(ALPM_LOG_ERROR, -- 2.7.4
On 04/02/16 at 04:08pm, Allan McRae wrote:
This ensures any additions to these test do not have to rely on the correct error condition being set by libalpm.
Signed-off-by: Allan McRae <allan@archlinux.org> --- src/pacman/query.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
ACK
diff --git a/src/pacman/query.c b/src/pacman/query.c index 0cc12e6..1d102a9 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -460,27 +460,27 @@ int pacman_query(alpm_list_t *targets)
if(config->op_q_isfile) { alpm_pkg_load(config->handle, strname, 1, 0, &pkg); + + if(pkg == NULL) { + pm_printf(ALPM_LOG_ERROR, + _("could not load package '%s': %s\n"), strname, + alpm_strerror(alpm_errno(config->handle))); + } } else { pkg = alpm_db_get_pkg(db_local, strname); + + if(pkg == NULL) { + pm_printf(ALPM_LOG_ERROR, + _("package '%s' was not found\n"), strname); + if(!config->op_q_isfile && access(strname, R_OK) == 0) { + pm_printf(ALPM_LOG_WARNING, + _("'%s' is a file, you might want to use %s.\n"), + strname, "-p/--file"); + } + } }
if(pkg == NULL) { - switch(alpm_errno(config->handle)) { - case ALPM_ERR_PKG_NOT_FOUND: - pm_printf(ALPM_LOG_ERROR, - _("package '%s' was not found\n"), strname); - if(!config->op_q_isfile && access(strname, R_OK) == 0) { - pm_printf(ALPM_LOG_WARNING, - _("'%s' is a file, you might want to use %s.\n"), - strname, "-p/--file"); - } - break; - default: - pm_printf(ALPM_LOG_ERROR, - _("could not load package '%s': %s\n"), strname, - alpm_strerror(alpm_errno(config->handle))); - break; - } ret = 1; continue; } -- 2.7.4
participants (2)
-
Allan McRae
-
Andrew Gregory