core: Move triggers into separate binary: ostree-run-triggers

I'm trying to keep ostree as being closer to just being the versioning
filesystem, so let's split out the triggers into a different binary
(although still namespaced ostree-).
This commit is contained in:
Colin Walters 2012-01-13 15:08:27 -05:00
parent 0d21187f14
commit 40226c2769
21 changed files with 236 additions and 522 deletions

View File

@ -30,8 +30,6 @@ libostree_la_SOURCES = src/libostree/ostree.h \
src/libostree/ostree-repo-file.h \
src/libostree/ostree-repo-file-enumerator.c \
src/libostree/ostree-repo-file-enumerator.h \
src/libostree/ostree-checkout.c \
src/libostree/ostree-checkout.h \
$(NULL)
if USE_LIBARCHIVE
libostree_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \

View File

@ -31,7 +31,6 @@ ostree_SOURCES = src/ostree/main.c \
src/ostree/ot-builtin-local-clone.c \
src/ostree/ot-builtin-log.c \
src/ostree/ot-builtin-ls.c \
src/ostree/ot-builtin-run-triggers.c \
src/ostree/ot-builtin-remote.c \
src/ostree/ot-builtin-rev-parse.c \
src/ostree/ot-builtin-show.c \

View File

@ -19,12 +19,18 @@
triggersdir = $(libexecdir)/ostree/triggers.d
triggers_SCRIPTS = \
triggers.d/desktop-database.trigger \
triggers.d/gdk-pixbuf.trigger \
triggers.d/glib.trigger \
triggers.d/gtk+.trigger \
triggers.d/immodules.trigger \
triggers.d/ldconfig.trigger \
triggers.d/mime-database.trigger \
triggers.d/pango.trigger \
src/triggers/triggers.d/desktop-database.trigger \
src/triggers/triggers.d/gdk-pixbuf.trigger \
src/triggers/triggers.d/glib.trigger \
src/triggers/triggers.d/gtk+.trigger \
src/triggers/triggers.d/immodules.trigger \
src/triggers/triggers.d/ldconfig.trigger \
src/triggers/triggers.d/mime-database.trigger \
src/triggers/triggers.d/pango.trigger \
$(NULL)
bin_PROGRAMS += ostree-run-triggers
ostree_run_triggers_SOURCES = src/triggers/ostree-run-triggers.c
ostree_run_triggers_CFLAGS = $(OT_DEP_GIO_UNIX_CFLAGS)
ostree_run_triggers_LDFLAGS = $(OT_DEP_GIO_UNIX_LIBS)

View File

@ -1,361 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Colin Walters <walters@verbum.org>
*/
#include "config.h"
#include "ostree.h"
#include "otutil.h"
enum {
PROP_0,
PROP_REPO,
PROP_PATH
};
G_DEFINE_TYPE (OstreeCheckout, ostree_checkout, G_TYPE_OBJECT)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), OSTREE_TYPE_CHECKOUT, OstreeCheckoutPrivate))
typedef struct _OstreeCheckoutPrivate OstreeCheckoutPrivate;
struct _OstreeCheckoutPrivate {
OstreeRepo *repo;
char *path;
};
static void
ostree_checkout_finalize (GObject *object)
{
OstreeCheckout *self = OSTREE_CHECKOUT (object);
OstreeCheckoutPrivate *priv = GET_PRIVATE (self);
g_free (priv->path);
g_clear_object (&priv->repo);
G_OBJECT_CLASS (ostree_checkout_parent_class)->finalize (object);
}
static void
ostree_checkout_set_property(GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
OstreeCheckout *self = OSTREE_CHECKOUT (object);
OstreeCheckoutPrivate *priv = GET_PRIVATE (self);
switch (prop_id)
{
case PROP_PATH:
priv->path = g_value_dup_string (value);
break;
case PROP_REPO:
priv->repo = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
ostree_checkout_get_property(GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
OstreeCheckout *self = OSTREE_CHECKOUT (object);
OstreeCheckoutPrivate *priv = GET_PRIVATE (self);
switch (prop_id)
{
case PROP_PATH:
g_value_set_string (value, priv->path);
break;
case PROP_REPO:
g_value_set_object (value, priv->repo);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GObject *
ostree_checkout_constructor (GType gtype,
guint n_properties,
GObjectConstructParam *properties)
{
GObject *object;
GObjectClass *parent_class;
OstreeCheckoutPrivate *priv;
parent_class = G_OBJECT_CLASS (ostree_checkout_parent_class);
object = parent_class->constructor (gtype, n_properties, properties);
priv = GET_PRIVATE (object);
g_assert (priv->path != NULL);
return object;
}
static void
ostree_checkout_class_init (OstreeCheckoutClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (OstreeCheckoutPrivate));
object_class->constructor = ostree_checkout_constructor;
object_class->get_property = ostree_checkout_get_property;
object_class->set_property = ostree_checkout_set_property;
object_class->finalize = ostree_checkout_finalize;
g_object_class_install_property (object_class,
PROP_PATH,
g_param_spec_string ("path", "", "",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_REPO,
g_param_spec_object ("repo", "", "",
OSTREE_TYPE_REPO,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
ostree_checkout_init (OstreeCheckout *self)
{
}
OstreeCheckout*
ostree_checkout_new (OstreeRepo *repo,
const char *path)
{
return g_object_new (OSTREE_TYPE_CHECKOUT, "repo", repo, "path", path, NULL);
}
static gboolean
executable_exists_in_checkout (const char *path,
const char *executable)
{
int i;
const char *subdirs[] = {"bin", "sbin", "usr/bin", "usr/sbin"};
for (i = 0; i < G_N_ELEMENTS (subdirs); i++)
{
char *possible_path = g_build_filename (path, subdirs[i], executable, NULL);
gboolean exists;
exists = g_file_test (possible_path, G_FILE_TEST_EXISTS);
g_free (possible_path);
if (exists)
return TRUE;
}
return FALSE;
}
static gboolean
run_trigger (OstreeCheckout *self,
GFile *trigger,
gboolean requires_chroot,
GError **error)
{
OstreeCheckoutPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE;
const char *path = NULL;
char *temp_path = NULL;
char *rel_temp_path = NULL;
GFile *temp_copy = NULL;
char *basename = NULL;
GPtrArray *args = NULL;
int estatus;
path = ot_gfile_get_path_cached (trigger);
basename = g_path_get_basename (path);
args = g_ptr_array_new ();
if (requires_chroot)
{
temp_path = g_build_filename (priv->path, basename, NULL);
rel_temp_path = g_strconcat ("./", basename, NULL);
temp_copy = ot_gfile_new_for_path (temp_path);
if (!g_file_copy (trigger, temp_copy, 0, NULL, NULL, NULL, error))
goto out;
g_ptr_array_add (args, "chroot");
g_ptr_array_add (args, ".");
g_ptr_array_add (args, rel_temp_path);
g_ptr_array_add (args, NULL);
}
else
{
g_ptr_array_add (args, (char*)path);
g_ptr_array_add (args, NULL);
}
g_print ("Running trigger: %s\n", path);
if (!g_spawn_sync (priv->path,
(char**)args->pdata,
NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL,
&estatus,
error))
{
g_prefix_error (error, "Failed to run trigger %s: ", basename);
goto out;
}
ret = TRUE;
out:
if (requires_chroot && temp_path)
(void)unlink (temp_path);
g_free (basename);
g_free (temp_path);
g_free (rel_temp_path);
g_clear_object (&temp_copy);
if (args)
g_ptr_array_free (args, TRUE);
return ret;
}
static gboolean
check_trigger (OstreeCheckout *self,
GFile *trigger,
GError **error)
{
OstreeCheckoutPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE;
GInputStream *instream = NULL;
GDataInputStream *datain = NULL;
GError *temp_error = NULL;
char *line;
gsize len;
gboolean requires_chroot = TRUE;
gboolean matches = FALSE;
instream = (GInputStream*)g_file_read (trigger, NULL, error);
if (!instream)
goto out;
datain = g_data_input_stream_new (instream);
while ((line = g_data_input_stream_read_line (datain, &len, NULL, &temp_error)) != NULL)
{
if (g_str_has_prefix (line, "# IfExecutable: "))
{
char *executable = g_strdup (line + strlen ("# IfExecutable: "));
g_strchomp (executable);
matches = executable_exists_in_checkout (priv->path, executable);
g_free (executable);
}
g_free (line);
}
if (line == NULL && temp_error != NULL)
{
g_propagate_error (error, temp_error);
goto out;
}
if (matches)
{
if (!run_trigger (self, trigger, requires_chroot, error))
goto out;
}
ret = TRUE;
out:
g_clear_object (&instream);
g_clear_object (&datain);
return ret;
}
gboolean
ostree_checkout_run_triggers (OstreeCheckout *self,
GError **error)
{
gboolean ret = FALSE;
GError *temp_error = NULL;
char *triggerdir_path = NULL;
GFile *triggerdir = NULL;
GFileInfo *file_info = NULL;
GFileEnumerator *enumerator = NULL;
triggerdir_path = g_build_filename (LIBEXECDIR, "ostree", "triggers.d", NULL);
triggerdir = ot_gfile_new_for_path (triggerdir_path);
enumerator = g_file_enumerate_children (triggerdir, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL,
error);
if (!enumerator)
goto out;
while ((file_info = g_file_enumerator_next_file (enumerator, NULL, &temp_error)) != NULL)
{
const char *name;
guint32 type;
char *child_path = NULL;
GFile *child = NULL;
gboolean success;
name = g_file_info_get_attribute_byte_string (file_info, "standard::name");
type = g_file_info_get_attribute_uint32 (file_info, "standard::type");
if (type == G_FILE_TYPE_REGULAR && g_str_has_suffix (name, ".trigger"))
{
child_path = g_build_filename (triggerdir_path, name, NULL);
child = ot_gfile_new_for_path (child_path);
success = check_trigger (self, child, error);
}
else
success = TRUE;
g_object_unref (file_info);
g_free (child_path);
g_clear_object (&child);
if (!success)
goto out;
}
if (file_info == NULL && temp_error != NULL)
{
g_propagate_error (error, temp_error);
goto out;
}
ret = TRUE;
out:
g_free (triggerdir_path);
g_clear_object (&triggerdir);
g_clear_object (&enumerator);
return ret;
}

View File

@ -1,60 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Colin Walters <walters@verbum.org>
*/
#ifndef _OSTREE_CHECKOUT
#define _OSTREE_CHECKOUT
#include <ostree-repo.h>
G_BEGIN_DECLS
#define OSTREE_TYPE_CHECKOUT ostree_checkout_get_type()
#define OSTREE_CHECKOUT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), OSTREE_TYPE_CHECKOUT, OstreeCheckout))
#define OSTREE_CHECKOUT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), OSTREE_TYPE_CHECKOUT, OstreeCheckoutClass))
#define OSTREE_IS_CHECKOUT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSTREE_TYPE_CHECKOUT))
#define OSTREE_IS_CHECKOUT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), OSTREE_TYPE_CHECKOUT))
#define OSTREE_CHECKOUT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), OSTREE_TYPE_CHECKOUT, OstreeCheckoutClass))
typedef struct {
GObject parent;
} OstreeCheckout;
typedef struct {
GObjectClass parent_class;
} OstreeCheckoutClass;
GType ostree_checkout_get_type (void);
OstreeCheckout* ostree_checkout_new (OstreeRepo *repo,
const char *path);
gboolean ostree_checkout_run_triggers (OstreeCheckout *checkout,
GError **error);
G_END_DECLS
#endif /* _OSTREE_CHECKOUT */

View File

@ -24,7 +24,6 @@
#include <ostree-core.h>
#include <ostree-repo.h>
#include <ostree-checkout.h>
#include <ostree-mutable-tree.h>
#include <ostree-repo-file.h>

View File

@ -43,7 +43,6 @@ static OstreeBuiltin builtins[] = {
{ "remote", ostree_builtin_remote, 0 },
{ "rev-parse", ostree_builtin_rev_parse, 0 },
{ "remote", ostree_builtin_remote, 0 },
{ "run-triggers", ostree_builtin_run_triggers, 0 },
{ "show", ostree_builtin_show, 0 },
{ NULL }
};

View File

@ -40,7 +40,6 @@ ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error
GOptionContext *context;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
OstreeCheckout *checkout = NULL;
const char *commit;
const char *destination;
GFile *destf = NULL;
@ -79,7 +78,6 @@ ostree_builtin_checkout (int argc, char **argv, GFile *repo_path, GError **error
if (context)
g_option_context_free (context);
g_clear_object (&repo);
g_clear_object (&checkout);
g_clear_object (&destf);
return ret;
}

View File

@ -93,7 +93,6 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
GOptionContext *context;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
OstreeCheckout *checkout = NULL;
char *parent = NULL;
GFile *destf = NULL;
GHashTable *seen_branches = NULL;
@ -286,7 +285,6 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
if (parent_commit_compose_iter)
g_variant_iter_free (parent_commit_compose_iter);
g_clear_object (&repo);
g_clear_object (&checkout);
g_clear_object (&destf);
g_clear_object (&metadata_f);
g_clear_object (&mtree);

View File

@ -47,7 +47,6 @@ ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error)
GOptionContext *context;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
OstreeCheckout *checkout = NULL;
const char *op;
GKeyFile *config = NULL;
@ -99,6 +98,5 @@ ostree_builtin_remote (int argc, char **argv, GFile *repo_path, GError **error)
if (config)
g_key_file_free (config);
g_clear_object (&repo);
g_clear_object (&checkout);
return ret;
}

View File

@ -1,79 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2011 Colin Walters <walters@verbum.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Colin Walters <walters@verbum.org>
*/
#include "config.h"
#include "ot-builtins.h"
#include "ostree.h"
#include <glib/gi18n.h>
static gboolean quiet;
static GOptionEntry options[] = {
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
{ NULL }
};
gboolean
ostree_builtin_run_triggers (int argc, char **argv, GFile *repo_path, GError **error)
{
GOptionContext *context;
gboolean ret = FALSE;
OstreeRepo *repo = NULL;
OstreeCheckout *checkout = NULL;
const char *dir;
context = g_option_context_new ("DIR - Run trigger scripts for directory");
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
repo = ostree_repo_new (repo_path);
if (!ostree_repo_check (repo, error))
goto out;
if (argc < 1)
{
gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_printerr ("%s\n", help);
g_free (help);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"DIR must be specified");
goto out;
}
dir = argv[1];
checkout = ostree_checkout_new (repo, dir);
if (!ostree_checkout_run_triggers (checkout, error))
goto out;
ret = TRUE;
out:
if (context)
g_option_context_free (context);
g_clear_object (&repo);
g_clear_object (&checkout);
return ret;
}

View File

@ -36,7 +36,6 @@ gboolean ostree_builtin_init (int argc, char **argv, GFile *repo_path, GError **
gboolean ostree_builtin_local_clone (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_log (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_ls (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_run_triggers (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_fsck (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_show (int argc, char **argv, GFile *repo_path, GError **error);
gboolean ostree_builtin_rev_parse (int argc, char **argv, GFile *repo_path, GError **error);

View File

@ -0,0 +1,221 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2011,2012 Colin Walters <walters@verbum.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Colin Walters <walters@verbum.org>
*/
#include "config.h"
#include <gio/gio.h>
#include <string.h>
static gboolean quiet;
static GOptionEntry options[] = {
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
{ NULL }
};
static gboolean
run_trigger (const char *path,
GError **error)
{
gboolean ret = FALSE;
char *basename = NULL;
GPtrArray *args = NULL;
int estatus;
basename = g_path_get_basename (path);
args = g_ptr_array_new ();
g_ptr_array_add (args, (char*)path);
g_ptr_array_add (args, NULL);
g_print ("Running trigger: %s\n", path);
if (!g_spawn_sync (NULL,
(char**)args->pdata,
NULL,
0,
NULL, NULL, NULL, NULL,
&estatus,
error))
{
g_prefix_error (error, "Failed to run trigger %s: ", basename);
goto out;
}
ret = TRUE;
out:
g_free (basename);
if (args)
g_ptr_array_free (args, TRUE);
return ret;
}
static gboolean
check_trigger (GFile *trigger,
GError **error)
{
gboolean ret = FALSE;
GInputStream *instream = NULL;
GDataInputStream *datain = NULL;
GError *temp_error = NULL;
char *line;
gsize len;
char *ifexecutable_path = NULL;
char *trigger_path = NULL;
gboolean matched = TRUE;
trigger_path = g_file_get_path (trigger);
instream = (GInputStream*)g_file_read (trigger, NULL, error);
if (!instream)
goto out;
datain = g_data_input_stream_new (instream);
while ((line = g_data_input_stream_read_line (datain, &len, NULL, &temp_error)) != NULL)
{
if (g_str_has_prefix (line, "# IfExecutable: "))
{
char *executable = g_strdup (line + strlen ("# IfExecutable: "));
g_strchomp (executable);
g_free (ifexecutable_path);
ifexecutable_path = g_find_program_in_path (executable);
g_free (executable);
if (!ifexecutable_path)
{
matched = FALSE;
break;
}
break;
}
g_free (line);
}
if (line == NULL && temp_error != NULL)
{
g_propagate_error (error, temp_error);
goto out;
}
if (matched)
{
if (!run_trigger (trigger_path, error))
goto out;
}
ret = TRUE;
out:
g_free (trigger_path);
g_free (ifexecutable_path);
g_clear_object (&instream);
g_clear_object (&datain);
return ret;
}
gboolean
run_triggers (GError **error)
{
gboolean ret = FALSE;
GError *temp_error = NULL;
char *triggerdir_path = NULL;
GFile *triggerdir = NULL;
GFileInfo *file_info = NULL;
GFileEnumerator *enumerator = NULL;
triggerdir_path = g_build_filename (LIBEXECDIR, "ostree", "triggers.d", NULL);
triggerdir = g_file_new_for_path (triggerdir_path);
enumerator = g_file_enumerate_children (triggerdir, "standard::name,standard::type",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL,
error);
if (!enumerator)
goto out;
while ((file_info = g_file_enumerator_next_file (enumerator, NULL, &temp_error)) != NULL)
{
const char *name;
guint32 type;
char *child_path = NULL;
GFile *child = NULL;
gboolean success;
name = g_file_info_get_attribute_byte_string (file_info, "standard::name");
type = g_file_info_get_attribute_uint32 (file_info, "standard::type");
if (type == G_FILE_TYPE_REGULAR && g_str_has_suffix (name, ".trigger"))
{
child_path = g_build_filename (triggerdir_path, name, NULL);
child = g_file_new_for_path (child_path);
success = check_trigger (child, error);
}
else
success = TRUE;
g_object_unref (file_info);
g_free (child_path);
g_clear_object (&child);
if (!success)
goto out;
}
if (file_info == NULL && temp_error != NULL)
{
g_propagate_error (error, temp_error);
goto out;
}
ret = TRUE;
out:
g_free (triggerdir_path);
g_clear_object (&triggerdir);
g_clear_object (&enumerator);
return ret;
}
int
main (int argc,
char **argv)
{
GOptionContext *context;
GError *real_error = NULL;
GError **error = &real_error;
gboolean ret = FALSE;
g_type_init ();
context = g_option_context_new ("- Regenerate caches in operating system tree");
g_option_context_add_main_entries (context, options, NULL);
if (!g_option_context_parse (context, &argc, &argv, error))
goto out;
if (!run_triggers (error))
goto out;
ret = TRUE;
out:
if (real_error)
g_printerr ("%s\n", real_error->message);
g_clear_error (&real_error);
if (!ret)
return 1;
return 0;
}

View File

@ -22,6 +22,5 @@
# IfExecutable: pango-querymodules
# REMatch: /lib.*/pango/.*/modules/.*\.so
OSTREE_ROOT=`pwd`
DEST=./usr/etc/pango/pango.modules
DEST=/etc/pango/pango.modules
pango-querymodules > ${DEST}.tmp && mv ${DEST}.tmp ${DEST}