core: Associate branches with remotes, move trigger runs into checkout
Also add --atomic-retarget option to checkout. This does the magical symlink dance to do atomic swaps between trees.
This commit is contained in:
1 parent
3f23ac156a
commit
bae584c64a
22 files changed
+490
-164
No files matched your search
@@ -25,15 +25,16 @@
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
||||
static gboolean quiet;
|
||||
static gboolean verbose;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "Don't display informational messages", NULL },
|
||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Display informational messages", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static gboolean
|
||||
run_trigger (const char *path,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
@@ -47,8 +48,9 @@ run_trigger (const char *path,
|
||||
|
||||
g_ptr_array_add (args, (char*)path);
|
||||
g_ptr_array_add (args, NULL);
|
||||
|
||||
g_print ("Running trigger: %s\n", path);
|
||||
|
||||
if (verbose)
|
||||
g_print ("Running trigger: %s\n", path);
|
||||
if (!g_spawn_sync (NULL,
|
||||
(char**)args->pdata,
|
||||
NULL,
|
||||
@@ -69,65 +71,6 @@ run_trigger (const char *path,
|
||||
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;
|
||||
}
|
||||
|
||||
static int
|
||||
compare_files_by_basename (gconstpointer ap,
|
||||
gconstpointer bp)
|
||||
@@ -147,6 +90,7 @@ compare_files_by_basename (gconstpointer ap,
|
||||
|
||||
static gboolean
|
||||
get_sorted_triggers (GPtrArray **out_triggers,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
@@ -164,12 +108,12 @@ get_sorted_triggers (GPtrArray **out_triggers,
|
||||
|
||||
enumerator = g_file_enumerate_children (triggerdir, "standard::name,standard::type",
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL,
|
||||
cancellable,
|
||||
error);
|
||||
if (!enumerator)
|
||||
goto out;
|
||||
|
||||
while ((file_info = g_file_enumerator_next_file (enumerator, NULL, &temp_error)) != NULL)
|
||||
while ((file_info = g_file_enumerator_next_file (enumerator, cancellable, &temp_error)) != NULL)
|
||||
{
|
||||
const char *name;
|
||||
guint32 type;
|
||||
@@ -214,25 +158,31 @@ get_sorted_triggers (GPtrArray **out_triggers,
|
||||
}
|
||||
|
||||
gboolean
|
||||
run_triggers (GError **error)
|
||||
run_triggers (GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int i;
|
||||
GPtrArray *triggers = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
if (!get_sorted_triggers (&triggers, error))
|
||||
if (!get_sorted_triggers (&triggers, cancellable, error))
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < triggers->len; i++)
|
||||
{
|
||||
GFile *trigger = triggers->pdata[i];
|
||||
GFile *trigger_path = triggers->pdata[i];
|
||||
|
||||
if (!check_trigger (trigger, error))
|
||||
g_free (path);
|
||||
path = g_file_get_path (trigger_path);
|
||||
|
||||
if (!run_trigger (path, cancellable, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
g_free (path);
|
||||
if (triggers)
|
||||
g_ptr_array_unref (triggers);
|
||||
return ret;
|
||||
@@ -245,6 +195,7 @@ main (int argc,
|
||||
GOptionContext *context;
|
||||
GError *real_error = NULL;
|
||||
GError **error = &real_error;
|
||||
GCancellable *cancellable = NULL;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
g_type_init ();
|
||||
@@ -255,7 +206,7 @@ main (int argc,
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (!run_triggers (error))
|
||||
if (!run_triggers (cancellable, error))
|
||||
goto out;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# Post-installation hook for shared libraries. -*- mode: sh -*-
|
||||
#
|
||||
# Written by Colin Walters <walters@verbum.org>
|
||||
@@ -18,7 +18,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: ldconfig
|
||||
# REMatch: /lib.*/\.so.*
|
||||
|
||||
ldconfig -r .
|
||||
if test -x "$(which ldconfig 2>/dev/null)"; then
|
||||
exec ldconfig
|
||||
fi
|
||||
@@ -18,7 +18,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: update-mime-database
|
||||
# REMatch: /mime/packages/.*\.xml
|
||||
|
||||
exec update-mime-database ./usr/share/mime
|
||||
if test -x "$(which update-mime-database 2>/dev/null)"; then
|
||||
exec update-mime-database /usr/share/mime
|
||||
fi
|
||||
@@ -18,7 +18,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: dconf
|
||||
# LiteralMatch: /etc/dconf/*
|
||||
|
||||
exec dconf update
|
||||
if test -x "$(which dconf 2>/dev/null)"; then
|
||||
exec dconf update
|
||||
fi
|
||||
@@ -18,7 +18,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: glib-compile-schemas
|
||||
# LiteralMatch: /share/glib-2.0/schemas/
|
||||
|
||||
exec glib-compile-schemas ./usr/share/glib-2.0/schemas
|
||||
if test -x "$(which glib-compile-schemas 2>/dev/null)"; then
|
||||
exec glib-compile-schemas /usr/share/glib-2.0/schemas
|
||||
fi
|
||||
@@ -19,8 +19,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: gdk-pixbuf-query-loaders
|
||||
# RequiresChroot: true
|
||||
# LiteralMatch: /gdk-pixbuf-2.0/2.10.0/loaders/
|
||||
|
||||
exec gdk-pixbuf-query-loaders --update-cache
|
||||
if test -x "$(which gdk-pixbuf-query-loaders 2>/dev/null)"; then
|
||||
exec gdk-pixbuf-query-loaders --update-cache
|
||||
fi
|
||||
@@ -18,7 +18,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: gtk-query-immodules-3.0
|
||||
# REMatch: /lib.*/gtk-3\.0/3\.0\.0/immodules/.*\.so
|
||||
|
||||
gtk-query-immodules-3.0 --update-cache
|
||||
if test -x "$(which gtk-query-immodules-3.0 2>/dev/null)"; then
|
||||
exec gtk-query-immodules-3.0 --update-cache
|
||||
fi
|
||||
@@ -19,8 +19,7 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: pango-querymodules
|
||||
# REMatch: /lib.*/pango/.*/modules/.*\.so
|
||||
|
||||
DEST=/etc/pango/pango.modules
|
||||
pango-querymodules --system > ${DEST}.tmp && mv ${DEST}.tmp ${DEST}
|
||||
if test -x "$(which pango-querymodules 2>/dev/null)"; then
|
||||
DEST=/etc/pango/pango.modules
|
||||
pango-querymodules --system > ${DEST}.tmp && mv ${DEST}.tmp ${DEST}
|
||||
fi
|
||||
@@ -18,14 +18,13 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: gtk-update-icon-cache
|
||||
# LiteralMatch: /share/icons/
|
||||
|
||||
for dir in ./usr/share/icons/*; do
|
||||
if test -f $dir/index.theme; then
|
||||
if ! gtk-update-icon-cache --quiet $dir; then
|
||||
echo "Failed to run gtk-update-icon-cache for $dir"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if test -x "$(which gtk-update-icon-cache 2>/dev/null)"; then
|
||||
for dir in /usr/share/icons/*; do
|
||||
if test -f $dir/index.theme; then
|
||||
if ! gtk-update-icon-cache --quiet $dir; then
|
||||
echo "Failed to run gtk-update-icon-cache for $dir"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -18,7 +18,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
# IfExecutable: update-desktop-database
|
||||
# REMatch: /share/applications/.*/.*\.desktop
|
||||
|
||||
exec update-desktop-database -q ./usr/share/applications
|
||||
if test -x "$(which update-desktop-database 2>/dev/null)"; then
|
||||
exec update-desktop-database -q /usr/share/applications
|
||||
fi
|
||||
Reference in new issue
Block a user