/** * asb_package_deb_explode: **/ static gboolean asb_package_deb_explode (AsbPackage *pkg, const gchar *dir, GPtrArray *glob, GError **error) { guint i; const gchar *data_names[] = { "data.tar.xz", "data.tar.bz2", "data.tar.gz", "data.tar.lzma", "data.tar", NULL }; /* first decompress the main deb */ if (!asb_utils_explode (asb_package_get_filename (pkg), dir, NULL, error)) return FALSE; /* then decompress the data file */ for (i = 0; data_names[i] != NULL; i++) { _cleanup_free_ gchar *data_fn = NULL; data_fn = g_build_filename (dir, data_names[i], NULL); if (g_file_test (data_fn, G_FILE_TEST_EXISTS)) { if (!asb_utils_explode (data_fn, dir, glob, error)) return FALSE; } } return TRUE; }
/** * asb_package_explode: * @pkg: A #AsbPackage * @dir: directory to explode into * @glob: (element-type utf8): the glob list, or %NULL * @error: A #GError or %NULL * * Decompresses a package into a directory, optionally using a glob list. * * Returns: %TRUE for success, %FALSE otherwise * * Since: 0.1.0 **/ gboolean asb_package_explode (AsbPackage *pkg, const gchar *dir, GPtrArray *glob, GError **error) { AsbPackageClass *klass = ASB_PACKAGE_GET_CLASS (pkg); AsbPackagePrivate *priv = GET_PRIVATE (pkg); if (klass->explode != NULL) return klass->explode (pkg, dir, glob, error); return asb_utils_explode (priv->filename, dir, glob, error); }
/** * asb_context_setup: * @ctx: A #AsbContext * @error: A #GError or %NULL * * Sets up the context ready for use. * * Returns: %TRUE for success, %FALSE otherwise * * Since: 0.1.0 **/ gboolean asb_context_setup (AsbContext *ctx, GError **error) { AsbContextPrivate *priv = GET_PRIVATE (ctx); g_autofree gchar *icons_dir = NULL; g_autofree gchar *screenshot_dir1 = NULL; g_autofree gchar *screenshot_dir2 = NULL; /* required stuff set */ if (priv->origin == NULL) { g_set_error_literal (error, ASB_PLUGIN_ERROR, ASB_PLUGIN_ERROR_FAILED, "origin not set!"); return FALSE; } if (priv->output_dir == NULL) { g_set_error_literal (error, ASB_PLUGIN_ERROR, ASB_PLUGIN_ERROR_FAILED, "output_dir not set!"); return FALSE; } if (priv->icons_dir == NULL) { g_set_error_literal (error, ASB_PLUGIN_ERROR, ASB_PLUGIN_ERROR_FAILED, "icons_dir not set!"); return FALSE; } if (priv->temp_dir == NULL) { g_set_error_literal (error, ASB_PLUGIN_ERROR, ASB_PLUGIN_ERROR_FAILED, "temp_dir not set!"); return FALSE; } if (priv->cache_dir == NULL) { g_set_error_literal (error, ASB_PLUGIN_ERROR, ASB_PLUGIN_ERROR_FAILED, "cache_dir not set!"); return FALSE; } /* create temp space */ if (!asb_utils_ensure_exists (priv->output_dir, error)) return FALSE; screenshot_dir1 = g_build_filename (priv->temp_dir, "screenshots", NULL); if (!asb_utils_ensure_exists_and_empty (screenshot_dir1, error)) return FALSE; screenshot_dir2 = g_build_filename (priv->cache_dir, "screenshots", NULL); if (!asb_utils_ensure_exists (screenshot_dir2, error)) return FALSE; if (priv->log_dir != NULL) { if (!asb_utils_ensure_exists (priv->log_dir, error)) return FALSE; } /* icons is nuked; we can re-decompress from the -icons.tar.gz */ if (!asb_utils_ensure_exists (priv->icons_dir, error)) return FALSE; if (priv->flags & ASB_CONTEXT_FLAG_HIDPI_ICONS) { g_autofree gchar *icons_dir_hidpi = NULL; g_autofree gchar *icons_dir_lodpi = NULL; icons_dir_lodpi = g_build_filename (priv->icons_dir, "64x64", NULL); if (!asb_utils_ensure_exists (icons_dir_lodpi, error)) return FALSE; icons_dir_hidpi = g_build_filename (priv->icons_dir, "128x128", NULL); if (!asb_utils_ensure_exists (icons_dir_hidpi, error)) return FALSE; } /* decompress the icons */ if (priv->old_metadata != NULL) { g_autofree gchar *icons_fn = NULL; icons_fn = g_strdup_printf ("%s/%s-icons.tar.gz", priv->old_metadata, priv->basename); if (g_file_test (icons_fn, G_FILE_TEST_EXISTS)) { if (!asb_utils_explode (icons_fn, priv->icons_dir, NULL, error)) return FALSE; } } /* load plugins */ if (!asb_plugin_loader_setup (priv->plugin_loader, error)) return FALSE; /* get a cache of the file globs */ priv->file_globs = asb_plugin_loader_get_globs (priv->plugin_loader); /* add old metadata */ if (priv->old_metadata != NULL) { g_autofree gchar *builder_id = NULL; g_autofree gchar *fn_failed = NULL; g_autofree gchar *fn_ignore = NULL; g_autofree gchar *fn_old = NULL; g_autoptr(GFile) file_failed = NULL; g_autoptr(GFile) file_ignore = NULL; g_autoptr(GFile) file_old = NULL; builder_id = asb_utils_get_builder_id (); fn_old = g_strdup_printf ("%s/%s.xml.gz", priv->old_metadata, priv->basename); file_old = g_file_new_for_path (fn_old); if (g_file_query_exists (file_old, NULL)) { if (!as_store_from_file (priv->store_old, file_old, NULL, NULL, error)) return FALSE; /* check builder-id matches */ if (g_strcmp0 (as_store_get_builder_id (priv->store_old), builder_id) != 0) { g_debug ("builder ID does not match: %s:%s", as_store_get_builder_id (priv->store_old), builder_id); as_store_remove_all (priv->store_old); } } fn_ignore = g_strdup_printf ("%s/%s-ignore.xml.gz", priv->old_metadata, priv->basename); file_ignore = g_file_new_for_path (fn_ignore); if (g_file_query_exists (file_ignore, NULL)) { if (!as_store_from_file (priv->store_ignore, file_ignore, NULL, NULL, error)) return FALSE; /* check builder-id matches */ if (g_strcmp0 (as_store_get_builder_id (priv->store_ignore), builder_id) != 0) { g_debug ("builder ID does not match: %s:%s", as_store_get_builder_id (priv->store_ignore), builder_id); as_store_remove_all (priv->store_ignore); } } fn_failed = g_strdup_printf ("%s/%s-failed.xml.gz", priv->old_metadata, priv->basename); file_failed = g_file_new_for_path (fn_failed); if (g_file_query_exists (file_failed, NULL)) { if (!as_store_from_file (priv->store_failed, file_failed, NULL, NULL, error)) return FALSE; /* check builder-id matches */ if (g_strcmp0 (as_store_get_builder_id (priv->store_failed), builder_id) != 0) { g_debug ("builder ID does not match: %s:%s", as_store_get_builder_id (priv->store_failed), builder_id); as_store_remove_all (priv->store_failed); } } } return TRUE; }