/**
 * gs_refine_item_management_plugin:
 */
static void
gs_refine_item_management_plugin (GsApp *app, AsApp *item)
{
	GPtrArray *bundles;
	const gchar *management_plugin = NULL;
	const gchar *runtime = NULL;
	guint i;

	/* find the default bundle kind */
	bundles = as_app_get_bundles (item);
	for (i = 0; i < bundles->len; i++) {
		AsBundle *bundle = g_ptr_array_index (bundles, i);
		if (as_bundle_get_kind (bundle) == AS_BUNDLE_KIND_XDG_APP) {
			management_plugin = "XgdApp";
			gs_app_add_source (app, as_bundle_get_id (bundle));

			/* automatically add runtime */
			runtime = as_bundle_get_runtime (bundle);
			if (runtime != NULL) {
				g_autoptr(GsApp) app2 = NULL;
				app2 = gs_appstream_create_runtime (app, runtime);
				if (app2 != NULL) {
					g_debug ("runtime for %s is %s",
						 gs_app_get_id (app), runtime);
					gs_app_set_runtime (app, app2);
				}
			}
			break;
		}
		if (as_bundle_get_kind (bundle) == AS_BUNDLE_KIND_LIMBA) {
			management_plugin = "Limba";
			gs_app_add_source (app, as_bundle_get_id (bundle));
			break;
		}
	}

	/* fall back to PackageKit */
	if (management_plugin == NULL &&
	    as_app_get_pkgname_default (item) != NULL)
		management_plugin = "PackageKit";
	if (management_plugin != NULL)
		gs_app_set_management_plugin (app, management_plugin);
}
Exemple #2
0
/**
 * as_utils_get_component_bundle_kind:
 *
 * Check which bundling system the component uses.
 */
AsBundleKind
as_utils_get_component_bundle_kind (AsComponent *cpt)
{
	GPtrArray *bundles;
	AsBundleKind bundle_kind;

	/* determine bundle - what should we do if there are multiple bundles of different types
	 * defined for one component? */
	bundle_kind = AS_BUNDLE_KIND_PACKAGE;
	bundles = as_component_get_bundles (cpt);
	if (bundles->len > 0)
		bundle_kind = as_bundle_get_kind (AS_BUNDLE (g_ptr_array_index (bundles, 0)));

	return bundle_kind;
}