summaryrefslogtreecommitdiff
path: root/src/boot/grub2/grub2-15_ostree
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@theqtcompany.com>2016-04-01 13:51:18 +0200
committerColin Walters (automation) <walters+githubbot@verbum.org>2016-04-04 14:19:35 +0000
commit4e815484470fb22a1b0dc52af0193d5ce1a3caf7 (patch)
tree6c6c0262c3543ac90a2c441af5992f4e579f6b84 /src/boot/grub2/grub2-15_ostree
parent826c2149b8e1c7be7277d9e558680139e9fd0ab7 (diff)
downloadostree-4e815484470fb22a1b0dc52af0193d5ce1a3caf7.tar.gz
Introducing ostree-grub-generator
ostree-grub-generator can be used to customize the generated grub.cfg file. Compile time decision ostree-grub-generator vs grub2-mkconfig can be overwritten with the OSTREE_GRUB2_EXEC envvar - useful for auto tests and OS installers. Why this alternative approach: 1) The current approach is less flexible than using a custom 'ostree-grub-generator' script. Each system can adjust this script for its needs, instead of using the hardcoded values from ostree-bootloader-grub2.c. 2) Too much overhead on embedded to generate grub.cfg via /etc/grub.d/ configuration files. It is still possible to do so, even with this patch applied. No need to install grub2 package on a target device. 3) The grub2-mkconfig code path has other issues: https://bugzilla.gnome.org/show_bug.cgi?id=761180 Task: https://bugzilla.gnome.org/show_bug.cgi?id=762220 Closes: #228 Approved by: cgwalters
Diffstat (limited to 'src/boot/grub2/grub2-15_ostree')
-rw-r--r--src/boot/grub2/grub2-15_ostree47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/boot/grub2/grub2-15_ostree b/src/boot/grub2/grub2-15_ostree
new file mode 100644
index 00000000..dfff6e89
--- /dev/null
+++ b/src/boot/grub2/grub2-15_ostree
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (C) 2014 Colin Walters <walters@verbum.org>
+#
+# This program 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 licence 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.
+
+# Gracefully exit if ostree is not installed
+if ! which ostree >/dev/null 2>/dev/null; then
+ exit 0
+fi
+
+# Make sure we're in the right environment
+if ! test -n "${GRUB_DEVICE}"; then
+ echo "This script must be run as a child of grub2-mkconfig" 1>&2
+ exit 1
+fi
+
+set -e
+
+# Pick up stuff from grub's helper that we want to inject into our
+# generated bootloader configuration. Yes, this is pretty awful, but
+# it's a lot better than reimplementing the config-generating bits of
+# OSTree in shell script.
+
+. /usr/share/grub/grub-mkconfig_lib
+
+DEVICE=${GRUB_DEVICE_BOOT:-${GRUB_DEVICE}}
+
+GRUB2_BOOT_DEVICE_ID="$(grub_get_device_id ${DEVICE})"
+export GRUB2_BOOT_DEVICE_ID
+GRUB2_PREPARE_ROOT_CACHE="$(prepare_grub_to_access_device ${DEVICE})"
+export GRUB2_PREPARE_ROOT_CACHE
+
+exec ostree admin instutil grub2-generate