Date: Mon, 2 Sep 2013 19:03:40 GMT From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r256842 - soc2013/mattbw/backend/jobs Message-ID: <201309021903.r82J3eNa078483@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mattbw Date: Mon Sep 2 19:03:40 2013 New Revision: 256842 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256842 Log: Output exact package that failed a suitability check. This is mainly for debugging purposes. Modified: soc2013/mattbw/backend/jobs/check.c soc2013/mattbw/backend/jobs/check.h soc2013/mattbw/backend/jobs/do.c Modified: soc2013/mattbw/backend/jobs/check.c ============================================================================== --- soc2013/mattbw/backend/jobs/check.c Mon Sep 2 18:25:18 2013 (r256841) +++ soc2013/mattbw/backend/jobs/check.c Mon Sep 2 19:03:40 2013 (r256842) @@ -34,33 +34,36 @@ #include "check.h" /* jobs_check_... */ static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever); -static bool jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates); +static struct pkg *jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates); /* Checks a solved job against a string vector of PackageIDs to ensure any * packages that match the PackageIDs match them fully. + * + * Returns NULL if the check succeeded, and a struct pkg if that package + * failed the check. */ -bool +struct pkg * jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates) { - bool success; + struct pkg *package; struct query_id *query_ids; assert(jobs != NULL); assert(package_ids != NULL); assert(0 < count); - success = false; + package = NULL; query_ids = query_id_array_from_package_ids(package_ids, count); if (query_ids != NULL) { /* Now do the actual checking, per package. */ - success = jobs_check_query_ids(jobs, query_ids, count, + package = jobs_check_query_ids(jobs, query_ids, count, reject_non_updates); } - return success; + return package; } static bool @@ -86,7 +89,7 @@ } -static bool +static struct pkg * jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates) { @@ -141,5 +144,5 @@ /* Do not free the struct pkg, we actually don't own it. */ } - return success; + return success ? NULL : package; } Modified: soc2013/mattbw/backend/jobs/check.h ============================================================================== --- soc2013/mattbw/backend/jobs/check.h Mon Sep 2 18:25:18 2013 (r256841) +++ soc2013/mattbw/backend/jobs/check.h Mon Sep 2 19:03:40 2013 (r256842) @@ -25,6 +25,6 @@ #include <stdbool.h> /* bool */ #include "../pkg.h" /* pkg_... */ -bool jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates); +struct pkg *jobs_check_package_ids(struct pkg_jobs *jobs, gchar **package_ids, guint count, bool reject_non_updates); #endif /* !_PKGNG_BACKEND_JOBS_CHECK_H_ */ Modified: soc2013/mattbw/backend/jobs/do.c ============================================================================== --- soc2013/mattbw/backend/jobs/do.c Mon Sep 2 18:25:18 2013 (r256841) +++ soc2013/mattbw/backend/jobs/do.c Mon Sep 2 19:03:40 2013 (r256842) @@ -28,6 +28,7 @@ #include "../db.h" /* db_... */ #include "../namever.h" /* namever_array_free */ +#include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* get_package_ids */ #include "check.h" /* jobs_check_... */ #include "core.h" /* jobs_... */ @@ -103,28 +104,39 @@ jobs_do_check(const struct jobs_spec *spec, struct pkg_jobs *jobs, gchar **package_ids, guint count) { - bool success; + struct pkg *failed_package; assert(spec != NULL); assert(jobs != NULL); assert(package_ids != NULL || 0 == count); assert(package_ids == NULL || 0 < count); - success = true; + failed_package = NULL; if (package_ids != NULL) { - success = jobs_check_package_ids(jobs, package_ids, count, - spec->reject_non_updates); + failed_package = jobs_check_package_ids(jobs, package_ids, + count, spec->reject_non_updates); } - if (!success) { + if (failed_package != NULL) { + char *message; + char *package_id; + + package_id = pkgutils_pkg_to_id(failed_package); + message = NULL; + (void)asprintf(&message, + "(internal error) package %s failed suitability check.", + package_id); ERR(spec->backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, - "packages failed suitability check"); + message); + + g_free(package_id); + free(message); } - assert(0 < count || success); + assert(0 < count || failed_package == NULL); - return success; + return (failed_package == NULL); } static bool
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309021903.r82J3eNa078483>