Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Improve message about incompatible ABIs found in repositories
Baptiste Daroussin committed 13 years ago
commit b72ab0d1fdc88f70795f820b7394d265698a683f
parent d3423d4
3 files changed +40 -5
modified libpkg/pkgdb.c
@@ -2880,6 +2880,37 @@ get_pragma(sqlite3 *s, const char *sql, int64_t *res)
}

int
+
get_sql_string(sqlite3 *s, const char *sql, char **res)
+
{
+
	sqlite3_stmt	*stmt;
+
	int		 ret;
+

+
	assert(s != NULL && sql != NULL);
+

+
	if (sqlite3_prepare_v2(s, sql, -1, &stmt, NULL) != SQLITE_OK) {
+
		ERROR_SQLITE(s);
+
		return (EPKG_OK);
+
	}
+

+
	ret = sqlite3_step(stmt);
+

+
	if (ret == SQLITE_ROW)
+
		*res = strdup(sqlite3_column_text(stmt, 0));
+

+
	if (ret == SQLITE_DONE)
+
		*res = NULL;
+

+
	sqlite3_finalize(stmt);
+

+
	if (ret != SQLITE_ROW && ret != SQLITE_DONE) {
+
		ERROR_SQLITE(s);
+
		return (EPKG_FATAL);
+
	}
+

+
	return (EPKG_OK);
+
}
+

+
int
pkgdb_compact(struct pkgdb *db)
{
	int64_t	page_count = 0;
modified libpkg/private/pkg.h
@@ -349,6 +349,7 @@ int pkg_check_repo_version(struct pkgdb *db, const char *database);
/* pkgdb commands */
int sql_exec(sqlite3 *, const char *, ...);
int get_pragma(sqlite3 *, const char *sql, int64_t *res);
+
int get_sql_string(sqlite3 *, const char *sql, char **res);

int pkgdb_load_deps(struct pkgdb *db, struct pkg *pkg);
int pkgdb_load_rdeps(struct pkgdb *db, struct pkg *pkg);
modified libpkg/update.c
@@ -84,6 +84,7 @@ pkg_update(const char *name, const char *packagesite, bool force)
	char *req = NULL;
	const char *myarch;
	int64_t res;
+
	char *bad_abis = NULL;
	const char *tmpdir;
	sqlite3_stmt *stmt;
	const char sql[] = ""
@@ -245,9 +246,9 @@ pkg_update(const char *name, const char *packagesite, bool force)

	pkg_config_string(PKG_CONFIG_ABI, &myarch);

-
	req = sqlite3_mprintf("select count(arch) from packages "
+
	req = sqlite3_mprintf("select group_concat(arch, ', ') from packages "
	    "where arch not GLOB '%q'", myarch);
-
	if (get_pragma(sqlite, req, &res) != EPKG_OK) {
+
	if (get_sql_string(sqlite, req, &bad_abis) != EPKG_OK) {
		sqlite3_free(req);
		pkg_emit_error("Unable to query repository");
		rc = EPKG_FATAL;
@@ -255,10 +256,12 @@ pkg_update(const char *name, const char *packagesite, bool force)
		goto cleanup;
	}

-
	if (res > 0) {
+
	if (bad_abis != NULL) {
		pkg_emit_error("At least one of the packages provided by "
-
		    "the repository is not compatible with your abi: %s",
-
		    myarch);
+
		    "the repository is not compatible with your ABI:\n"
+
		    "    Your ABI: %s\n"
+
		    "    Incompatible ABIs found: %s",
+
		    myarch, bad_abis);
		rc = EPKG_FATAL;
		sqlite3_close(sqlite);
		goto cleanup;