When built with support for libdb tools (i.e. db_dump was found at configure time), check for the existance of the db_dumb tool before attempting to use it: this way the libdb tools can stay an optional dependency at runtime, and their lack just gives no information on the applications installed in an RPM-based distro. Since we don't need the absolute path of db_dumb (nor db_load, used only in tests), change the GUESTFS_FIND_DB_TOOL m4 macro to give the names instead. --- m4/guestfs-find-db-tool.m4 | 2 +- src/inspect-apps.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/m4/guestfs-find-db-tool.m4 b/m4/guestfs-find-db-tool.m4 index ee20301..1026938 100644 --- a/m4/guestfs-find-db-tool.m4 +++ b/m4/guestfs-find-db-tool.m4 @@ -36,7 +36,7 @@ AC_DEFUN([GUESTFS_FIND_DB_TOOL],[ exe_list="$exe_list $exe" done done - AC_PATH_PROGS([]VARIABLE[], [$exe_list], [no]) + AC_CHECK_PROGS([]VARIABLE[], [$exe_list], [no]) ]) popdef([VARIABLE]) diff --git a/src/inspect-apps.c b/src/inspect-apps.c index b377f57..78c2711 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <unistd.h> #include <string.h> +#include <libintl.h> #ifdef HAVE_ENDIAN_H #include <endian.h> @@ -109,6 +110,7 @@ guestfs_impl_inspect_list_applications2 (guestfs_h *g, const char *root) { struct guestfs_application2_list *ret = NULL; struct inspect_fs *fs = guestfs_int_search_for_root (g, root); + int r; if (!fs) return NULL; @@ -122,9 +124,17 @@ guestfs_impl_inspect_list_applications2 (guestfs_h *g, const char *root) switch (fs->package_format) { case OS_PACKAGE_FORMAT_RPM: #ifdef DB_DUMP - ret = list_applications_rpm (g, fs); - if (ret == NULL) + r = guestfs_int_find_cmd (g, DB_DUMP, NULL); + if (r < 0) return NULL; + if (r == 0) { + debug (g, _("inspection of RPM database cannot be done, as %s is not available"), + DB_DUMP); + } else { + ret = list_applications_rpm (g, fs); + if (ret == NULL) + return NULL; + } #endif break; -- 2.7.4