@matiasdelellis
Copy link

I am maintaining a humble software store based on the old gnome-packagekit. I upgraded from fedora 35 to fedora 37, and today I find some bugs.

It seems that there were several changes in appstream 0.15, but the particular api used, it claims to work the same.

Theoretically it looks for all the components that are in any of the categories. 🤔
But in practice, it seems that by adding more search categories, it shows less components.

Well, I share a little test code.

#include <glib-object.h>
#include <appstream.h>

void
print_pkg_components_by_categories (AsPool *as_pool, gchar **categories)
{
	GPtrArray *components = NULL;
	AsComponent *component = NULL;
	const gchar *pkgname = NULL;
	guint i = 0;

	g_print("\n\nSearch by categories:\n");
	for (i = 0; categories[i] != NULL; i++) {
		g_print (" - Category: %s\n", categories[i]);
	}

	g_print("Components results:\n");
	components = as_pool_get_components_by_categories (as_pool, categories);
	for (i = 0; i < components->len; i++) {
		component = AS_COMPONENT (g_ptr_array_index (components, i));
		pkgname = as_component_get_pkgname (component);
		if (pkgname) {
			g_print (" - Package name: %s\n", pkgname);
		}
	}
}

int main( void )
{
	AsPool *as_pool;
	gchar **categories = NULL;

	as_pool = as_pool_new ();
	if (!as_pool_load (as_pool, NULL, NULL)) {
		g_print ("D'OH!: Cannot load AsPool");
		return -1;
	}

	categories = g_strsplit("AdventureGame", ",", -1);
	print_pkg_components_by_categories (as_pool, categories);
	g_strfreev(categories);

	categories = g_strsplit("BlocksGame", ",", -1);
	print_pkg_components_by_categories (as_pool, categories);
	g_strfreev(categories);

	categories = g_strsplit("AdventureGame,BlocksGame", ",", -1);
	print_pkg_components_by_categories (as_pool, categories);
	g_strfreev(categories);

	categories = g_strsplit("ActionGame,AdventureGame,ArcadeGame,Amusement,BlocksGame,BoardGame,CardGame,Game,KidsGame,LogicGame,RolePlaying,Shooter,Simulation,SportsGame,StrategyGame", ",", -1);
	print_pkg_components_by_categories (as_pool, categories);
	g_strfreev(categories);
}

Build with:

cc `pkg-config --cflags appstream` test.c -o test `pkg-config --libs appstream`
[matias@bangho-mdl xings-software]$ ./test 

Search by categories:
 - Category: AdventureGame
Components results:
 - Package name: naev
 - Package name: edgar
 - Package name: crossfire-client
 - Package name: scummvm
 - Package name: openarena
 - Package name: pioneer
 - Package name: freedink-engine
 - Package name: colobot


Search by categories:
 - Category: BlocksGame
Components results:
 - Package name: lbrickbuster2
 - Package name: flobopuyo
 - Package name: ballbuster
 - Package name: quadrapassel
 - Package name: BlockOutII
 - Package name: crystal-stacker


Search by categories:
 - Category: AdventureGame
 - Category: BlocksGame
Components results:


Search by categories:
 - Category: ActionGame
 - Category: AdventureGame
 - Category: ArcadeGame
 - Category: Amusement
 - Category: BlocksGame
 - Category: BoardGame
 - Category: CardGame
 - Category: Game
 - Category: KidsGame
 - Category: LogicGame
 - Category: RolePlaying
 - Category: Shooter
 - Category: Simulation
 - Category: SportsGame
 - Category: StrategyGame
Components results:

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.495: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.495: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

(process:36826): XbValueBindings-CRITICAL **: 15:39:52.496: xb_value_bindings_bind_str: assertion 'idx < G_N_ELEMENTS(_self->values)' failed

So, searching AdventureGame find 8 components, and searching BlocksGame show 6 components, and looking for both categories, does not find any.. 🙈

But my problem started when I search all the game subcategories, and it doesn't find anything either, but it also returns errors. 🤔