Exemplo n.º 1
0
static gboolean
asb_package_alpm_ensure_filelists (AsbPackage *pkg, GError **error)
{
	AsbPackageAlpm *pkg_alpm = ASB_PACKAGE_ALPM (pkg);
	AsbPackageAlpmPrivate *priv = GET_PRIVATE (pkg_alpm);

	alpm_filelist_t *pkgfiles = alpm_pkg_get_files (priv->package);
	guint i;
	GPtrArray *filelist = g_ptr_array_new_with_free_func (g_free);

	for (i = 0; i < pkgfiles->count; i++) {
		const alpm_file_t *file = pkgfiles->files + i;
		g_ptr_array_add (filelist, g_strconcat ("/", file->name, NULL));
	}
	g_ptr_array_add (filelist, NULL);

	asb_package_set_filelist (pkg, (gchar **)(filelist->pdata));

	g_ptr_array_free (filelist, TRUE);
	return TRUE;
}
Exemplo n.º 2
0
/**
 * asb_package_deb_ensure_filelists:
 **/
static gboolean
asb_package_deb_ensure_filelists (AsbPackage *pkg, GError **error)
{
	const gchar *argv[4] = { "dpkg", "--contents", "fn", NULL };
	const gchar *fn;
	guint i;
	_cleanup_free_ gchar *output = NULL;
	_cleanup_ptrarray_unref_ GPtrArray *files = NULL;
	_cleanup_strv_free_ gchar **lines = NULL;

	/* spawn sync */
	argv[2] = asb_package_get_filename (pkg);
	if (!g_spawn_sync (NULL, (gchar **) argv, NULL,
			   G_SPAWN_SEARCH_PATH,
			   NULL, NULL,
			   &output, NULL, NULL, error))
		return FALSE;

	/* parse output */
	files = g_ptr_array_new_with_free_func (g_free);
	lines = g_strsplit (output, "\n", -1);
	for (i = 0; lines[i] != NULL; i++) {
		fn = g_strrstr (lines[i], " ");
		if (fn == NULL)
			continue;
		/* ignore directories */
		if (g_str_has_suffix (fn, "/"))
			continue;
		g_ptr_array_add (files, g_strdup (fn + 2));
	}

	/* save */
	g_ptr_array_add (files, NULL);
	asb_package_set_filelist (pkg, (gchar **) files->pdata);
	return TRUE;
}