Commit 89c49875 authored by Colin Walters's avatar Colin Walters

Move triggers from ostree to here

Previously, "ostree checkout" would by default run a set of triggers
that came with ostree itself.  This had various flaws, see the ostree
git log.
parent 5a24ae46
......@@ -33,10 +33,27 @@ bin_SCRIPTS += ostbuild \
utils_SCRIPTS = \
src/ostree-build-compile-one \
src/gnome-ostree-run-triggers \
src/ostree-build-yocto \
$(NULL)
utilsdir = $(pkglibdir)
triggersdir = $(pkglibdir)/triggers
triggers_SCRIPTS = \
src/triggers/0001ldconfig.trigger \
src/triggers/0005depmod.trigger \
src/triggers/0010mime-database.trigger \
src/triggers/0020dconf.trigger \
src/triggers/0030glib.trigger \
src/triggers/0040gdk-pixbuf.trigger \
src/triggers/0060immodules.trigger \
src/triggers/0070pango.trigger \
src/triggers/0080gtk+.trigger \
src/triggers/0090desktop-database.trigger \
src/triggers/0100fontconfig-cache.trigger \
$(NULL)
EXTRA_DIST += $(triggers_SCRIPTS)
jsostbuilddir=$(pkgdatadir)/js
jsostbuild_DATA= \
src/js/argparse.js \
......
......@@ -49,11 +49,6 @@
"config-opts": ["--disable-modular-tests",
"--enable-installed-tests"]},
{"src": "gnome:ostree",
"name": "ostree-triggers",
"bootstrap": true,
"config-opts": ["--enable-triggers-only"]},
{"src": "gnome:gnome-common",
"component": "devel"},
......
#!/bin/sh
# Copyright (C) 2013 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.
set -e
set -x
for x in ${1}/*; do ${x}; done
......@@ -138,6 +138,8 @@ const TaskBuild = new Lang.Class({
'checkout', '--user-mode', '--union',
'--from-file=' + tmpPath.get_path(), cachedRootTmp.get_path()], cancellable);
GSystem.file_unlink(tmpPath, cancellable);
this._runTriggersInRoot(cachedRootTmp, cancellable);
let builddirTmp = cachedRootTmp.get_child('ostbuild');
GSystem.file_ensure_directory(builddirTmp.resolve_relative_path('source/' + componentName), true, cancellable);
......@@ -507,17 +509,6 @@ const TaskBuild = new Lang.Class({
return this._componentBuildRefFromName(component['name'], architecture);
},
_replaceTmpWithDir: function(root, cancellable) {
// The default now is for tmp -> sysroot/tmp, which doesn't
// exist. Make tmp in the buildroot a regular dir, which
// we'll then bind mount to the host's /tmp.
let tmp = root.get_child('tmp');
if (tmp.query_file_type(Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null) == Gio.FileType.SYMBOLIC_LINK) {
GSystem.file_unlink(tmp, cancellable);
GSystem.file_ensure_directory(tmp, true, cancellable);
}
},
_buildOneComponent: function(component, architecture, cancellable, params) {
params = Params.parse(params, { installedTests: false });
let basename = component['name'];
......@@ -638,21 +629,19 @@ const TaskBuild = new Lang.Class({
}
}
this._replaceTmpWithDir(rootdir, cancellable);
childArgs = ['setarch', architecture];
childArgs.push.apply(childArgs, BuildUtil.getBaseUserChrootArgs());
childArgs.push.apply(childArgs, [
'--mount-readonly', '/',
'--mount-proc', '/proc',
'--mount-bind', '/dev', '/dev',
'--mount-bind', tmpdir.get_path(), '/tmp',
'--mount-bind', componentSrc.get_path(), chrootSourcedir.get_path(),
'--mount-bind', componentResultdir.get_path(), '/ostbuild/results',
'--chdir', chrootChdir.get_path(),
rootdir.get_path(), '/ostree-build-compile-one',
'--ostbuild-resultdir=/ostbuild/results',
'--ostbuild-meta=_ostbuild-meta.json']);
'--mount-readonly', '/',
'--mount-bind', '/', '/sysroot',
'--mount-proc', '/proc',
'--mount-bind', '/dev', '/dev',
'--mount-bind', componentSrc.get_path(), chrootSourcedir.get_path(),
'--mount-bind', componentResultdir.get_path(), '/ostbuild/results',
'--chdir', chrootChdir.get_path(),
rootdir.get_path(), '/ostree-build-compile-one',
'--ostbuild-resultdir=/ostbuild/results',
'--ostbuild-meta=_ostbuild-meta.json']);
let envCopy = {};
Lang.copyProperties(BuildUtil.BUILD_ENV, envCopy);
envCopy['PWD'] = chrootSourcedir.get_path();
......@@ -714,7 +703,9 @@ const TaskBuild = new Lang.Class({
return ostreeRevision;
},
_checkoutOneTreeCoreAsync: function(name, composeContents, cancellable, callback) {
_checkoutOneTreeCoreAsync: function(name, composeContents, cancellable, callback,
params) {
params = Params.parse(params, { runTriggers: true });
let composeRootdir = this.subworkdir.get_child(name);
print("Checking out " + composeRootdir.get_path());
GSystem.shutil_rm_rf(composeRootdir, cancellable);
......@@ -748,6 +739,9 @@ const TaskBuild = new Lang.Class({
callback(null, ""+e);
return;
}
if (params.runTriggers)
this._runTriggersInRoot(composeRootdir, cancellable);
let contentsPath = composeRootdir.resolve_relative_path('usr/share/contents.json');
GSystem.file_ensure_directory(contentsPath.get_parent(), true, cancellable);
......@@ -816,16 +810,35 @@ const TaskBuild = new Lang.Class({
}
}));
},
_runTriggersInRoot: function(rootdir, cancellable) {
let triggersScriptPath = this.libdir.resolve_relative_path('gnome-ostree-run-triggers');
let triggersPath = this.libdir.resolve_relative_path('triggers');
let childArgs = BuildUtil.getBaseUserChrootArgs();
childArgs.push.apply(childArgs, [
'--mount-bind', '/', '/sysroot',
'--mount-proc', '/proc',
'--mount-bind', '/dev', '/dev',
rootdir.get_path(), '/sysroot' + triggersScriptPath.get_path(),
'/sysroot' + triggersPath.get_path()]);
let envCopy = {};
Lang.copyProperties(BuildUtil.BUILD_ENV, envCopy);
envCopy['PWD'] = '/';
let context = new GSystem.SubprocessContext({ argv: childArgs });
context.set_environment(ProcUtil.objectToEnvironment(envCopy));
let proc = new GSystem.Subprocess({ context: context });
proc.init(cancellable);
print("Started child process " + context.argv.map(GLib.shell_quote).join(' '));
try {
proc.wait_sync_check(cancellable);
} catch (e) {
print("Trigger execution in root " + rootdir.get_path() + " failed");
throw e;
}
},
_postComposeTransform: function(composeRootdir, cancellable) {
// Create /usr/share/ostree/triggers-run; this is a temporary
// hack until the trigger functionality moves outside of ostree
// entirely.
let shareOstree = composeRootdir.resolve_relative_path('usr/share/ostree');
GSystem.file_ensure_directory(shareOstree, true, cancellable);
let triggersRunPath = shareOstree.get_child('triggers-run');
triggersRunPath.create(Gio.FileCreateFlags.REPLACE_DESTINATION, cancellable).close(cancellable);
// Move /etc to /usr/etc, since it contains defaults.
let etc = composeRootdir.resolve_relative_path("etc");
let usrEtc = composeRootdir.resolve_relative_path("usr/etc");
......@@ -958,19 +971,18 @@ const TaskBuild = new Lang.Class({
GSystem.file_ensure_directory(tmpDir, true, cancellable);
let initramfsTmp = tmpDir.get_child('initramfs-ostree.img');
this._replaceTmpWithDir(composeRootdir, cancellable);
// HACK: Temporarily move /usr/etc to /etc to help dracut
// find stuff, like the config file telling it to use the
// ostree module.
let etcDir = composeRootdir.resolve_relative_path('etc');
let usrEtcDir = composeRootdir.resolve_relative_path('usr/etc');
GSystem.file_rename(usrEtcDir, etcDir, cancellable);
let args = ['linux-user-chroot', '--mount-readonly', '/',
let args = ['linux-user-chroot',
'--mount-proc', '/proc',
'--mount-bind', '/dev', '/dev',
'--mount-bind', '/', '/sysroot',
'--mount-bind', tmpDir.get_path(), '/sysroot/tmp',
'--mount-bind', varDir.get_path(), '/var',
'--mount-bind', tmpDir.get_path(), '/tmp',
composeRootdir.get_path(),
'dracut', '--tmpdir=/tmp', '-f', '/tmp/initramfs-ostree.img',
kernelRelease];
......@@ -1530,7 +1542,8 @@ const TaskBuild = new Lang.Class({
if (composeTreeTaskCount == 0)
composeTreeTaskLoop.quit();
}));
}));
}),
{ runTriggers: false });
}
composeTreeTaskLoop.run();
......
#!/bin/bash
# Post-installation hook for shared libraries. -*- mode: sh -*-
#
# Written by 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.
if test -x "$(which ldconfig 2>/dev/null)"; then
exec ldconfig
fi
#!/bin/bash
# Post-installation hook for kernel modules. -*- mode: sh -*-
#
# Written by 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.
set -e
if test -x "$(which depmod 2>/dev/null)"; then
for d in /usr/lib/modules/*; do
if test -d "$d"; then depmod $(basename "$d"); fi
done
fi
#!/bin/sh
# Post-installation hook for shared-mime-info. -*- mode: sh -*-
#
# Written by Matthias Clasen <mclasen@redhat.com>
#
# 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.
if test -x "$(which update-mime-database 2>/dev/null)"; then
exec update-mime-database /usr/share/mime
fi
#!/bin/sh
# Post-installation hook for system dconf schemas. -*- mode: sh -*-
#
# Written by 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.
if test -x "$(which dconf 2>/dev/null)"; then
exec dconf update
fi
#!/bin/sh
# Post-installation hook for glib/gschema. -*- mode: sh -*-
#
# Written by 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.
if test -x "$(which glib-compile-schemas 2>/dev/null)"; then
exec glib-compile-schemas /usr/share/glib-2.0/schemas
fi
#!/bin/sh
# Post-installation hook for gdk-pixbuf. -*- mode: sh -*-
# Corresponds to gdk-pixbuf/gdk-pixbuf/Makefile.am:install-data-hook
#
# Written by 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.
if test -x "$(which gdk-pixbuf-query-loaders 2>/dev/null)"; then
exec gdk-pixbuf-query-loaders --update-cache
fi
#!/bin/sh
# Post-installation hook for GTK+ input method modules. -*- mode: sh -*-
#
# Written by Matthias Clasen <mclasen@redhat.com>
#
# 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.
if test -x "$(which gtk-query-immodules-3.0 2>/dev/null)"; then
exec gtk-query-immodules-3.0 --update-cache
fi
#!/bin/sh
# Post-installation hook for pango. -*- mode: sh -*-
# Corresponds to gdk-pixbuf/gdk-pixbuf/Makefile.am:install-data-hook
#
# Written by 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.
if test -x "$(which pango-querymodules 2>/dev/null)"; then
# Support both old and new pango-querymodules; see
# http://git.gnome.org/browse/pango/commit/?id=9bbb992671140b840bedb4339f6c326a2ae2c072
if ! pango-querymodules --system --update-cache; then
DEST=/etc/pango/pango.modules
pango-querymodules --system > ${DEST}.tmp && mv ${DEST}.tmp ${DEST}
fi
fi
#!/bin/sh
# Post-installation hook for gtk icon cache. -*- mode: sh -*-
#
# Written by 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.
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
#!/bin/sh
# Post-installation hook for desktop files. -*- mode: sh -*-
#
# Written by Matthias Clasen <mclasen@redhat.com>
#
# 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.
if test -x "$(which update-desktop-database 2>/dev/null)"; then
exec update-desktop-database -q /usr/share/applications
fi
#!/bin/sh
# Post-installation hook for the FontConfig cache -*- mode: sh -*-
#
# Written by Adrian Perez de Castro <aperez@igalia.com>
#
# 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.
if test -x "$(which fc-cache 2>/dev/null)"; then
exec fc-cache --system-only
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment