[recipes] Make autoar dependency conditional
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Make autoar dependency conditional
- Date: Thu, 29 Dec 2016 18:23:01 +0000 (UTC)
commit 1f55b9e1ef28684159fb8be0e1e726abbe3d14ae
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 29 13:09:43 2016 -0500
Make autoar dependency conditional
This will help getting builds on other platforms working.
Without export/import, we also don't need the linux-specific
libglnx.
Makefile.am | 2 +
configure.ac | 14 ++++++++++-
src/gr-recipe-exporter.c | 61 +++++++++++++++++++++++++++++----------------
src/gr-recipe-importer.c | 59 +++++++++++++++++++++++++++++---------------
4 files changed, 93 insertions(+), 43 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 56de94f..e0a258b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,6 +30,7 @@ NEWS: data/appdata/org.gnome.Recipes.appdata.xml.in
@GENERATE_CHANGELOG_RULES@
dist-hook: dist-ChangeLog
+if USE_AUTOAR
lib_LTLIBRARIES =
noinst_LTLIBRARIES = libglnx.la
libglnx_srcpath := $(srcdir)/libglnx
@@ -39,6 +40,7 @@ libglnx_cflags := \
$(NULL)
libglnx_libs := $(RECIPES_LIBS)
include libglnx/Makefile-libglnx.am.inc
+endif
GITIGNOREFILES = \
**/*.swp \
diff --git a/configure.ac b/configure.ac
index 9459c8b..a66e796 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,12 +105,23 @@ if test "x$enable_gspell" = xyes; then
AC_DEFINE([ENABLE_GSPELL], [], [Define to 1 if gspell is used])
fi
+AC_ARG_ENABLE(autoar,
+ [AS_HELP_STRING([--enable-autoar],
+ [Use gnome-autoar for export/import support])],,
+ [enable_autoar="yes"])
+if test "x$enable_autoar" = xyes; then
+ AUTOAR_DEP=gnome-autoar-0
+ AC_DEFINE([ENABLE_AUTOAR], [], [Define to 1 if gnome-autoar is used])
+fi
+AM_CONDITIONAL(USE_AUTOAR, test "x$enable_autoar" = xyes)
+
+
dnl ***********************************************************************
dnl Check for required packages
dnl ***********************************************************************
PKG_CHECK_MODULES(RECIPES, [gio-2.0 >= 2.42
gtk+-3.0 >= 3.20
- gnome-autoar-0
+ $AUTOAR_DEP
$GSPELL_DEP])
@@ -144,5 +155,6 @@ echo " Options"
echo ""
echo " Prefix ............................... : ${prefix}"
echo " Libdir ............................... : ${libdir}"
+echo " Export/Import ........................ : ${enable_autoar}"
echo " Spell checking ....................... : ${enable_gspell}"
echo ""
diff --git a/src/gr-recipe-exporter.c b/src/gr-recipe-exporter.c
index 57cfde7..de8a5e0 100644
--- a/src/gr-recipe-exporter.c
+++ b/src/gr-recipe-exporter.c
@@ -22,8 +22,10 @@
#include "config.h"
#include <glib/gi18n.h>
+#ifdef ENABLE_AUTOAR
#include <gnome-autoar/gnome-autoar.h>
#include "glnx-shutil.h"
+#endif
#include "gr-recipe-exporter.h"
#include "gr-images.h"
@@ -41,7 +43,9 @@ struct _GrRecipeExporter
GrRecipe *recipe;
GtkWindow *window;
+#ifdef ENABLE_AUTOAR
AutoarCompressor *compressor;
+#endif
GFile *dest;
GFile *output;
GList *sources;
@@ -94,18 +98,22 @@ cleanup_export (GrRecipeExporter *exporter)
{
g_autoptr(GError) error = NULL;
+#ifdef ENABLE_AUTOAR
if (!glnx_shutil_rm_rf_at (-1, exporter->dir, NULL, &error))
g_warning ("Failed to clean up temp directory %s: %s", exporter->dir, error->message);
+ g_clear_object (&exporter->compressor);
+#endif
+
g_clear_pointer (&exporter->dir, g_free);
g_clear_object (&exporter->recipe);
- g_clear_object (&exporter->compressor);
g_clear_object (&exporter->output);
g_clear_object (&exporter->dest);
g_list_free_full (exporter->sources, g_object_unref);
exporter->sources = NULL;
}
+#ifdef ENABLE_AUTOAR
static void
completed_cb (AutoarCompressor *compressor,
GrRecipeExporter *exporter)
@@ -130,37 +138,24 @@ completed_cb (AutoarCompressor *compressor,
}
static void
-error_cb (AutoarCompressor *compressor,
- GError *error,
- GrRecipeExporter *exporter)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (exporter->window,
- GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Error while exporting recipe %s:\n%s"),
- gr_recipe_get_name (exporter->recipe),
- error->message);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
-
- cleanup_export (exporter);
-}
-
-static void
decide_dest_cb (AutoarCompressor *compressor,
GFile *file,
GrRecipeExporter *exporter)
{
g_set_object (&exporter->dest, file);
}
+#endif
static gboolean
prepare_export (GrRecipeExporter *exporter,
GError **error)
{
+#ifndef ENABLE_AUTOAR
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("This build does not support exporting"));
+
+ return FALSE;
+#else
g_autofree char *path = NULL;
g_autoptr(GKeyFile) keyfile = NULL;
const char *key;
@@ -322,8 +317,28 @@ prepare_export (GrRecipeExporter *exporter,
}
exporter->sources = g_list_append (exporter->sources, g_file_new_for_path (path));
-
return TRUE;
+#endif
+}
+
+static void
+error_cb (gpointer compressor,
+ GError *error,
+ GrRecipeExporter *exporter)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (exporter->window,
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Error while exporting recipe %s:\n%s"),
+ gr_recipe_get_name (exporter->recipe),
+ error->message);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+
+ cleanup_export (exporter);
}
void
@@ -341,6 +356,7 @@ gr_recipe_exporter_export_to (GrRecipeExporter *exporter,
return;
}
+#ifdef ENABLE_AUTOAR
exporter->compressor = autoar_compressor_new (exporter->sources, exporter->output,
AUTOAR_FORMAT_TAR, AUTOAR_FILTER_GZIP, FALSE);
g_signal_connect (exporter->compressor, "decide-dest", G_CALLBACK (decide_dest_cb), exporter);
@@ -348,4 +364,5 @@ gr_recipe_exporter_export_to (GrRecipeExporter *exporter,
g_signal_connect (exporter->compressor, "error", G_CALLBACK (error_cb), exporter);
autoar_compressor_start_async (exporter->compressor, NULL);
+#endif
}
diff --git a/src/gr-recipe-importer.c b/src/gr-recipe-importer.c
index 46a79f5..934f4f7 100644
--- a/src/gr-recipe-importer.c
+++ b/src/gr-recipe-importer.c
@@ -22,8 +22,11 @@
#include <stdlib.h>
#include <glib/gi18n.h>
+
+#ifdef ENABLE_AUTOAR
#include <gnome-autoar/gnome-autoar.h>
#include "glnx-shutil.h"
+#endif
#include "gr-recipe-importer.h"
#include "gr-images.h"
@@ -40,7 +43,9 @@ struct _GrRecipeImporter
GtkWindow *window;
+#ifdef ENABLE_AUTOAR
AutoarExtractor *extractor;
+#endif
GFile *output;
char *dir;
@@ -80,7 +85,9 @@ gr_recipe_importer_finalize (GObject *object)
{
GrRecipeImporter *importer = GR_RECIPE_IMPORTER (object);
+#ifdef ENABLE_AUTOAR
g_clear_object (&importer->extractor);
+#endif
g_clear_object (&importer->output);
g_free (importer->dir);
g_free (importer->chef_id);
@@ -146,13 +153,15 @@ gr_recipe_importer_new (GtkWindow *parent)
static void
cleanup_import (GrRecipeImporter *importer)
{
+#ifdef ENABLE_AUTOAR
g_autoptr(GError) error = NULL;
if (!glnx_shutil_rm_rf_at (-1, importer->dir, NULL, &error))
g_warning ("Failed to clean up temp directory %s: %s", importer->dir, error->message);
+ g_clear_object (&importer->extractor);
+#endif
g_clear_pointer (&importer->dir, g_free);
- g_clear_object (&importer->extractor);
g_clear_object (&importer->output);
g_clear_pointer (&importer->chef_id, g_free);
g_clear_pointer (&importer->chef_name, g_free);
@@ -177,6 +186,26 @@ cleanup_import (GrRecipeImporter *importer)
g_clear_pointer (&importer->recipe_mtime, g_date_time_unref);
}
+static void
+error_cb (gpointer extractor,
+ GError *error,
+ GrRecipeImporter *importer)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (importer->window,
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Error while importing recipe:\n%s"),
+ error->message);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+
+ cleanup_import (importer);
+}
+
+#ifdef ENABLE_AUTOAR
static gboolean
copy_image (GrRecipeImporter *importer,
const char *path,
@@ -213,25 +242,6 @@ copy_image (GrRecipeImporter *importer,
}
static void
-error_cb (AutoarExtractor *extractor,
- GError *error,
- GrRecipeImporter *importer)
-{
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (importer->window,
- GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Error while importing recipe:\n%s"),
- error->message);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
-
- cleanup_import (importer);
-}
-
-static void
do_import_recipe (GrRecipeImporter *importer)
{
GrRecipeStore *store;
@@ -690,11 +700,19 @@ completed_cb (AutoarExtractor *extractor,
{
finish_import (importer);
}
+#endif
void
gr_recipe_importer_import_from (GrRecipeImporter *importer,
GFile *file)
{
+#ifndef ENABLE_AUTOAR
+ g_autoptr(GError) error = NULL;
+
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("This build does not support importing"));
+ error_cb (NULL, error, importer);
+#else
importer->dir = g_mkdtemp (g_build_filename (g_get_tmp_dir (), "recipeXXXXXX", NULL));
importer->output = g_file_new_for_path (importer->dir);
@@ -705,4 +723,5 @@ gr_recipe_importer_import_from (GrRecipeImporter *importer,
g_signal_connect (importer->extractor, "error", G_CALLBACK (error_cb), importer);
autoar_extractor_start_async (importer->extractor, NULL);
+#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]