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
This commit is contained in:
1 parent
826c2149b8
commit
4e81548447
11 files changed
+187
-23
No files matched your search
+11
-4
@@ -21,10 +21,17 @@ set -euo pipefail
|
||||
echo "1..16"
|
||||
|
||||
function validate_bootloader() {
|
||||
(cd ${test_tmpdir};
|
||||
if test -f sysroot/boot/syslinux/syslinux.cfg; then
|
||||
$(dirname $0)/syslinux-entries-crosscheck.py sysroot
|
||||
fi)
|
||||
cd ${test_tmpdir};
|
||||
bootloader=""
|
||||
if test -f sysroot/boot/syslinux/syslinux.cfg; then
|
||||
bootloader="syslinux"
|
||||
elif test -f sysroot/boot/grub2/grub.cfg; then
|
||||
bootloader="grub2"
|
||||
fi
|
||||
if test -n "${bootloader}"; then
|
||||
$(dirname $0)/bootloader-entries-crosscheck.py sysroot ${bootloader}
|
||||
fi
|
||||
cd -
|
||||
}
|
||||
|
||||
orig_mtime=$(stat -c '%.Y' sysroot/ostree/deploy)
|
||||
|
||||
@@ -25,9 +25,14 @@ if len(sys.argv) == 1:
|
||||
else:
|
||||
sysroot = sys.argv[1]
|
||||
|
||||
bootloader = sys.argv[2]
|
||||
loaderpath = sysroot + '/boot/loader/entries'
|
||||
syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
|
||||
|
||||
if bootloader == "grub2":
|
||||
sys.stdout.write('GRUB2 configuration validation not implemented.\n')
|
||||
sys.exit(0)
|
||||
|
||||
def fatal(msg):
|
||||
sys.stderr.write(msg)
|
||||
sys.stderr.write('\n')
|
||||
@@ -229,6 +229,20 @@ setup_os_boot_uboot() {
|
||||
ln -s loader/uEnv.txt sysroot/boot/uEnv.txt
|
||||
}
|
||||
|
||||
setup_os_boot_grub2() {
|
||||
grub2_options=$1
|
||||
mkdir -p sysroot/boot/grub2/
|
||||
ln -s ../loader/grub.cfg sysroot/boot/grub2/grub.cfg
|
||||
export OSTREE_BOOT_PARTITION="/boot"
|
||||
case "$grub2_options" in
|
||||
*ostree-grub-generator*)
|
||||
cp ${test_srcdir}/ostree-grub-generator ${test_tmpdir}
|
||||
chmod +x ${test_tmpdir}/ostree-grub-generator
|
||||
export OSTREE_GRUB2_EXEC=${test_tmpdir}/ostree-grub-generator
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
setup_os_repository () {
|
||||
mode=$1
|
||||
bootmode=$2
|
||||
@@ -301,6 +315,9 @@ EOF
|
||||
"uboot")
|
||||
setup_os_boot_uboot
|
||||
;;
|
||||
*grub2*)
|
||||
setup_os_boot_grub2 "${bootmode}"
|
||||
;;
|
||||
esac
|
||||
|
||||
cd ${test_tmpdir}
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../src/boot/grub2/ostree-grub-generator
|
||||
@@ -21,11 +21,7 @@ set -euo pipefail
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
echo "1..1"
|
||||
|
||||
# Exports OSTREE_SYSROOT so --sysroot not needed.
|
||||
setup_os_repository "archive-z2" "grub2"
|
||||
|
||||
echo "ok setup"
|
||||
setup_os_repository "archive-z2" "grub2 ostree-grub-generator"
|
||||
|
||||
. $(dirname $0)/admin-test.sh
|
||||
Reference in new issue
Block a user