From edfde74c015b4a8b796437d315ebaf2d9c085f3a Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Mon, 28 Mar 2022 09:58:22 +0800 Subject: [PATCH 1/3] init Signed-off-by: Chunmei Xu --- grubby-8.40-1/.gitignore | 3 + grubby-8.40-1/COPYING | 340 ++ grubby-8.40-1/Makefile | 86 + grubby-8.40-1/TODO | 15 + grubby-8.40-1/grubby.8 | 241 + grubby-8.40-1/grubby.c | 4739 +++++++++++++++++ grubby-8.40-1/grubby.c.orig | 4739 +++++++++++++++++ grubby-8.40-1/installkernel | 87 + grubby-8.40-1/installkernel.8 | 27 + grubby-8.40-1/log.c | 118 + grubby-8.40-1/log.h | 27 + grubby-8.40-1/new-kernel-pkg | 926 ++++ grubby-8.40-1/new-kernel-pkg.8 | 115 + grubby-8.40-1/test.sh | 745 +++ grubby-8.40-1/test/elilo.1 | 25 + grubby-8.40-1/test/elilo.2 | 30 + grubby-8.40-1/test/extlinux.1 | 17 + grubby-8.40-1/test/extlinux.2 | 21 + grubby-8.40-1/test/extlinux.3 | 15 + grubby-8.40-1/test/extlinux.4 | 32 + grubby-8.40-1/test/extlinux.5 | 21 + grubby-8.40-1/test/extlinux.6 | 21 + grubby-8.40-1/test/grub.1 | 16 + grubby-8.40-1/test/grub.10 | 10 + grubby-8.40-1/test/grub.11 | 10 + grubby-8.40-1/test/grub.12 | 32 + .../boot/grub/device.map | 1 + .../grub.12-support_files/etc/SuSE-release | 3 + .../test/grub.12-support_files/etc/grub.conf | 2 + grubby-8.40-1/test/grub.13 | 21 + grubby-8.40-1/test/grub.14 | 96 + grubby-8.40-1/test/grub.2 | 19 + grubby-8.40-1/test/grub.3 | 16 + grubby-8.40-1/test/grub.4 | 25 + grubby-8.40-1/test/grub.5 | 21 + grubby-8.40-1/test/grub.6 | 25 + grubby-8.40-1/test/grub.7 | 30 + grubby-8.40-1/test/grub.8 | 16 + grubby-8.40-1/test/grub.9 | 9 + .../test/grub2-support_files/.gitignore | 1 + .../test/grub2-support_files/grubenv.0 | 2 + .../test/grub2-support_files/grubenv.1 | 3 + .../test/grub2-support_files/grubenv.2 | 3 + grubby-8.40-1/test/grub2.1 | 84 + grubby-8.40-1/test/grub2.10 | 84 + grubby-8.40-1/test/grub2.11 | 97 + grubby-8.40-1/test/grub2.12 | 73 + grubby-8.40-1/test/grub2.13 | 72 + grubby-8.40-1/test/grub2.14 | 111 + grubby-8.40-1/test/grub2.15 | 111 + grubby-8.40-1/test/grub2.2 | 97 + grubby-8.40-1/test/grub2.3 | 106 + grubby-8.40-1/test/grub2.4 | 108 + grubby-8.40-1/test/grub2.5 | 161 + grubby-8.40-1/test/grub2.6 | 84 + grubby-8.40-1/test/grub2.7 | 130 + grubby-8.40-1/test/grub2.8 | 142 + grubby-8.40-1/test/grub2.9 | 142 + grubby-8.40-1/test/lilo.1 | 25 + grubby-8.40-1/test/lilo.2 | 27 + grubby-8.40-1/test/lilo.3 | 34 + grubby-8.40-1/test/lilo.4 | 18 + grubby-8.40-1/test/lilo.5 | 19 + grubby-8.40-1/test/lilo.6 | 18 + grubby-8.40-1/test/lilo.7 | 31 + grubby-8.40-1/test/results/add/extlinux1.1 | 20 + grubby-8.40-1/test/results/add/extlinux1.2 | 20 + grubby-8.40-1/test/results/add/extlinux1.3 | 21 + grubby-8.40-1/test/results/add/extlinux1.4 | 21 + grubby-8.40-1/test/results/add/extlinux2.1 | 21 + grubby-8.40-1/test/results/add/extlinux5.1 | 21 + grubby-8.40-1/test/results/add/extlinux6.1 | 21 + grubby-8.40-1/test/results/add/g1.1 | 19 + grubby-8.40-1/test/results/add/g1.2 | 19 + grubby-8.40-1/test/results/add/g1.3 | 20 + grubby-8.40-1/test/results/add/g1.4 | 20 + grubby-8.40-1/test/results/add/g1.5 | 19 + grubby-8.40-1/test/results/add/g1.6 | 19 + grubby-8.40-1/test/results/add/g1.7 | 97 + grubby-8.40-1/test/results/add/g11.1 | 13 + grubby-8.40-1/test/results/add/g2-1.1 | 96 + grubby-8.40-1/test/results/add/g2-1.10 | 96 + grubby-8.40-1/test/results/add/g2-1.11 | 98 + grubby-8.40-1/test/results/add/g2-1.12 | 86 + grubby-8.40-1/test/results/add/g2-1.13 | 85 + grubby-8.40-1/test/results/add/g2-1.14 | 126 + grubby-8.40-1/test/results/add/g2-1.15 | 126 + grubby-8.40-1/test/results/add/g2-1.2 | 96 + grubby-8.40-1/test/results/add/g2-1.3 | 95 + grubby-8.40-1/test/results/add/g2-1.4 | 98 + grubby-8.40-1/test/results/add/g2-1.5 | 179 + grubby-8.40-1/test/results/add/g2-1.6 | 96 + grubby-8.40-1/test/results/add/g2-1.7 | 96 + grubby-8.40-1/test/results/add/g2-1.8 | 142 + grubby-8.40-1/test/results/add/g2-1.9 | 142 + grubby-8.40-1/test/results/add/g2.1 | 19 + grubby-8.40-1/test/results/add/g8.1 | 20 + grubby-8.40-1/test/results/add/g8.2 | 20 + grubby-8.40-1/test/results/add/l4.1 | 24 + grubby-8.40-1/test/results/add/l4.2 | 17 + grubby-8.40-1/test/results/add/l5.1 | 24 + grubby-8.40-1/test/results/add/l5.2 | 18 + grubby-8.40-1/test/results/add/l6.1 | 25 + grubby-8.40-1/test/results/add/l6.2 | 18 + grubby-8.40-1/test/results/add/y1.1 | 37 + grubby-8.40-1/test/results/add/y1.2 | 33 + grubby-8.40-1/test/results/add/y3.1 | 14 + grubby-8.40-1/test/results/add/z1.1 | 14 + grubby-8.40-1/test/results/add/z1.2 | 16 + grubby-8.40-1/test/results/args/extlinux1.1 | 20 + grubby-8.40-1/test/results/args/extlinux1.2 | 20 + grubby-8.40-1/test/results/args/g1.1 | 19 + grubby-8.40-1/test/results/args/g1.2 | 18 + grubby-8.40-1/test/results/debug/g2.1 | 14 + grubby-8.40-1/test/results/debug/g2.1.2 | 1 + .../test/results/default/extlinux1.1 | 19 + .../test/results/default/extlinux1.2 | 19 + .../test/results/default/extlinux3.1 | 16 + .../test/results/default/extlinux3.2 | 15 + grubby-8.40-1/test/results/default/g1.1 | 18 + grubby-8.40-1/test/results/default/g1.2 | 18 + grubby-8.40-1/test/results/default/g3.1 | 17 + grubby-8.40-1/test/results/default/g3.2 | 16 + grubby-8.40-1/test/results/default/g4.1 | 20 + grubby-8.40-1/test/results/default/g4.2 | 24 + grubby-8.40-1/test/results/default/g6.1 | 20 + grubby-8.40-1/test/results/default/l1.1 | 25 + grubby-8.40-1/test/results/default/l1.2 | 20 + grubby-8.40-1/test/results/default/l1.3 | 29 + grubby-8.40-1/test/results/default/l1.4 | 29 + grubby-8.40-1/test/results/default/z1.1 | 14 + grubby-8.40-1/test/results/default/z1.2 | 14 + grubby-8.40-1/test/results/defaultindex/0 | 1 + grubby-8.40-1/test/results/defaultindex/1 | 1 + grubby-8.40-1/test/results/defaultindex/2 | 1 + grubby-8.40-1/test/results/defaulttitle/g.1 | 1 + grubby-8.40-1/test/results/defaulttitle/g.10 | 1 + grubby-8.40-1/test/results/defaulttitle/g.11 | 1 + grubby-8.40-1/test/results/defaulttitle/g.2 | 1 + grubby-8.40-1/test/results/defaulttitle/g.3 | 1 + grubby-8.40-1/test/results/defaulttitle/g.4 | 1 + grubby-8.40-1/test/results/defaulttitle/g.5 | 1 + grubby-8.40-1/test/results/defaulttitle/g.6 | 1 + grubby-8.40-1/test/results/defaulttitle/g.7 | 1 + grubby-8.40-1/test/results/defaulttitle/g.8 | 1 + grubby-8.40-1/test/results/defaulttitle/g.9 | 1 + grubby-8.40-1/test/results/defaulttitle/g2.1 | 1 + grubby-8.40-1/test/results/defaulttitle/g2.2 | 1 + grubby-8.40-1/test/results/fallback/g5.1 | 15 + grubby-8.40-1/test/results/fallback/g5.2 | 16 + grubby-8.40-1/test/results/fallback/g5.3 | 20 + grubby-8.40-1/test/results/info/g12.1 | 8 + grubby-8.40-1/test/results/longtitle/e7.1 | 35 + grubby-8.40-1/test/results/longtitle/l1.1 | 29 + grubby-8.40-1/test/results/longtitle/l1.2 | 29 + grubby-8.40-1/test/results/longtitle/l7.1 | 35 + grubby-8.40-1/test/results/multiboot/e1.1 | 30 + grubby-8.40-1/test/results/multiboot/e1.2 | 32 + grubby-8.40-1/test/results/multiboot/e2.1 | 26 + grubby-8.40-1/test/results/multiboot/e2.2 | 25 + grubby-8.40-1/test/results/multiboot/e2.3 | 23 + grubby-8.40-1/test/results/multiboot/g1.1 | 20 + grubby-8.40-1/test/results/multiboot/g1.2 | 21 + grubby-8.40-1/test/results/multiboot/g10.1 | 14 + grubby-8.40-1/test/results/multiboot/g10.2 | 15 + grubby-8.40-1/test/results/multiboot/g10.3 | 14 + grubby-8.40-1/test/results/multiboot/g10.4 | 13 + grubby-8.40-1/test/results/multiboot/g10.5 | 6 + grubby-8.40-1/test/results/multiboot/g10.6 | 5 + grubby-8.40-1/test/results/multiboot/g10.7 | 5 + grubby-8.40-1/test/results/remove/extlinux3.1 | 10 + grubby-8.40-1/test/results/remove/extlinux4.1 | 27 + grubby-8.40-1/test/results/remove/g2-1.1 | 95 + grubby-8.40-1/test/results/remove/g2-1.2 | 97 + grubby-8.40-1/test/results/remove/g2-1.4 | 72 + grubby-8.40-1/test/results/remove/g2.1 | 14 + grubby-8.40-1/test/results/remove/g3.1 | 12 + grubby-8.40-1/test/results/remove/g7.1 | 20 + grubby-8.40-1/test/results/remove/g9.1 | 6 + grubby-8.40-1/test/results/remove/y1.1 | 25 + grubby-8.40-1/test/results/remove/y1.2 | 26 + grubby-8.40-1/test/results/remove/y2.1 | 25 + grubby-8.40-1/test/results/remove/z1.1 | 7 + grubby-8.40-1/test/results/remove/z1.2 | 7 + .../test/results/setdefaultindex/g.13.0 | 21 + .../test/results/setdefaultindex/g.13.1 | 21 + .../test/results/setdefaultindex/g.13.9 | 20 + .../test/results/setdefaultindex/g2.1.0 | 84 + .../test/results/setdefaultindex/g2.1.1 | 84 + .../test/results/setdefaultindex/g2.1.9 | 83 + .../test/results/updargs/extlinux1.1 | 17 + .../test/results/updargs/extlinux1.2 | 18 + .../test/results/updargs/extlinux3.1 | 15 + .../test/results/updargs/extlinux3.2 | 15 + .../test/results/updargs/extlinux3.4 | 15 + .../test/results/updargs/extlinux3.7 | 13 + .../test/results/updargs/extlinux4.2 | 32 + .../test/results/updargs/extlinux4.3 | 32 + .../test/results/updargs/extlinux4.4 | 32 + .../test/results/updargs/extlinux4.5 | 33 + grubby-8.40-1/test/results/updargs/g1.1 | 16 + grubby-8.40-1/test/results/updargs/g1.2 | 16 + grubby-8.40-1/test/results/updargs/g11.1 | 10 + grubby-8.40-1/test/results/updargs/g11.2 | 10 + grubby-8.40-1/test/results/updargs/g3.1 | 16 + grubby-8.40-1/test/results/updargs/g3.2 | 16 + grubby-8.40-1/test/results/updargs/g3.4 | 16 + grubby-8.40-1/test/results/updargs/g3.7 | 16 + grubby-8.40-1/test/results/updargs/g7.1 | 30 + grubby-8.40-1/test/results/updargs/g7.2 | 30 + grubby-8.40-1/test/results/updargs/g7.3 | 30 + grubby-8.40-1/test/results/updargs/g7.4 | 30 + grubby-8.40-1/test/results/updargs/g7.5 | 30 + grubby-8.40-1/test/results/updargs/l1.1 | 25 + grubby-8.40-1/test/results/updargs/l1.2 | 25 + grubby-8.40-1/test/results/updargs/l1.3 | 26 + grubby-8.40-1/test/results/updargs/l1.4 | 27 + grubby-8.40-1/test/results/updargs/l1.6 | 25 + grubby-8.40-1/test/results/updargs/l3.1 | 33 + grubby-8.40-1/test/results/updargs/l3.2 | 34 + grubby-8.40-1/test/yaboot.1 | 31 + grubby-8.40-1/test/yaboot.2 | 31 + grubby-8.40-1/test/yaboot.3 | 12 + grubby-8.40-1/test/zipl.1 | 12 + grubby-8.40-1/uboot | 43 + 225 files changed, 19297 insertions(+) create mode 100644 grubby-8.40-1/.gitignore create mode 100644 grubby-8.40-1/COPYING create mode 100644 grubby-8.40-1/Makefile create mode 100644 grubby-8.40-1/TODO create mode 100644 grubby-8.40-1/grubby.8 create mode 100644 grubby-8.40-1/grubby.c create mode 100644 grubby-8.40-1/grubby.c.orig create mode 100755 grubby-8.40-1/installkernel create mode 100644 grubby-8.40-1/installkernel.8 create mode 100644 grubby-8.40-1/log.c create mode 100644 grubby-8.40-1/log.h create mode 100755 grubby-8.40-1/new-kernel-pkg create mode 100644 grubby-8.40-1/new-kernel-pkg.8 create mode 100755 grubby-8.40-1/test.sh create mode 100644 grubby-8.40-1/test/elilo.1 create mode 100644 grubby-8.40-1/test/elilo.2 create mode 100644 grubby-8.40-1/test/extlinux.1 create mode 100644 grubby-8.40-1/test/extlinux.2 create mode 100644 grubby-8.40-1/test/extlinux.3 create mode 100644 grubby-8.40-1/test/extlinux.4 create mode 100644 grubby-8.40-1/test/extlinux.5 create mode 100644 grubby-8.40-1/test/extlinux.6 create mode 100644 grubby-8.40-1/test/grub.1 create mode 100644 grubby-8.40-1/test/grub.10 create mode 100644 grubby-8.40-1/test/grub.11 create mode 100644 grubby-8.40-1/test/grub.12 create mode 100644 grubby-8.40-1/test/grub.12-support_files/boot/grub/device.map create mode 100644 grubby-8.40-1/test/grub.12-support_files/etc/SuSE-release create mode 100644 grubby-8.40-1/test/grub.12-support_files/etc/grub.conf create mode 100644 grubby-8.40-1/test/grub.13 create mode 100644 grubby-8.40-1/test/grub.14 create mode 100644 grubby-8.40-1/test/grub.2 create mode 100644 grubby-8.40-1/test/grub.3 create mode 100644 grubby-8.40-1/test/grub.4 create mode 100644 grubby-8.40-1/test/grub.5 create mode 100644 grubby-8.40-1/test/grub.6 create mode 100644 grubby-8.40-1/test/grub.7 create mode 100644 grubby-8.40-1/test/grub.8 create mode 100644 grubby-8.40-1/test/grub.9 create mode 100644 grubby-8.40-1/test/grub2-support_files/.gitignore create mode 100644 grubby-8.40-1/test/grub2-support_files/grubenv.0 create mode 100644 grubby-8.40-1/test/grub2-support_files/grubenv.1 create mode 100644 grubby-8.40-1/test/grub2-support_files/grubenv.2 create mode 100644 grubby-8.40-1/test/grub2.1 create mode 100644 grubby-8.40-1/test/grub2.10 create mode 100644 grubby-8.40-1/test/grub2.11 create mode 100644 grubby-8.40-1/test/grub2.12 create mode 100644 grubby-8.40-1/test/grub2.13 create mode 100644 grubby-8.40-1/test/grub2.14 create mode 100644 grubby-8.40-1/test/grub2.15 create mode 100644 grubby-8.40-1/test/grub2.2 create mode 100644 grubby-8.40-1/test/grub2.3 create mode 100644 grubby-8.40-1/test/grub2.4 create mode 100644 grubby-8.40-1/test/grub2.5 create mode 100644 grubby-8.40-1/test/grub2.6 create mode 100644 grubby-8.40-1/test/grub2.7 create mode 100644 grubby-8.40-1/test/grub2.8 create mode 100644 grubby-8.40-1/test/grub2.9 create mode 100644 grubby-8.40-1/test/lilo.1 create mode 100644 grubby-8.40-1/test/lilo.2 create mode 100644 grubby-8.40-1/test/lilo.3 create mode 100644 grubby-8.40-1/test/lilo.4 create mode 100644 grubby-8.40-1/test/lilo.5 create mode 100644 grubby-8.40-1/test/lilo.6 create mode 100644 grubby-8.40-1/test/lilo.7 create mode 100644 grubby-8.40-1/test/results/add/extlinux1.1 create mode 100644 grubby-8.40-1/test/results/add/extlinux1.2 create mode 100644 grubby-8.40-1/test/results/add/extlinux1.3 create mode 100644 grubby-8.40-1/test/results/add/extlinux1.4 create mode 100644 grubby-8.40-1/test/results/add/extlinux2.1 create mode 100644 grubby-8.40-1/test/results/add/extlinux5.1 create mode 100644 grubby-8.40-1/test/results/add/extlinux6.1 create mode 100644 grubby-8.40-1/test/results/add/g1.1 create mode 100644 grubby-8.40-1/test/results/add/g1.2 create mode 100644 grubby-8.40-1/test/results/add/g1.3 create mode 100644 grubby-8.40-1/test/results/add/g1.4 create mode 100644 grubby-8.40-1/test/results/add/g1.5 create mode 100644 grubby-8.40-1/test/results/add/g1.6 create mode 100644 grubby-8.40-1/test/results/add/g1.7 create mode 100644 grubby-8.40-1/test/results/add/g11.1 create mode 100644 grubby-8.40-1/test/results/add/g2-1.1 create mode 100644 grubby-8.40-1/test/results/add/g2-1.10 create mode 100644 grubby-8.40-1/test/results/add/g2-1.11 create mode 100644 grubby-8.40-1/test/results/add/g2-1.12 create mode 100644 grubby-8.40-1/test/results/add/g2-1.13 create mode 100644 grubby-8.40-1/test/results/add/g2-1.14 create mode 100644 grubby-8.40-1/test/results/add/g2-1.15 create mode 100644 grubby-8.40-1/test/results/add/g2-1.2 create mode 100644 grubby-8.40-1/test/results/add/g2-1.3 create mode 100644 grubby-8.40-1/test/results/add/g2-1.4 create mode 100644 grubby-8.40-1/test/results/add/g2-1.5 create mode 100644 grubby-8.40-1/test/results/add/g2-1.6 create mode 100644 grubby-8.40-1/test/results/add/g2-1.7 create mode 100644 grubby-8.40-1/test/results/add/g2-1.8 create mode 100644 grubby-8.40-1/test/results/add/g2-1.9 create mode 100644 grubby-8.40-1/test/results/add/g2.1 create mode 100644 grubby-8.40-1/test/results/add/g8.1 create mode 100644 grubby-8.40-1/test/results/add/g8.2 create mode 100644 grubby-8.40-1/test/results/add/l4.1 create mode 100644 grubby-8.40-1/test/results/add/l4.2 create mode 100644 grubby-8.40-1/test/results/add/l5.1 create mode 100644 grubby-8.40-1/test/results/add/l5.2 create mode 100644 grubby-8.40-1/test/results/add/l6.1 create mode 100644 grubby-8.40-1/test/results/add/l6.2 create mode 100644 grubby-8.40-1/test/results/add/y1.1 create mode 100644 grubby-8.40-1/test/results/add/y1.2 create mode 100644 grubby-8.40-1/test/results/add/y3.1 create mode 100644 grubby-8.40-1/test/results/add/z1.1 create mode 100644 grubby-8.40-1/test/results/add/z1.2 create mode 100644 grubby-8.40-1/test/results/args/extlinux1.1 create mode 100644 grubby-8.40-1/test/results/args/extlinux1.2 create mode 100644 grubby-8.40-1/test/results/args/g1.1 create mode 100644 grubby-8.40-1/test/results/args/g1.2 create mode 100644 grubby-8.40-1/test/results/debug/g2.1 create mode 100644 grubby-8.40-1/test/results/debug/g2.1.2 create mode 100644 grubby-8.40-1/test/results/default/extlinux1.1 create mode 100644 grubby-8.40-1/test/results/default/extlinux1.2 create mode 100644 grubby-8.40-1/test/results/default/extlinux3.1 create mode 100644 grubby-8.40-1/test/results/default/extlinux3.2 create mode 100644 grubby-8.40-1/test/results/default/g1.1 create mode 100644 grubby-8.40-1/test/results/default/g1.2 create mode 100644 grubby-8.40-1/test/results/default/g3.1 create mode 100644 grubby-8.40-1/test/results/default/g3.2 create mode 100644 grubby-8.40-1/test/results/default/g4.1 create mode 100644 grubby-8.40-1/test/results/default/g4.2 create mode 100644 grubby-8.40-1/test/results/default/g6.1 create mode 100644 grubby-8.40-1/test/results/default/l1.1 create mode 100644 grubby-8.40-1/test/results/default/l1.2 create mode 100644 grubby-8.40-1/test/results/default/l1.3 create mode 100644 grubby-8.40-1/test/results/default/l1.4 create mode 100644 grubby-8.40-1/test/results/default/z1.1 create mode 100644 grubby-8.40-1/test/results/default/z1.2 create mode 100644 grubby-8.40-1/test/results/defaultindex/0 create mode 100644 grubby-8.40-1/test/results/defaultindex/1 create mode 100644 grubby-8.40-1/test/results/defaultindex/2 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.1 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.10 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.11 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.2 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.3 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.4 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.5 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.6 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.7 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.8 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g.9 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g2.1 create mode 100644 grubby-8.40-1/test/results/defaulttitle/g2.2 create mode 100644 grubby-8.40-1/test/results/fallback/g5.1 create mode 100644 grubby-8.40-1/test/results/fallback/g5.2 create mode 100644 grubby-8.40-1/test/results/fallback/g5.3 create mode 100644 grubby-8.40-1/test/results/info/g12.1 create mode 100644 grubby-8.40-1/test/results/longtitle/e7.1 create mode 100644 grubby-8.40-1/test/results/longtitle/l1.1 create mode 100644 grubby-8.40-1/test/results/longtitle/l1.2 create mode 100644 grubby-8.40-1/test/results/longtitle/l7.1 create mode 100644 grubby-8.40-1/test/results/multiboot/e1.1 create mode 100644 grubby-8.40-1/test/results/multiboot/e1.2 create mode 100644 grubby-8.40-1/test/results/multiboot/e2.1 create mode 100644 grubby-8.40-1/test/results/multiboot/e2.2 create mode 100644 grubby-8.40-1/test/results/multiboot/e2.3 create mode 100644 grubby-8.40-1/test/results/multiboot/g1.1 create mode 100644 grubby-8.40-1/test/results/multiboot/g1.2 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.1 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.2 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.3 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.4 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.5 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.6 create mode 100644 grubby-8.40-1/test/results/multiboot/g10.7 create mode 100644 grubby-8.40-1/test/results/remove/extlinux3.1 create mode 100644 grubby-8.40-1/test/results/remove/extlinux4.1 create mode 100644 grubby-8.40-1/test/results/remove/g2-1.1 create mode 100644 grubby-8.40-1/test/results/remove/g2-1.2 create mode 100644 grubby-8.40-1/test/results/remove/g2-1.4 create mode 100644 grubby-8.40-1/test/results/remove/g2.1 create mode 100644 grubby-8.40-1/test/results/remove/g3.1 create mode 100644 grubby-8.40-1/test/results/remove/g7.1 create mode 100644 grubby-8.40-1/test/results/remove/g9.1 create mode 100644 grubby-8.40-1/test/results/remove/y1.1 create mode 100644 grubby-8.40-1/test/results/remove/y1.2 create mode 100644 grubby-8.40-1/test/results/remove/y2.1 create mode 100644 grubby-8.40-1/test/results/remove/z1.1 create mode 100644 grubby-8.40-1/test/results/remove/z1.2 create mode 100644 grubby-8.40-1/test/results/setdefaultindex/g.13.0 create mode 100644 grubby-8.40-1/test/results/setdefaultindex/g.13.1 create mode 100644 grubby-8.40-1/test/results/setdefaultindex/g.13.9 create mode 100644 grubby-8.40-1/test/results/setdefaultindex/g2.1.0 create mode 100644 grubby-8.40-1/test/results/setdefaultindex/g2.1.1 create mode 100644 grubby-8.40-1/test/results/setdefaultindex/g2.1.9 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux1.1 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux1.2 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux3.1 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux3.2 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux3.4 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux3.7 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux4.2 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux4.3 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux4.4 create mode 100644 grubby-8.40-1/test/results/updargs/extlinux4.5 create mode 100644 grubby-8.40-1/test/results/updargs/g1.1 create mode 100644 grubby-8.40-1/test/results/updargs/g1.2 create mode 100644 grubby-8.40-1/test/results/updargs/g11.1 create mode 100644 grubby-8.40-1/test/results/updargs/g11.2 create mode 100644 grubby-8.40-1/test/results/updargs/g3.1 create mode 100644 grubby-8.40-1/test/results/updargs/g3.2 create mode 100644 grubby-8.40-1/test/results/updargs/g3.4 create mode 100644 grubby-8.40-1/test/results/updargs/g3.7 create mode 100644 grubby-8.40-1/test/results/updargs/g7.1 create mode 100644 grubby-8.40-1/test/results/updargs/g7.2 create mode 100644 grubby-8.40-1/test/results/updargs/g7.3 create mode 100644 grubby-8.40-1/test/results/updargs/g7.4 create mode 100644 grubby-8.40-1/test/results/updargs/g7.5 create mode 100644 grubby-8.40-1/test/results/updargs/l1.1 create mode 100644 grubby-8.40-1/test/results/updargs/l1.2 create mode 100644 grubby-8.40-1/test/results/updargs/l1.3 create mode 100644 grubby-8.40-1/test/results/updargs/l1.4 create mode 100644 grubby-8.40-1/test/results/updargs/l1.6 create mode 100644 grubby-8.40-1/test/results/updargs/l3.1 create mode 100644 grubby-8.40-1/test/results/updargs/l3.2 create mode 100644 grubby-8.40-1/test/yaboot.1 create mode 100644 grubby-8.40-1/test/yaboot.2 create mode 100644 grubby-8.40-1/test/yaboot.3 create mode 100644 grubby-8.40-1/test/zipl.1 create mode 100644 grubby-8.40-1/uboot diff --git a/grubby-8.40-1/.gitignore b/grubby-8.40-1/.gitignore new file mode 100644 index 0000000..e64d3bc --- /dev/null +++ b/grubby-8.40-1/.gitignore @@ -0,0 +1,3 @@ +grubby +version.h +*.o diff --git a/grubby-8.40-1/COPYING b/grubby-8.40-1/COPYING new file mode 100644 index 0000000..f90922e --- /dev/null +++ b/grubby-8.40-1/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/grubby-8.40-1/Makefile b/grubby-8.40-1/Makefile new file mode 100644 index 0000000..ac14404 --- /dev/null +++ b/grubby-8.40-1/Makefile @@ -0,0 +1,86 @@ +# +# Makefile +# +# Copyright 2007-2009 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +VERSION=8.40 + +TARGETS = grubby +OBJECTS = grubby.o log.o + +CC = gcc +RPM_OPT_FLAGS ?= -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector +CFLAGS += $(RPM_OPT_FLAGS) -std=gnu99 -Wall -Werror -Wno-error=unused-function -Wno-unused-function -ggdb +LDFLAGS := + +grubby_LIBS = -lblkid -lpopt + +all: grubby + +debug : clean + $(MAKE) CFLAGS="${CFLAGS} -DDEBUG=1" all + +%.o : %.c + $(CC) $(CFLAGS) -DVERSION='"$(VERSION)"' -c -o $@ $< + +test: all + @export TOPDIR=$(TOPDIR) + @./test.sh + +install: all + mkdir -p $(DESTDIR)$(PREFIX)/sbin + mkdir -p $(DESTDIR)/$(mandir)/man8 + install -m 755 new-kernel-pkg $(DESTDIR)$(PREFIX)/sbin + install -m 644 new-kernel-pkg.8 $(DESTDIR)/$(mandir)/man8 + install -m 755 installkernel $(DESTDIR)$(PREFIX)/sbin + install -m 644 installkernel.8 $(DESTDIR)/$(mandir)/man8 + if [ -f grubby ]; then \ + install -m 755 grubby $(DESTDIR)$(PREFIX)/sbin ; \ + install -m 644 grubby.8 $(DESTDIR)/$(mandir)/man8 ; \ + fi + +grubby:: $(OBJECTS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(grubby_LIBS) + +clean: + rm -f *.o grubby *~ + +GITTAG = $(VERSION)-1 + +test-archive: + @rm -rf /tmp/grubby-$(VERSION) /tmp/grubby-$(VERSION)-tmp + @mkdir -p /tmp/grubby-$(VERSION)-tmp + @git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/grubby-$(VERSION)-tmp/ ; tar x ) + @git diff | ( cd /tmp/grubby-$(VERSION)-tmp/ ; patch -s -p1 -b -z .gitdiff ) + @mv /tmp/grubby-$(VERSION)-tmp/ /tmp/grubby-$(VERSION)/ + @dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/grubby-$(VERSION).tar.bz2 grubby-$(VERSION) + @rm -rf /tmp/grubby-$(VERSION) + @echo "The archive is in grubby-$(VERSION).tar.bz2" + +archive: + git tag $(GITTAG) refs/heads/master + @rm -rf /tmp/grubby-$(VERSION) /tmp/grubby-$(VERSION)-tmp + @mkdir -p /tmp/grubby-$(VERSION)-tmp + @git archive --format=tar $(GITTAG) | ( cd /tmp/grubby-$(VERSION)-tmp/ ; tar x ) + @mv /tmp/grubby-$(VERSION)-tmp/ /tmp/grubby-$(VERSION)/ + @dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/grubby-$(VERSION).tar.bz2 grubby-$(VERSION) + @rm -rf /tmp/grubby-$(VERSION) + @echo "The archive is in grubby-$(VERSION).tar.bz2" + +upload: archive + @scp grubby-$(VERSION).tar.bz2 fedorahosted.org:grubby + diff --git a/grubby-8.40-1/TODO b/grubby-8.40-1/TODO new file mode 100644 index 0000000..efee259 --- /dev/null +++ b/grubby-8.40-1/TODO @@ -0,0 +1,15 @@ +What should grubby look like: +1) grubby the binary + 1) split each bootloader handler into a separate file + 2) split utility functions for bootloader handles into utils.c or somesuch + 3) no variables in configFileInfo, only getters/setters/RMW state changing + callbacks + 4) readConfig() doesn't manipulate configFile except to add Entry/Line state + to it + 5) meta-level parsing happens after readConfig, using configFileInfo + callbacks + 6) top level functionality to be exposed with library API + 7) maintain 100% test suite compatibility +2) new-kernel-pkg + 1) goes away mostly + 2) per-arch single scripts in /usr/lib/kernel/install.d diff --git a/grubby-8.40-1/grubby.8 b/grubby-8.40-1/grubby.8 new file mode 100644 index 0000000..355b6eb --- /dev/null +++ b/grubby-8.40-1/grubby.8 @@ -0,0 +1,241 @@ +.TH GRUBBY 8 "Tue Jan 18 2005" +.SH NAME +grubby \- command line tool for configuring grub, lilo, elilo, yaboot and zipl + +.SH SYNOPSIS +\fBgrubby\fR [--add-kernel=\fIkernel-path\fR] [--args=\fIargs\fR] + [--bad-image-okay] [--boot-filesystem=\fIbootfs\fR] + [--bootloader-probe] [--config-file \fIpath\fR] [--copy-default] + [--debug] [--default-kernel] [--default-index] [--default-title] + [--devtree=\fIdevicetree.dtb\fR] + [--grub] [--lilo] [--yaboot] [--silo] [--zipl] + [--info=\fIkernel-path\fR] [--initrd=\fIinitrd-path\fR] + [--make-default] [-o path] [--version] + [--remove-kernel=\fIkernel-path\fR] [--remove-args=\fIargs\fR] + [--set-default=\fIkernel-path\fR] [--set-default-index=\fientry-index\fR] + [--title=entry-title] [--add-multiboot=\fImultiboot-path\fR] + [--mbargs=\fIargs\fR] [--remove-multiboot=\fImultiboot-path\fR] + [--remove-mbargs=\fIargs\fR] + +.SH DESCRIPTION +\fBgrubby\fR is a command line tool for updating and displaying information +about the configuration files for the \fBgrub\fR, \fBlilo\fR, \fBelilo\fR +(ia64), \fByaboot\fR (powerpc) and \fBzipl\fR (s390) boot loaders. It +is primarily designed to be used from scripts which install new +kernels and need to find information about the current boot environment. + +On BIOS-based Intel x86 platforms, \fBgrub2\fR is the default bootloader and +the configuration file is in \fB/boot/grub2/grub.cfg\fR. On UEFI-based Intel +x86 platforms, \fBgrub2\fR is the default bootloader, and the configuration +file is in \fB/boot/efi/EFI/redhat/grub.cfg\fR. On Intel ia64 platforms, +\fBelilo\fR mode is used and the default location for the configuration file +is \fB/boot/efi/EFI/redhat/elilo.conf\fR. On PowerPC platforms, systems based +on Power8 now support \fBgrub2\fR as a bootloader and store using a default +config stored in \fB/boot/grub2/grub.cfg\fR. The earlier Power7 systems use \fByaboot\fR +parsing and the configuration file should be in \fB/etc/yaboot.conf\fR. On +s390 platforms the \fBzipl bootloader\fR will read from \fB/etc/zipl.conf\fR. + +There are a number of ways to specify the kernel used for \fB-\-info\fR, +\fB-\-remove-kernel\fR, and \fB-\-update-kernel\fR. Specificying \fBDEFAULT\fR +or \fBALL\fR selects the default entry and all of the entries, respectively. +If a comma separated list of numbers is given, the boot entries indexed +by those numbers are selected. Finally, the title of a boot entry may +be specified by using \fBTITLE=\fItitle\fR as the argument; all entries +with that title are used. + +.SH OPTIONS +.TP +\fB-\-add-kernel\fR=\fIkernel-path\fR +Add a new boot entry for the kernel located at \fIkernel-path\fR. + +.TP +\fB-\-args\fR=\fIkernel-args\fR +When a new kernel is added, this specifies the command line arguments +which should be passed to the kernel by default (note they are merged +with the arguments from the template if \fB-\-copy-default\fR is used). +When \fB-\-update-kernel\fR is used, this specifies new arguments to add +to the argument list. Multiple, space separated arguments may be used. If +an argument already exists the new value replaces the old values. The +\fBroot=\fR kernel argument gets special handling if the configuration +file has special handling for specifying the root filesystem (like +lilo.conf does). + +.TP +\fB-\-bad-image-okay\fR +When \fBgrubby\fR is looking for a entry to use for something (such +as a template or a default boot entry) it uses sanity checks, such as +ensuring that the kernel exists in the filesystem, to make sure +entries that obviously won't work aren't selected. This option overrides +that behavior, and is designed primarily for testing. + +.TP +\fB-\-boot-filesystem\fR=\fIbootfs\fR +The \fBgrub\fR boot loader expects file paths listed in it's configuration +path to be relative to the top of the filesystem they are on, rather then +relative to the current root filesystem. By default \fBgrubby\fR searches +the list of currently mounted filesystems to determine this. If this option +is given \fBgrubby\fR acts as if the specified filesystem was the filesystem +containing the kernel (this option is designed primarily for testing). + +.TP +\fB-\-bootloader-probe\fR +\fBgrubby\fR tries to determine if \fBgrub\fR or \fBlilo\fR is currently +installed. When one of those bootloaders is found the name of that bootloader +is displayed on stdout. Both could be installed (on different devices), and +grubby will print out the names of both bootloaders, one per line. The probe +for \fBgrub\fR requires a commented out boot directive \fBgrub.conf\fR +identical to the standard directive in the lilo configuration file. If this +is not present \fBgrubby\fR will assume grub is not installed (note +that \fBanaconda\fR places this directive in \fBgrub.conf\fR files it creates). +This option is only available on ia32 platforms. + + +.TP +\fB-\-config-file\fR=\fIpath\fR +Use \fIpath\fR as the configuration file rather then the default. + +.TP +\fB-\-copy-default\fR +\fBgrubby\fR will copy as much information (such as kernel arguments and +root device) as possible from the current default kernel. The kernel path +and initrd path will never be copied. + +.TP +\fB-\-debug\fR +Display extra debugging information for failures. + +.TP +\fB-\-default-kernel\fR +Display the full path to the current default kernel and exit. + +.TP +\fB-\-default-index\fR +Display the numeric index of the current default boot entry and exit. + +.TP +\fB-\-default-title\fR +Display the title of the current default boot entry and exit. + +.TP +\fB-\-devtree\fR=\fIpath\fR +Use \fIpath\fR for device tree path in place of the path of any devicetree +directive found in the template stanza. + +.TP +\fB-\-elilo\fR +Use an \fBelilo\fR style configuration file. + +.TP +\fB-\-grub\fR +Use a \fBgrub\fR style configuration file instead of \fBlilo\fR style. This +is the default on ia32 platforms. + +.TP +\fB-\-info\fR=\fIkernel-path\fR +Display information on all boot entries which match \fIkernel-path\fR. I + +.TP +\fB-\-initrd\fR=\fIinitrd-path\fR +Use \fIinitrd-path\fR as the path to an initial ram disk for a new kernel +being added. + +.TP +\fB-\-lilo\fR +Use a \fBlilo\fR style configuration file. + +.TP +\fB-\-make-default\fR +Make the new kernel entry being added the default entry. + +.TP +\fB-\-remove-args\fR=\fIkernel-args\fR +The arguments specified by \fIkernel-args\fR are removed from the +kernels specified by \fB-\-update-kernel\fR. The \fBroot\fR argument +gets special handling for configuration files that support separate root +filesystem configuration. + +.TP +\fB-\-remove-kernel\fR=\fIkernel-path\fR +Removes all boot entries which match \fIkernel-path\fR. This may be used +along with -\-add-kernel, in which case the new kernel being added will +never be removed. + +.TP +\fB-\-set-default\fR=\fIkernel-path\fR +The first entry which boots the specified kernel is made the default +boot entry. + +.TP +\fB-\-set-default-index\fR=\fIentry-index\fR +Makes the given entry number the default boot entry. + +.TP +\fB-\-title\fR=\fIentry-title\fR +When a new kernel entry is added \fIentry-title\fR is used as the title +(\fBlilo\fR label) for the entry. If \fIentry-title\fR is longer then maximum +length allowed by the bootloader (15 for lilo, unlimited for grub and elilo) +the title is shortened to a (unique) entry. + +.TP +\fB-\-update-kernel\fR=\fIkernel-path\fR +The entries for kernels matching \fRkernel-path\fR are updated. Currently +the only items that can be updated is the kernel argument list, which is +modified via the \fB-\-args\fR and \fB-\-remove-args\fR options. + +.TP +\fB-\-version\fR +Display the version of \fBgrubby\fR being run and then exit immediately. + +.TP +\fB-\-yaboot\fR +Use an \fByaboot\fR style configuration file. + +.TP +\fB-\-zipl\fR +Use an \fBzipl\fR style configuration file. + +.SH MULTIBOOT OPTIONS +The Multiboot Specification provides a genreic interface for boot +loaders and operating systems. It is supported by the GRUB bootloader. + +.TP +\fB-\-add-multiboot\fR=\fImultiboot-path\fR +Add a new boot entry for the multiboot kernel located at +\fImultiboot-path\fR. Note that this is generally accompanied with a +\fI--add-kernel\fR option. + +.TP +\fB-\-remove-multiboot\fR=\fImultiboot-path\fR +Removes all boot entries which match \fImultiboot-path\fR. + +.TP +\fB-\-mbargs\fR=\fImultiboot-args\fR +When a new multiboot kernel is added, this specifies the command line +arguments which should be passed to that kernel by default +When \fB-\-update-kernel\fR is used, this specifies new arguments to add +to the argument list. Multiple, space separated arguments may be used. If +an argument already exists the new value replaces the old values. + +.TP +\fB-\-remove-mbargs\fR=\fImultiboot-args\fR +The arguments specified by \fImultiboot-args\fR are removed from the +kernels specified by \fB-\-update-kernel\fR. + + +.SH "BUGS" +The command line syntax is more than a little baroque. This probably +won't be fixed as \fBgrubby\fR is only intended to be called from shell +scripts which can get it right. + +.SH "SEE ALSO" +.BR grub (8), +.BR lilo (8), +.BR yaboot (8), +.BR mkinitrd (8) + +.SH AUTHORS +.nf +Erik Troan +Jeremy Katz +Peter Jones +.fi diff --git a/grubby-8.40-1/grubby.c b/grubby-8.40-1/grubby.c new file mode 100644 index 0000000..c358708 --- /dev/null +++ b/grubby-8.40-1/grubby.c @@ -0,0 +1,4739 @@ +/* + * grubby.c + * + * Copyright (C) 2001-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "log.h" + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#if DEBUG +#define dbgPrintf(format, args...) fprintf(stderr, format , ## args) +#else +#define dbgPrintf(format, args...) +#endif + +int debug = 0; /* Currently just for template debugging */ + +#define _(A) (A) + +#define MAX_EXTRA_INITRDS 16 /* code segment checked by --bootloader-probe */ +#define CODE_SEG_SIZE 128 /* code segment checked by --bootloader-probe */ + +#define NOOP_OPCODE 0x90 +#define JMP_SHORT_OPCODE 0xeb + +int isEfi = 0; + +#if defined(__aarch64__) +#define isEfiOnly 1 +#else +#define isEfiOnly 0 +#endif + +char *saved_command_line = NULL; + +/* comments get lumped in with indention */ +struct lineElement { + char * item; + char * indent; +}; + +enum lineType_e { + LT_WHITESPACE = 1 << 0, + LT_TITLE = 1 << 1, + LT_KERNEL = 1 << 2, + LT_INITRD = 1 << 3, + LT_HYPER = 1 << 4, + LT_DEFAULT = 1 << 5, + LT_MBMODULE = 1 << 6, + LT_ROOT = 1 << 7, + LT_FALLBACK = 1 << 8, + LT_KERNELARGS = 1 << 9, + LT_BOOT = 1 << 10, + LT_BOOTROOT = 1 << 11, + LT_LBA = 1 << 12, + LT_OTHER = 1 << 13, + LT_GENERIC = 1 << 14, + LT_ECHO = 1 << 16, + LT_MENUENTRY = 1 << 17, + LT_ENTRY_END = 1 << 18, + LT_SET_VARIABLE = 1 << 19, + LT_KERNEL_EFI = 1 << 20, + LT_INITRD_EFI = 1 << 21, + LT_KERNEL_16 = 1 << 22, + LT_INITRD_16 = 1 << 23, + LT_DEVTREE = 1 << 24, + LT_UNKNOWN = 1 << 25, +}; + +struct singleLine { + char * indent; + int numElements; + struct lineElement * elements; + struct singleLine * next; + enum lineType_e type; +}; + +struct singleEntry { + struct singleLine * lines; + int skip; + int multiboot; + struct singleEntry * next; +}; + +#define GRUBBY_BADIMAGE_OKAY (1 << 0) + +#define GRUB_CONFIG_NO_DEFAULT (1 << 0) /* don't write out default=0 */ + +/* These defines are (only) used in addNewKernel() */ +#define NEED_KERNEL (1 << 0) +#define NEED_INITRD (1 << 1) +#define NEED_TITLE (1 << 2) +#define NEED_ARGS (1 << 3) +#define NEED_MB (1 << 4) +#define NEED_END (1 << 5) +#define NEED_DEVTREE (1 << 6) + +#define MAIN_DEFAULT (1 << 0) +#define DEFAULT_SAVED -2 +#define DEFAULT_SAVED_GRUB2 -3 + +struct keywordTypes { + char * key; + enum lineType_e type; + char nextChar; + char separatorChar; +}; + +struct configFileInfo; + +typedef const char *(*findConfigFunc)(struct configFileInfo *); +typedef const int (*writeLineFunc)(struct configFileInfo *, + struct singleLine *line); +typedef char *(*getEnvFunc)(struct configFileInfo *, char *name); +typedef int (*setEnvFunc)(struct configFileInfo *, char *name, char *value); + +struct configFileInfo { + char * defaultConfig; + findConfigFunc findConfig; + writeLineFunc writeLine; + getEnvFunc getEnv; + setEnvFunc setEnv; + struct keywordTypes * keywords; + int caseInsensitive; + int defaultIsIndex; + int defaultIsVariable; + int defaultSupportSaved; + int defaultIsSaved; + int defaultIsUnquoted; + enum lineType_e entryStart; + enum lineType_e entryEnd; + int needsBootPrefix; + int argsInQuotes; + int maxTitleLength; + int titleBracketed; + int titlePosition; + int mbHyperFirst; + int mbInitRdIsModule; + int mbConcatArgs; + int mbAllowExtraInitRds; + char *envFile; +}; + +struct keywordTypes grubKeywords[] = { + { "title", LT_TITLE, ' ' }, + { "root", LT_BOOTROOT, ' ' }, + { "default", LT_DEFAULT, ' ' }, + { "fallback", LT_FALLBACK, ' ' }, + { "kernel", LT_KERNEL, ' ' }, + { "initrd", LT_INITRD, ' ', ' ' }, + { "module", LT_MBMODULE, ' ' }, + { "kernel", LT_HYPER, ' ' }, + { NULL, 0, 0 }, +}; + +const char *grubFindConfig(struct configFileInfo *cfi) { + static const char *configFiles[] = { + "/boot/grub/menu.lst", + "/etc/grub.conf", + NULL + }; + static int i = -1; + + if (i == -1) { + for (i = 0; configFiles[i] != NULL; i++) { + dbgPrintf("Checking \"%s\": ", configFiles[i]); + if (!access(configFiles[i], R_OK)) { + dbgPrintf("found\n"); + return configFiles[i]; + } + dbgPrintf("not found\n"); + } + } + return configFiles[i]; +} + +struct configFileInfo grubConfigType = { + .findConfig = grubFindConfig, + .keywords = grubKeywords, + .defaultIsIndex = 1, + .defaultSupportSaved = 1, + .entryStart = LT_TITLE, + .needsBootPrefix = 1, + .mbHyperFirst = 1, + .mbInitRdIsModule = 1, + .mbAllowExtraInitRds = 1, + .titlePosition = 1, +}; + +struct keywordTypes grub2Keywords[] = { + { "menuentry", LT_MENUENTRY, ' ' }, + { "}", LT_ENTRY_END, ' ' }, + { "echo", LT_ECHO, ' ' }, + { "set", LT_SET_VARIABLE,' ', '=' }, + { "root", LT_BOOTROOT, ' ' }, + { "default", LT_DEFAULT, ' ' }, + { "fallback", LT_FALLBACK, ' ' }, + { "linux", LT_KERNEL, ' ' }, + { "linuxefi", LT_KERNEL_EFI, ' ' }, + { "linux16", LT_KERNEL_16, ' ' }, + { "initrd", LT_INITRD, ' ', ' ' }, + { "initrdefi", LT_INITRD_EFI, ' ', ' ' }, + { "initrd16", LT_INITRD_16, ' ', ' ' }, + { "module", LT_MBMODULE, ' ' }, + { "kernel", LT_HYPER, ' ' }, + { "devicetree", LT_DEVTREE, ' ' }, + { NULL, 0, 0 }, +}; + +const char *grub2FindConfig(struct configFileInfo *cfi) { + static const char *configFiles[] = { + "/etc/grub2-efi.cfg", + "/etc/grub2.cfg", + "/boot/grub2/grub.cfg", + "/boot/grub2-efi/grub.cfg", + NULL + }; + static int i = -1; + static const char *grub_cfg = "/boot/grub/grub.cfg"; + int rc = -1; + + if (i == -1) { + for (i = 0; configFiles[i] != NULL; i++) { + dbgPrintf("Checking \"%s\": ", configFiles[i]); + if ((rc = access(configFiles[i], R_OK))) { + if (errno == EACCES) { + printf("Unable to access bootloader configuration file " + "\"%s\": %m\n", configFiles[i]); + exit(1); + } + continue; + } else { + dbgPrintf("found\n"); + return configFiles[i]; + } + } + } + + /* Ubuntu renames grub2 to grub, so check for the grub.d directory + * that isn't in grub1, and if it exists, return the config file path + * that they use. */ + if (configFiles[i] == NULL && !access("/etc/grub.d/", R_OK)) { + dbgPrintf("found\n"); + return grub_cfg; + } + + dbgPrintf("not found\n"); + return configFiles[i]; +} + +/* kind of hacky. It'll give the first 1024 bytes, ish. */ +static char *grub2GetEnv(struct configFileInfo *info, char *name) +{ + static char buf[1025]; + char *s = NULL; + char *ret = NULL; + char *envFile = info->envFile ? info->envFile : "/boot/grub2/grubenv"; + int rc = asprintf(&s, "grub2-editenv %s list | grep '^%s='", envFile, name); + + if (rc < 0) + return NULL; + + FILE *f = popen(s, "r"); + if (!f) + goto out; + + memset(buf, '\0', sizeof (buf)); + ret = fgets(buf, 1024, f); + pclose(f); + + if (ret) { + ret += strlen(name) + 1; + ret[strlen(ret) - 1] = '\0'; + } + dbgPrintf("grub2GetEnv(%s): %s\n", name, ret); +out: + free(s); + return ret; +} + +static int sPopCount(const char *s, const char *c) +{ + int ret = 0; + if (!s) + return -1; + for (int i = 0; s[i] != '\0'; i++) + for (int j = 0; c[j] != '\0'; j++) + if (s[i] == c[j]) + ret++; + return ret; +} + +static char *shellEscape(const char *s) +{ + int l = strlen(s) + sPopCount(s, "'") * 2; + + char *ret = calloc(l+1, sizeof (*ret)); + if (!ret) + return NULL; + for (int i = 0, j = 0; s[i] != '\0'; i++, j++) { + if (s[i] == '\'') + ret[j++] = '\\'; + ret[j] = s[i]; + } + return ret; +} + +static void unquote(char *s) +{ + int l = strlen(s); + + if ((s[l-1] == '\'' && s[0] == '\'') || (s[l-1] == '"' && s[0] == '"')) { + memmove(s, s+1, l-2); + s[l-2] = '\0'; + } +} + +static int grub2SetEnv(struct configFileInfo *info, char *name, char *value) +{ + char *s = NULL; + int rc = 0; + char *envFile = info->envFile ? info->envFile : "/boot/grub2/grubenv"; + + unquote(value); + value = shellEscape(value); + if (!value) + return -1; + + rc = asprintf(&s, "grub2-editenv %s set '%s=%s'", envFile, name, value); + free(value); + if (rc <0) + return -1; + + dbgPrintf("grub2SetEnv(%s): %s\n", name, s); + rc = system(s); + free(s); + return rc; +} + +/* this is a gigantic hack to avoid clobbering grub2 variables... */ +static int is_special_grub2_variable(const char *name) +{ + if (!strcmp(name,"\"${next_entry}\"")) + return 1; + if (!strcmp(name,"\"${prev_saved_entry}\"")) + return 1; + return 0; +} + +int sizeOfSingleLine(struct singleLine * line) { + int count = 0; + + for (int i = 0; i < line->numElements; i++) { + int indentSize = 0; + + count = count + strlen(line->elements[i].item); + + indentSize = strlen(line->elements[i].indent); + if (indentSize > 0) + count = count + indentSize; + else + /* be extra safe and add room for whitespaces */ + count = count + 1; + } + + /* room for trailing terminator */ + count = count + 1; + + return count; +} + +static int isquote(char q) +{ + if (q == '\'' || q == '\"') + return 1; + return 0; +} + +static int iskernel(enum lineType_e type) { + return (type == LT_KERNEL || type == LT_KERNEL_EFI || type == LT_KERNEL_16); +} + +static int isinitrd(enum lineType_e type) { + return (type == LT_INITRD || type == LT_INITRD_EFI || type == LT_INITRD_16); +} + +char *grub2ExtractTitle(struct singleLine * line) { + char * current; + char * current_indent; + int current_len; + int current_indent_len; + int i; + + /* bail out if line does not start with menuentry */ + if (strcmp(line->elements[0].item, "menuentry")) + return NULL; + + i = 1; + current = line->elements[i].item; + current_len = strlen(current); + + /* if second word is quoted, strip the quotes and return single word */ + if (isquote(*current) && isquote(current[current_len - 1])) { + char *tmp; + + tmp = strdup(current); + *(tmp + current_len - 1) = '\0'; + return ++tmp; + } + + /* if no quotes, return second word verbatim */ + if (!isquote(*current)) + return current; + + /* second element start with a quote, so we have to find the element + * whose last character is also quote (assuming it's the closing one) */ + int resultMaxSize; + char * result; + + resultMaxSize = sizeOfSingleLine(line); + result = malloc(resultMaxSize); + snprintf(result, resultMaxSize, "%s", ++current); + + i++; + int result_len = 0; + for (; i < line->numElements; ++i) { + current = line->elements[i].item; + current_len = strlen(current); + current_indent = line->elements[i].indent; + current_indent_len = strlen(current_indent); + + memcpy(result + result_len, current_indent, current_indent_len); + result_len += current_indent_len; + + if (!isquote(current[current_len-1])) { + memcpy(result + result_len, current_indent, current_indent_len); + result_len += current_len; + } else { + memcpy(result + result_len, current_indent, current_indent_len); + result_len += (current_len - 1); + break; + } + } + result[result_len] = '\0'; + return result; +} + +struct configFileInfo grub2ConfigType = { + .findConfig = grub2FindConfig, + .getEnv = grub2GetEnv, + .setEnv = grub2SetEnv, + .keywords = grub2Keywords, + .defaultIsIndex = 1, + .defaultSupportSaved = 1, + .defaultIsVariable = 1, + .entryStart = LT_MENUENTRY, + .entryEnd = LT_ENTRY_END, + .titlePosition = 1, + .needsBootPrefix = 1, + .mbHyperFirst = 1, + .mbInitRdIsModule = 1, + .mbAllowExtraInitRds = 1, +}; + +struct keywordTypes yabootKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "bsd", LT_GENERIC, '=' }, + { "macos", LT_GENERIC, '=' }, + { "macosx", LT_GENERIC, '=' }, + { "magicboot", LT_GENERIC, '=' }, + { "darwin", LT_GENERIC, '=' }, + { "timeout", LT_GENERIC, '=' }, + { "install", LT_GENERIC, '=' }, + { "fstype", LT_GENERIC, '=' }, + { "hfstype", LT_GENERIC, '=' }, + { "delay", LT_GENERIC, '=' }, + { "defaultos", LT_GENERIC, '=' }, + { "init-message", LT_GENERIC, '=' }, + { "enablecdboot", LT_GENERIC, ' ' }, + { "enableofboot", LT_GENERIC, ' ' }, + { "enablenetboot", LT_GENERIC, ' ' }, + { "nonvram", LT_GENERIC, ' ' }, + { "hide", LT_GENERIC, ' ' }, + { "protect", LT_GENERIC, ' ' }, + { "nobless", LT_GENERIC, ' ' }, + { "nonvram", LT_GENERIC, ' ' }, + { "brokenosx", LT_GENERIC, ' ' }, + { "usemount", LT_GENERIC, ' ' }, + { "mntpoint", LT_GENERIC, '=' }, + { "partition", LT_GENERIC, '=' }, + { "device", LT_GENERIC, '=' }, + { "fstype", LT_GENERIC, '=' }, + { "initrd", LT_INITRD, '=', ';' }, + { "append", LT_KERNELARGS, '=' }, + { "boot", LT_BOOT, '=' }, + { "lba", LT_LBA, ' ' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes liloKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "other", LT_OTHER, '=' }, + { "initrd", LT_INITRD, '=' }, + { "append", LT_KERNELARGS, '=' }, + { "boot", LT_BOOT, '=' }, + { "lba", LT_LBA, ' ' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes eliloKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "initrd", LT_INITRD, '=' }, + { "append", LT_KERNELARGS, '=' }, + { "vmm", LT_HYPER, '=' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes siloKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "other", LT_OTHER, '=' }, + { "initrd", LT_INITRD, '=' }, + { "append", LT_KERNELARGS, '=' }, + { "boot", LT_BOOT, '=' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes ziplKeywords[] = { + { "target", LT_BOOTROOT, '=' }, + { "image", LT_KERNEL, '=' }, + { "ramdisk", LT_INITRD, '=' }, + { "parameters", LT_KERNELARGS, '=' }, + { "default", LT_DEFAULT, '=' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes extlinuxKeywords[] = { + { "label", LT_TITLE, ' ' }, + { "root", LT_ROOT, ' ' }, + { "default", LT_DEFAULT, ' ' }, + { "kernel", LT_KERNEL, ' ' }, + { "initrd", LT_INITRD, ' ', ',' }, + { "append", LT_KERNELARGS, ' ' }, + { "prompt", LT_UNKNOWN, ' ' }, + { "fdt", LT_DEVTREE, ' ' }, + { "fdtdir", LT_DEVTREE, ' ' }, + { NULL, 0, 0 }, +}; +int useextlinuxmenu; +struct configFileInfo eliloConfigType = { + .defaultConfig = "/boot/efi/EFI/redhat/elilo.conf", + .keywords = eliloKeywords, + .entryStart = LT_KERNEL, + .needsBootPrefix = 1, + .argsInQuotes = 1, + .mbConcatArgs = 1, + .titlePosition = 1, +}; + +struct configFileInfo liloConfigType = { + .defaultConfig = "/etc/lilo.conf", + .keywords = liloKeywords, + .entryStart = LT_KERNEL, + .argsInQuotes = 1, + .maxTitleLength = 15, + .titlePosition = 1, +}; + +struct configFileInfo yabootConfigType = { + .defaultConfig = "/etc/yaboot.conf", + .keywords = yabootKeywords, + .entryStart = LT_KERNEL, + .needsBootPrefix = 1, + .argsInQuotes = 1, + .maxTitleLength = 15, + .mbAllowExtraInitRds = 1, + .titlePosition = 1, +}; + +struct configFileInfo siloConfigType = { + .defaultConfig = "/etc/silo.conf", + .keywords = siloKeywords, + .entryStart = LT_KERNEL, + .needsBootPrefix = 1, + .argsInQuotes = 1, + .maxTitleLength = 15, + .titlePosition = 1, +}; + +struct configFileInfo ziplConfigType = { + .defaultConfig = "/etc/zipl.conf", + .keywords = ziplKeywords, + .entryStart = LT_TITLE, + .argsInQuotes = 1, + .titleBracketed = 1, +}; + +struct configFileInfo extlinuxConfigType = { + .defaultConfig = "/boot/extlinux/extlinux.conf", + .keywords = extlinuxKeywords, + .caseInsensitive = 1, + .entryStart = LT_TITLE, + .needsBootPrefix = 1, + .maxTitleLength = 255, + .mbAllowExtraInitRds = 1, + .defaultIsUnquoted = 1, + .titlePosition = 1, +}; + +struct grubConfig { + struct singleLine * theLines; + struct singleEntry * entries; + char * primaryIndent; + char * secondaryIndent; + int defaultImage; /* -1 if none specified -- this value is + * written out, overriding original */ + int fallbackImage; /* just like defaultImage */ + int flags; + struct configFileInfo * cfi; +}; + +blkid_cache blkid; + +struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index); +struct singleEntry * findEntryByPath(struct grubConfig * cfg, + const char * path, const char * prefix, + int * index); +struct singleEntry * findEntryByTitle(struct grubConfig * cfg, char *title, + int * index); +static int readFile(int fd, char ** bufPtr); +static void lineInit(struct singleLine * line); +struct singleLine * lineDup(struct singleLine * line); +static void lineFree(struct singleLine * line); +static int lineWrite(FILE * out, struct singleLine * line, + struct configFileInfo * cfi); +static int getNextLine(char ** bufPtr, struct singleLine * line, + struct configFileInfo * cfi); +static char * getRootSpecifier(char * str); +static void requote(struct singleLine *line, struct configFileInfo * cfi); +static void insertElement(struct singleLine * line, + const char * item, int insertHere, + struct configFileInfo * cfi); +static void removeElement(struct singleLine * line, int removeHere); +static struct keywordTypes * getKeywordByType(enum lineType_e type, + struct configFileInfo * cfi); +static enum lineType_e getTypeByKeyword(char * keyword, + struct configFileInfo * cfi); +static struct singleLine * getLineByType(enum lineType_e type, + struct singleLine * line); +static int checkForExtLinux(struct grubConfig * config); +struct singleLine * addLineTmpl(struct singleEntry * entry, + struct singleLine * tmplLine, + struct singleLine * prevLine, + const char * val, + struct configFileInfo * cfi); +struct singleLine * addLine(struct singleEntry * entry, + struct configFileInfo * cfi, + enum lineType_e type, char * defaultIndent, + const char * val); + +static char * sdupprintf(const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 1, 2))); +#else + ; +#endif + +static char * sdupprintf(const char *format, ...) { + char *buf = NULL; + char c; + va_list args; + size_t size = 0; + va_start(args, format); + + /* XXX requires C99 vsnprintf behavior */ + size = vsnprintf(&c, 1, format, args) + 1; + if (size == -1) { + printf("ERROR: vsnprintf behavior is not C99\n"); + abort(); + } + + va_end(args); + va_start(args, format); + + buf = malloc(size); + if (buf == NULL) + return NULL; + vsnprintf(buf, size, format, args); + va_end (args); + + return buf; +} + +static enum lineType_e preferredLineType(enum lineType_e type, + struct configFileInfo *cfi) { + if (isEfi && cfi == &grub2ConfigType) { + switch (type) { + case LT_KERNEL: + return isEfiOnly ? LT_KERNEL : LT_KERNEL_EFI; + case LT_INITRD: + return isEfiOnly ? LT_INITRD : LT_INITRD_EFI; + default: + return type; + } +#if defined(__i386__) || defined(__x86_64__) + } else if (cfi == &grub2ConfigType) { + switch (type) { + case LT_KERNEL: + return LT_KERNEL_16; + case LT_INITRD: + return LT_INITRD_16; + default: + return type; + } +#endif + } + return type; +} + +static struct keywordTypes * getKeywordByType(enum lineType_e type, + struct configFileInfo * cfi) { + for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { + if (kw->type == type) + return kw; + } + return NULL; +} + +static char *getKeyByType(enum lineType_e type, struct configFileInfo * cfi) { + struct keywordTypes *kt = getKeywordByType(type, cfi); + if (kt) + return kt->key; + return "unknown"; +} + +static char * getpathbyspec(char *device) { + if (!blkid) + blkid_get_cache(&blkid, NULL); + + return blkid_get_devname(blkid, device, NULL); +} + +static char * getuuidbydev(char *device) { + if (!blkid) + blkid_get_cache(&blkid, NULL); + + return blkid_get_tag_value(blkid, "UUID", device); +} + +static enum lineType_e getTypeByKeyword(char * keyword, + struct configFileInfo * cfi) { + for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { + if (cfi->caseInsensitive) { + if (!strcasecmp(keyword, kw->key)) + return kw->type; + } else { + if (!strcmp(keyword, kw->key)) + return kw->type; + } + } + return LT_UNKNOWN; +} + +static struct singleLine * getLineByType(enum lineType_e type, + struct singleLine * line) { + dbgPrintf("getLineByType(%d): ", type); + for (; line; line = line->next) { + dbgPrintf("%d:%s ", line->type, + line->numElements ? line->elements[0].item : "(empty)"); + if (line->type & type) break; + } + dbgPrintf(line ? "\n" : " (failed)\n"); + return line; +} + +static int isBracketedTitle(struct singleLine * line) { + if (line->numElements == 1 && *line->elements[0].item == '[') { + int len = strlen(line->elements[0].item); + if (*(line->elements[0].item + len - 1) == ']') { + /* FIXME: this is a hack... */ + if (strcmp(line->elements[0].item, "[defaultboot]")) { + return 1; + } + } + } + return 0; +} + +static int isEntryStart(struct singleLine * line, + struct configFileInfo * cfi) { + return line->type == cfi->entryStart || line->type == LT_OTHER || + (cfi->titleBracketed && isBracketedTitle(line)); +} + +/* extract the title from within brackets (for zipl) */ +static char * extractTitle(struct grubConfig *cfg, struct singleLine * line) { + /* bracketed title... let's extract it */ + char * title = NULL; + if (line->type == LT_TITLE) { + char *tmp = line->elements[cfg->cfi->titlePosition].item; + if (cfg->cfi->titleBracketed) { + tmp++; + title = strdup(tmp); + *(title + strlen(title) - 1) = '\0'; + } else { + title = strdup(tmp); + } + } else if (line->type == LT_MENUENTRY) + title = strdup(line->elements[1].item); + else + return NULL; + return title; +} + +static int readFile(int fd, char ** bufPtr) { + int alloced = 0, size = 0, i = 0; + char * buf = NULL; + + do { + size += i; + if ((size + 1024) > alloced) { + alloced += 4096; + buf = realloc(buf, alloced + 1); + } + } while ((i = read(fd, buf + size, 1024)) > 0); + + if (i < 0) { + fprintf(stderr, _("error reading input: %s\n"), strerror(errno)); + free(buf); + return 1; + } + + buf = realloc(buf, size + 2); + if (size == 0) + buf[size++] = '\n'; + else + if (buf[size - 1] != '\n') + buf[size++] = '\n'; + buf[size] = '\0'; + + *bufPtr = buf; + + return 0; +} + +static void lineInit(struct singleLine * line) { + line->indent = NULL; + line->elements = NULL; + line->numElements = 0; + line->next = NULL; +} + +struct singleLine * lineDup(struct singleLine * line) { + struct singleLine * newLine = malloc(sizeof(*newLine)); + + newLine->indent = strdup(line->indent); + newLine->next = NULL; + newLine->type = line->type; + newLine->numElements = line->numElements; + newLine->elements = malloc(sizeof(*newLine->elements) * + newLine->numElements); + + for (int i = 0; i < newLine->numElements; i++) { + newLine->elements[i].indent = strdup(line->elements[i].indent); + newLine->elements[i].item = strdup(line->elements[i].item); + } + + return newLine; +} + +static void lineFree(struct singleLine * line) { + if (line->indent) free(line->indent); + + for (int i = 0; i < line->numElements; i++) { + free(line->elements[i].item); + free(line->elements[i].indent); + } + + if (line->elements) free(line->elements); + lineInit(line); +} + +static int lineWrite(FILE * out, struct singleLine * line, + struct configFileInfo * cfi) { + if (fprintf(out, "%s", line->indent) == -1) return -1; + + for (int i = 0; i < line->numElements; i++) { + /* Need to handle this, because we strip the quotes from + * menuentry when read it. */ + if (line->type == LT_MENUENTRY && i == 1) { + if(!isquote(*line->elements[i].item)) + fprintf(out, "\'%s\'", line->elements[i].item); + else + fprintf(out, "%s", line->elements[i].item); + fprintf(out, "%s", line->elements[i].indent); + + continue; + } + + if (i == 1 && line->type == LT_KERNELARGS && cfi->argsInQuotes) + if (fputc('"', out) == EOF) return -1; + + if (fprintf(out, "%s", line->elements[i].item) == -1) return -1; + if (i < line->numElements - 1) + if (fprintf(out, "%s", line->elements[i].indent) == -1) return -1; + } + + if (line->type == LT_KERNELARGS && cfi->argsInQuotes) + if (fputc('"', out) == EOF) return -1; + + if (fprintf(out, "\n") == -1) return -1; + + return 0; +} + +/* we've guaranteed that the buffer ends w/ \n\0 */ +static int getNextLine(char ** bufPtr, struct singleLine * line, + struct configFileInfo * cfi) { + char * end; + char * start = *bufPtr; + char * chptr; + int elementsAlloced = 0; + struct lineElement * element; + int first = 1; + + lineFree(line); + + end = strchr(start, '\n'); + *end = '\0'; + *bufPtr = end + 1; + + for (chptr = start; *chptr && isspace(*chptr); chptr++) ; + + line->indent = strndup(start, chptr - start); + start = chptr; + + while (start < end) { + /* we know !isspace(*start) */ + + if (elementsAlloced == line->numElements) { + elementsAlloced += 5; + line->elements = realloc(line->elements, + sizeof(*line->elements) * elementsAlloced); + } + + element = line->elements + line->numElements; + + chptr = start; + while (*chptr && !isspace(*chptr)) { + if (first && *chptr == '=') break; + chptr++; + } + element->item = strndup(start, chptr - start); + start = chptr; + + /* lilo actually accepts the pathological case of append = " foo " */ + if (*start == '=') + chptr = start + 1; + else + chptr = start; + + do { + for (; *chptr && isspace(*chptr); chptr++); + if (*chptr == '=') + chptr = chptr + 1; + } while (isspace(*chptr)); + + element->indent = strndup(start, chptr - start); + start = chptr; + + line->numElements++; + first = 0; + } + + if (!line->numElements) + line->type = LT_WHITESPACE; + else { + line->type = getTypeByKeyword(line->elements[0].item, cfi); + if (line->type == LT_UNKNOWN) { + /* zipl does [title] instead of something reasonable like all + * the other boot loaders. kind of ugly */ + if (cfi->titleBracketed && isBracketedTitle(line)) { + line->type = LT_TITLE; + } + + /* this is awkward, but we need to be able to handle keywords + that begin with a # (specifically for #boot in grub.conf), + but still make comments lines with no elements (everything + stored in the indent */ + if (*line->elements[0].item == '#') { + char * fullLine; + int len; + + len = strlen(line->indent); + for (int i = 0; i < line->numElements; i++) + len += strlen(line->elements[i].item) + + strlen(line->elements[i].indent); + + fullLine = malloc(len + 1); + strcpy(fullLine, line->indent); + free(line->indent); + line->indent = fullLine; + + for (int i = 0; i < line->numElements; i++) { + strcat(fullLine, line->elements[i].item); + strcat(fullLine, line->elements[i].indent); + free(line->elements[i].item); + free(line->elements[i].indent); + } + + line->type = LT_WHITESPACE; + line->numElements = 0; + } + } else { + struct keywordTypes *kw; + + kw = getKeywordByType(line->type, cfi); + + /* space isn't the only separator, we need to split + * elements up more + */ + if (!isspace(kw->separatorChar)) { + char indent[2] = ""; + indent[0] = kw->separatorChar; + for (int i = 1; i < line->numElements; i++) { + char *p; + int numNewElements; + + numNewElements = 0; + p = line->elements[i].item; + while (*p != '\0') { + if (*p == kw->separatorChar) + numNewElements++; + p++; + } + if (line->numElements + numNewElements >= elementsAlloced) { + elementsAlloced += numNewElements + 5; + line->elements = realloc(line->elements, + sizeof(*line->elements) * elementsAlloced); + } + + for (int j = line->numElements; j > i; j--) { + line->elements[j + numNewElements] = line->elements[j]; + } + line->numElements += numNewElements; + + p = line->elements[i].item; + while (*p != '\0') { + + while (*p != kw->separatorChar && *p != '\0') p++; + if (*p == '\0') { + break; + } + + line->elements[i + 1].indent = line->elements[i].indent; + line->elements[i].indent = strdup(indent); + *p++ = '\0'; + i++; + line->elements[i].item = strdup(p); + } + } + } + } + } + + return 0; +} + +static int isnumber(const char *s) +{ + int i; + for (i = 0; s[i] != '\0'; i++) + if (s[i] < '0' || s[i] > '9') + return 0; + return i; +} + +static struct grubConfig * readConfig(const char * inName, + struct configFileInfo * cfi) { + int in; + char * incoming = NULL, * head; + int rc; + int sawEntry = 0; + int movedLine = 0; + struct grubConfig * cfg; + struct singleLine * last = NULL, * line, * defaultLine = NULL; + char * end; + struct singleEntry * entry = NULL; + int len; + char * buf; + + if (inName == NULL) { + printf("Could not find bootloader configuration\n"); + exit(1); + } else if (!strcmp(inName, "-")) { + in = 0; + } else { + if ((in = open(inName, O_RDONLY)) < 0) { + fprintf(stderr, _("error opening %s for read: %s\n"), + inName, strerror(errno)); + return NULL; + } + } + + rc = readFile(in, &incoming); + close(in); + if (rc) return NULL; + + head = incoming; + cfg = malloc(sizeof(*cfg)); + cfg->primaryIndent = strdup(""); + cfg->secondaryIndent = strdup("\t"); + cfg->flags = GRUB_CONFIG_NO_DEFAULT; + cfg->cfi = cfi; + cfg->theLines = NULL; + cfg->entries = NULL; + cfg->fallbackImage = 0; + + /* copy everything we have */ + while (*head) { + line = malloc(sizeof(*line)); + lineInit(line); + + if (getNextLine(&head, line, cfi)) { + free(line); + /* XXX memory leak of everything in cfg */ + return NULL; + } + + if (!sawEntry && line->numElements) { + free(cfg->primaryIndent); + cfg->primaryIndent = strdup(line->indent); + } else if (line->numElements) { + free(cfg->secondaryIndent); + cfg->secondaryIndent = strdup(line->indent); + } + + if (isEntryStart(line, cfi) || (cfg->entries && !sawEntry)) { + sawEntry = 1; + if (!entry) { + cfg->entries = malloc(sizeof(*entry)); + entry = cfg->entries; + } else { + entry->next = malloc(sizeof(*entry)); + entry = entry->next; + } + + entry->skip = 0; + entry->multiboot = 0; + entry->lines = NULL; + entry->next = NULL; + } + + if (line->type == LT_SET_VARIABLE) { + dbgPrintf("found 'set' command (%d elements): ", line->numElements); + dbgPrintf("%s", line->indent); + for (int i = 0; i < line->numElements; i++) + dbgPrintf("\"%s\"%s", line->elements[i].item, line->elements[i].indent); + dbgPrintf("\n"); + struct keywordTypes *kwType = getKeywordByType(LT_DEFAULT, cfi); + if (kwType && line->numElements == 3 && + !strcmp(line->elements[1].item, kwType->key) && + !is_special_grub2_variable(line->elements[2].item)) { + dbgPrintf("Line sets default config\n"); + cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; + defaultLine = line; + } + + } else if (iskernel(line->type)) { + /* if by some freak chance this is multiboot and the "module" + * lines came earlier in the template, make sure to use LT_HYPER + * instead of LT_KERNEL now + */ + if (entry && entry->multiboot) + line->type = LT_HYPER; + + } else if (line->type == LT_MBMODULE) { + /* go back and fix the LT_KERNEL line to indicate LT_HYPER + * instead, now that we know this is a multiboot entry. + * This only applies to grub, but that's the only place we + * should find LT_MBMODULE lines anyway. + */ + for (struct singleLine *l = entry->lines; l; l = l->next) { + if (l->type == LT_HYPER) + break; + else if (iskernel(l->type)) { + l->type = LT_HYPER; + break; + } + } + entry->multiboot = 1; + + } else if (line->type == LT_HYPER) { + entry->multiboot = 1; + + } else if (line->type == LT_FALLBACK && line->numElements == 2) { + cfg->fallbackImage = strtol(line->elements[1].item, &end, 10); + if (*end) cfg->fallbackImage = -1; + + } else if ((line->type == LT_DEFAULT && cfi->defaultIsUnquoted) || + (line->type == LT_TITLE && line->numElements > 1)) { + /* make the title/default a single argument (undoing our parsing) */ + len = 0; + for (int i = 1; i < line->numElements; i++) { + len += strlen(line->elements[i].item); + len += strlen(line->elements[i].indent); + } + buf = malloc(len + 1); + *buf = '\0'; + + for (int i = 1; i < line->numElements; i++) { + strcat(buf, line->elements[i].item); + free(line->elements[i].item); + + if ((i + 1) != line->numElements) { + strcat(buf, line->elements[i].indent); + free(line->elements[i].indent); + } + } + + line->elements[1].indent = + line->elements[line->numElements - 1].indent; + line->elements[1].item = buf; + line->numElements = 2; + } else if (line->type == LT_MENUENTRY && line->numElements > 3) { + /* let --remove-kernel="TITLE=what" work */ + len = 0; + char *extras; + char *title; + + for (int i = 1; i < line->numElements; i++) { + len += strlen(line->elements[i].item); + len += strlen(line->elements[i].indent); + } + buf = malloc(len + 1); + *buf = '\0'; + + /* allocate mem for extra flags. */ + extras = malloc(len + 1); + *extras = '\0'; + + int buf_len = 0; + /* get title. */ + for (int i = 0; i < line->numElements; i++) { + if (!strcmp(line->elements[i].item, "menuentry")) + continue; + if (isquote(*line->elements[i].item)) + title = line->elements[i].item + 1; + else + title = line->elements[i].item; + + len = strlen(title); + if (isquote(title[len-1])) { + memcpy(buf + buf_len, title, len - 1); + buf_len += (len - 1); + break; + } else { + memcpy(buf + buf_len, title, len); + buf_len += len; + len = strlen(line->elements[i].indent); + memcpy(buf + buf_len, line->elements[i].indent, len); + buf_len += len; + } + } + buf[buf_len] = '\0'; + + /* get extras */ + int count = 0; + for (int i = 0; i < line->numElements; i++) { + if (count >= 2) { + strcat(extras, line->elements[i].item); + strcat(extras, line->elements[i].indent); + } + + if (!strcmp(line->elements[i].item, "menuentry")) + continue; + + /* count ' or ", there should be two in menuentry line. */ + if (isquote(*line->elements[i].item)) + count++; + + len = strlen(line->elements[i].item); + + if (isquote(line->elements[i].item[len -1])) + count++; + + /* ok, we get the final ' or ", others are extras. */ + } + line->elements[1].indent = + line->elements[line->numElements - 2].indent; + line->elements[1].item = buf; + line->elements[2].indent = + line->elements[line->numElements - 2].indent; + line->elements[2].item = extras; + line->numElements = 3; + } else if (line->type == LT_KERNELARGS && cfi->argsInQuotes) { + /* Strip off any " which may be present; they'll be put back + on write. This is one of the few (the only?) places that grubby + canonicalizes the output */ + + if (line->numElements >= 2) { + int last, len; + + if (isquote(*line->elements[1].item)) + memmove(line->elements[1].item, line->elements[1].item + 1, + strlen(line->elements[1].item + 1) + 1); + + last = line->numElements - 1; + len = strlen(line->elements[last].item) - 1; + if (isquote(line->elements[last].item[len])) + line->elements[last].item[len] = '\0'; + } + } + + if (line->type == LT_DEFAULT && line->numElements == 2) { + cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; + defaultLine = line; + } + + /* If we find a generic config option which should live at the + top of the file, move it there. Old versions of grubby were + probably responsible for putting new images in the wrong + place in front of it anyway. */ + if (sawEntry && line->type == LT_GENERIC) { + struct singleLine **l = &cfg->theLines; + struct singleLine **last_nonws = &cfg->theLines; + while (*l) { + if ((*l)->type != LT_WHITESPACE) + last_nonws = &((*l)->next); + l = &((*l)->next); + } + line->next = *last_nonws; + *last_nonws = line; + movedLine = 1; + continue; /* without setting 'last' */ + } + + /* If a second line of whitespace happens after a generic option + which was moved, drop it. */ + if (movedLine && line->type == LT_WHITESPACE && last->type == LT_WHITESPACE) { + lineFree(line); + free(line); + movedLine = 0; + continue; + } + movedLine = 0; + + if (sawEntry) { + if (!entry->lines) + entry->lines = line; + else + last->next = line; + dbgPrintf("readConfig added %s to %p\n", getKeyByType(line->type, cfi), entry); + + /* we could have seen this outside of an entry... if so, we + * ignore it like any other line we don't grok */ + if (line->type == LT_ENTRY_END && sawEntry) + sawEntry = 0; + } else { + if (!cfg->theLines) + cfg->theLines = line; + else + last->next = line; + dbgPrintf("readConfig added %s to cfg\n", getKeyByType(line->type, cfi)); + } + + last = line; + } + + free(incoming); + + dbgPrintf("defaultLine is %s\n", defaultLine ? "set" : "unset"); + if (defaultLine) { + if (defaultLine->numElements > 2 && + cfi->defaultSupportSaved && + !strncmp(defaultLine->elements[2].item,"\"${saved_entry}\"", 16)) { + cfg->cfi->defaultIsSaved = 1; + cfg->defaultImage = DEFAULT_SAVED_GRUB2; + if (cfg->cfi->getEnv) { + char *defTitle = cfi->getEnv(cfg->cfi, "saved_entry"); + if (defTitle) { + int index = 0; + if (isnumber(defTitle)) { + index = atoi(defTitle); + entry = findEntryByIndex(cfg, index); + } else { + entry = findEntryByTitle(cfg, defTitle, &index); + } + if (entry) + cfg->defaultImage = index; + } + } + } else if (cfi->defaultIsVariable) { + char *value = defaultLine->elements[2].item; + while (*value && (*value == '"' || *value == '\'' || + *value == ' ' || *value == '\t')) + value++; + cfg->defaultImage = strtol(value, &end, 10); + while (*end && (*end == '"' || *end == '\'' || + *end == ' ' || *end == '\t')) + end++; + if (*end) cfg->defaultImage = -1; + } else if (cfi->defaultSupportSaved && + !strncmp(defaultLine->elements[1].item, "saved", 5)) { + cfg->defaultImage = DEFAULT_SAVED; + } else if (cfi->defaultIsIndex) { + cfg->defaultImage = strtol(defaultLine->elements[1].item, &end, 10); + if (*end) cfg->defaultImage = -1; + } else if (defaultLine->numElements >= 2) { + int i = 0; + while ((entry = findEntryByIndex(cfg, i))) { + for (line = entry->lines; line; line = line->next) + if (line->type == LT_TITLE) break; + + if (!cfi->titleBracketed) { + if (line && (line->numElements >= 2) && + !strcmp(defaultLine->elements[1].item, + line->elements[1].item)) break; + } else if (line) { + if (!strcmp(defaultLine->elements[1].item, + extractTitle(cfg, line))) break; + } + i++; + entry = NULL; + } + + if (entry){ + cfg->defaultImage = i; + }else{ + cfg->defaultImage = -1; + } + } + } else if (cfg->cfi->defaultIsSaved && cfg->cfi->getEnv) { + char *defTitle = cfi->getEnv(cfg->cfi, "saved_entry"); + if (defTitle) { + int index = 0; + if (isnumber(defTitle)) { + index = atoi(defTitle); + entry = findEntryByIndex(cfg, index); + } else { + entry = findEntryByTitle(cfg, defTitle, &index); + } + if (entry) + cfg->defaultImage = index; + } + } else { + cfg->defaultImage = 0; + } + + return cfg; +} + +static void writeDefault(FILE * out, char * indent, + char * separator, struct grubConfig * cfg) { + struct singleEntry * entry; + struct singleLine * line; + int i; + + if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT) return; + + if (cfg->defaultImage == DEFAULT_SAVED) + fprintf(out, "%sdefault%ssaved\n", indent, separator); + else if (cfg->cfi->defaultIsSaved) { + fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); + if (cfg->defaultImage >= 0 && cfg->cfi->setEnv) { + char *title; + entry = findEntryByIndex(cfg, cfg->defaultImage); + line = getLineByType(LT_MENUENTRY, entry->lines); + if (!line) + line = getLineByType(LT_TITLE, entry->lines); + if (line) { + title = extractTitle(cfg, line); + if (title) + cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); + } + } + } else if (cfg->defaultImage > -1) { + if (cfg->cfi->defaultIsIndex) { + if (cfg->cfi->defaultIsVariable) { + fprintf(out, "%sset default=\"%d\"\n", indent, + cfg->defaultImage); + } else { + fprintf(out, "%sdefault%s%d\n", indent, separator, + cfg->defaultImage); + } + } else { + int image = cfg->defaultImage; + + entry = cfg->entries; + while (entry && entry->skip) entry = entry->next; + + i = 0; + while (entry && i < image) { + entry = entry->next; + + while (entry && entry->skip) entry = entry->next; + i++; + } + + if (!entry) return; + + line = getLineByType(LT_TITLE, entry->lines); + + if (line && line->numElements >= 2) + fprintf(out, "%sdefault%s%s\n", indent, separator, + line->elements[1].item); + else if (line && (line->numElements == 1) && + cfg->cfi->titleBracketed) { + fprintf(out, "%sdefault%s%s\n", indent, separator, + extractTitle(cfg, line)); + } + } + } +} + +static int writeConfig(struct grubConfig * cfg, char * outName, + const char * prefix) { + FILE * out; + struct singleLine * line; + struct singleEntry * entry; + char * tmpOutName; + int needs = MAIN_DEFAULT; + struct stat sb; + int i; + + if (!strcmp(outName, "-")) { + out = stdout; + tmpOutName = NULL; + } else { + if (!lstat(outName, &sb) && S_ISLNK(sb.st_mode)) { + char * buf; + int len = 256; + int rc; + + /* most likely the symlink is relative, so change our + directory to the dir of the symlink */ + char *dir = strdupa(outName); + rc = chdir(dirname(dir)); + do { + buf = alloca(len + 1); + rc = readlink(basename(outName), buf, len); + if (rc == len) len += 256; + } while (rc == len); + + if (rc < 0) { + fprintf(stderr, _("grubby: error readlink link %s: %s\n"), + outName, strerror(errno)); + return 1; + } + + outName = buf; + outName[rc] = '\0'; + } + + tmpOutName = alloca(strlen(outName) + 2); + sprintf(tmpOutName, "%s-", outName); + out = fopen(tmpOutName, "w"); + if (!out) { + fprintf(stderr, _("grubby: error creating %s: %s\n"), tmpOutName, + strerror(errno)); + return 1; + } + + if (!stat(outName, &sb)) { + if (chmod(tmpOutName, sb.st_mode & ~(S_IFMT))) { + fprintf(stderr, _("grubby: error setting perms on %s: %s\n"), + tmpOutName, strerror(errno)); + fclose(out); + unlink(tmpOutName); + return 1; + } + } + } + + line = cfg->theLines; + struct keywordTypes *defaultKw = getKeywordByType(LT_DEFAULT, cfg->cfi); + while (line) { + if (line->type == LT_SET_VARIABLE && defaultKw && + line->numElements == 3 && + !strcmp(line->elements[1].item, defaultKw->key) && + !is_special_grub2_variable(line->elements[2].item)) { + writeDefault(out, line->indent, line->elements[0].indent, cfg); + needs &= ~MAIN_DEFAULT; + } else if (line->type == LT_DEFAULT) { + writeDefault(out, line->indent, line->elements[0].indent, cfg); + needs &= ~MAIN_DEFAULT; + } else if (line->type == LT_FALLBACK) { + if (cfg->fallbackImage > -1) + fprintf(out, "%s%s%s%d\n", line->indent, + line->elements[0].item, line->elements[0].indent, + cfg->fallbackImage); + } else { + if (lineWrite(out, line, cfg->cfi) == -1) { + fprintf(stderr, _("grubby: error writing %s: %s\n"), + tmpOutName, strerror(errno)); + fclose(out); + unlink(tmpOutName); + return 1; + } + } + + line = line->next; + } + + if (needs & MAIN_DEFAULT) { + writeDefault(out, cfg->primaryIndent, "=", cfg); + needs &= ~MAIN_DEFAULT; + } + + i = 0; + while ((entry = findEntryByIndex(cfg, i++))) { + if (entry->skip) continue; + + line = entry->lines; + while (line) { + if (lineWrite(out, line, cfg->cfi) == -1) { + fprintf(stderr, _("grubby: error writing %s: %s\n"), + tmpOutName, strerror(errno)); + fclose(out); + unlink(tmpOutName); + return 1; + } + line = line->next; + } + } + + if (tmpOutName) { + if (rename(tmpOutName, outName)) { + fprintf(stderr, _("grubby: error moving %s to %s: %s\n"), + tmpOutName, outName, strerror(errno)); + unlink(outName); + return 1; + } + } + + return 0; +} + +static int numEntries(struct grubConfig *cfg) { + int i = 0; + struct singleEntry * entry; + + entry = cfg->entries; + while (entry) { + if (!entry->skip) + i++; + entry = entry->next; + } + return i; +} + +static char *findDiskForRoot() +{ + int fd; + char buf[65536]; + char *devname; + char *chptr; + int rc; + + if ((fd = open(_PATH_MOUNTED, O_RDONLY)) < 0) { + fprintf(stderr, "grubby: failed to open %s: %s\n", + _PATH_MOUNTED, strerror(errno)); + return NULL; + } + + rc = read(fd, buf, sizeof(buf) - 1); + if (rc <= 0) { + fprintf(stderr, "grubby: failed to read %s: %s\n", + _PATH_MOUNTED, strerror(errno)); + close(fd); + return NULL; + } + close(fd); + buf[rc] = '\0'; + chptr = buf; + + char *foundanswer = NULL; + + while (chptr && chptr != buf+rc) { + devname = chptr; + + /* + * The first column of a mtab entry is the device, but if the entry is a + * special device it won't start with /, so move on to the next line. + */ + if (*devname != '/') { + chptr = strchr(chptr, '\n'); + if (chptr) + chptr++; + continue; + } + + /* Seek to the next space */ + chptr = strchr(chptr, ' '); + if (!chptr) { + fprintf(stderr, "grubby: error parsing %s: %s\n", + _PATH_MOUNTED, strerror(errno)); + return NULL; + } + + /* + * The second column of a mtab entry is the mount point, we are looking + * for '/' obviously. + */ + if (*(++chptr) == '/' && *(++chptr) == ' ') { + /* remember the last / entry in mtab */ + foundanswer = devname; + } + + /* Next line */ + chptr = strchr(chptr, '\n'); + if (chptr) + chptr++; + } + + /* Return the last / entry found */ + if (foundanswer) { + chptr = strchr(foundanswer, ' '); + *chptr = '\0'; + return strdup(foundanswer); + } + + return NULL; +} + +void printEntry(struct singleEntry * entry, FILE *f) { + int i; + struct singleLine * line; + + for (line = entry->lines; line; line = line->next) { + log_message(f, "DBG: %s", line->indent); + for (i = 0; i < line->numElements; i++) { + /* Need to handle this, because we strip the quotes from + * menuentry when read it. */ + if (line->type == LT_MENUENTRY && i == 1) { + if(!isquote(*line->elements[i].item)) + log_message(f, "\'%s\'", line->elements[i].item); + else + log_message(f, "%s", line->elements[i].item); + log_message(f, "%s", line->elements[i].indent); + + continue; + } + + log_message(f, "%s%s", + line->elements[i].item, line->elements[i].indent); + } + log_message(f, "\n"); + } +} + +void notSuitablePrintf(struct singleEntry * entry, int okay, const char *fmt, ...) +{ + static int once; + va_list argp, argq; + + va_start(argp, fmt); + + va_copy(argq, argp); + if (!once) { + log_time(NULL); + log_message(NULL, "command line: %s\n", saved_command_line); + } + log_message(NULL, "DBG: Image entry %s: ", okay ? "succeeded" : "failed"); + log_vmessage(NULL, fmt, argq); + + printEntry(entry, NULL); + va_end(argq); + + if (!debug) { + once = 1; + va_end(argp); + return; + } + + if (okay) { + va_end(argp); + return; + } + + if (!once) + log_message(stderr, "DBG: command line: %s\n", saved_command_line); + once = 1; + fprintf(stderr, "DBG: Image entry failed: "); + vfprintf(stderr, fmt, argp); + printEntry(entry, stderr); + va_end(argp); +} + +#define beginswith(s, c) ((s) && (s)[0] == (c)) + +static int endswith(const char *s, char c) +{ + int slen; + + if (!s || !s[0]) + return 0; + slen = strlen(s) - 1; + + return s[slen] == c; +} + +int suitableImage(struct singleEntry * entry, const char * bootPrefix, + int skipRemoved, int flags) { + struct singleLine * line; + char * fullName; + int i; + char * dev; + char * rootspec; + char * rootdev; + + if (skipRemoved && entry->skip) { + notSuitablePrintf(entry, 0, "marked to skip\n"); + return 0; + } + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) { + notSuitablePrintf(entry, 0, "no line found\n"); + return 0; + } + if (line->numElements < 2) { + notSuitablePrintf(entry, 0, "line has only %d elements\n", + line->numElements); + return 0; + } + + if (flags & GRUBBY_BADIMAGE_OKAY) { + notSuitablePrintf(entry, 1, "\n"); + return 1; + } + + fullName = alloca(strlen(bootPrefix) + + strlen(line->elements[1].item) + 1); + rootspec = getRootSpecifier(line->elements[1].item); + int rootspec_offset = rootspec ? strlen(rootspec) : 0; + int hasslash = endswith(bootPrefix, '/') || + beginswith(line->elements[1].item + rootspec_offset, '/'); + sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", + line->elements[1].item + rootspec_offset); + if (access(fullName, R_OK)) { + notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); + return 0; + } + for (i = 2; i < line->numElements; i++) + if (!strncasecmp(line->elements[i].item, "root=", 5)) break; + if (i < line->numElements) { + dev = line->elements[i].item + 5; + } else { + /* look for a lilo style LT_ROOT line */ + line = getLineByType(LT_ROOT, entry->lines); + + if (line && line->numElements >= 2) { + dev = line->elements[1].item; + } else { + /* didn't succeed in finding a LT_ROOT, let's try LT_KERNELARGS. + * grub+multiboot uses LT_MBMODULE for the args, so check that too. + */ + line = getLineByType(LT_KERNELARGS|LT_MBMODULE, entry->lines); + + /* failed to find one */ + if (!line) { + notSuitablePrintf(entry, 0, "no line found\n"); + return 0; + } + + for (i = 1; i < line->numElements; i++) + if (!strncasecmp(line->elements[i].item, "root=", 5)) break; + if (i < line->numElements) + dev = line->elements[i].item + 5; + else { + notSuitablePrintf(entry, 0, "no root= entry found\n"); + /* it failed too... can't find root= */ + return 0; + } + } + } + + dev = getpathbyspec(dev); + if (!getpathbyspec(dev)) { + notSuitablePrintf(entry, 0, "can't find blkid entry for %s\n", dev); + return 0; + } else + dev = getpathbyspec(dev); + + rootdev = findDiskForRoot(); + if (!rootdev) { + notSuitablePrintf(entry, 0, "can't find root device\n"); + return 0; + } + + if (!getuuidbydev(rootdev) || !getuuidbydev(dev)) { + notSuitablePrintf(entry, 0, "uuid missing: rootdev %s, dev %s\n", + getuuidbydev(rootdev), getuuidbydev(dev)); + free(rootdev); + return 0; + } + + if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) { + notSuitablePrintf(entry, 0, "uuid mismatch: rootdev %s, dev %s\n", + getuuidbydev(rootdev), getuuidbydev(dev)); + free(rootdev); + return 0; + } + + free(rootdev); + notSuitablePrintf(entry, 1, "\n"); + + return 1; +} + +/* returns the first match on or after the one pointed to by index (if index + is not NULL) which is not marked as skip */ +struct singleEntry * findEntryByPath(struct grubConfig * config, + const char * kernel, const char * prefix, + int * index) { + struct singleEntry * entry = NULL; + struct singleLine * line; + int i; + char * chptr; + char * rootspec = NULL; + enum lineType_e checkType = LT_KERNEL; + + if (isdigit(*kernel)) { + int * indexVars = alloca(sizeof(*indexVars) * strlen(kernel)); + + i = 0; + indexVars[i] = strtol(kernel, &chptr, 10); + while (*chptr == ',') { + i++; + kernel = chptr + 1; + indexVars[i] = strtol(kernel, &chptr, 10); + } + + if (*chptr) { + /* can't parse it, bail */ + return NULL; + } + + indexVars[i + 1] = -1; + + i = 0; + if (index) { + while (i < *index) { + i++; + if (indexVars[i] == -1) return NULL; + } + } + + entry = findEntryByIndex(config, indexVars[i]); + if (!entry) return NULL; + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) return NULL; + + if (index) *index = indexVars[i]; + return entry; + } + + if (!strcmp(kernel, "DEFAULT")) { + if (index && *index > config->defaultImage) { + entry = NULL; + } else { + entry = findEntryByIndex(config, config->defaultImage); + if (entry && entry->skip) + entry = NULL; + else if (index) + *index = config->defaultImage; + } + } else if (!strcmp(kernel, "ALL")) { + if (index) + i = *index; + else + i = 0; + + while ((entry = findEntryByIndex(config, i))) { + if (!entry->skip) break; + i++; + } + + if (entry && index) + *index = i; + } else { + if (index) + i = *index; + else + i = 0; + + if (!strncmp(kernel, "TITLE=", 6)) { + prefix = ""; + checkType = LT_TITLE|LT_MENUENTRY; + kernel += 6; + } + + for (entry = findEntryByIndex(config, i); entry; entry = entry->next, i++) { + if (entry->skip) continue; + + dbgPrintf("findEntryByPath looking for %d %s in %p\n", checkType, kernel, entry); + + /* check all the lines matching checkType */ + for (line = entry->lines; line; line = line->next) { + enum lineType_e ct = checkType; + if (entry->multiboot && checkType == LT_KERNEL) + ct = LT_KERNEL|LT_KERNEL_EFI|LT_MBMODULE|LT_HYPER|LT_KERNEL_16; + else if (checkType & LT_KERNEL) + ct = checkType | LT_KERNEL_EFI | LT_KERNEL_16; + line = getLineByType(ct, line); + if (!line) + break; /* not found in this entry */ + + if (line && line->type != LT_MENUENTRY && + line->numElements >= 2) { + rootspec = getRootSpecifier(line->elements[1].item); + if (!strcmp(line->elements[1].item + + ((rootspec != NULL) ? strlen(rootspec) : 0), + kernel + strlen(prefix))) + break; + } + if(line->type == LT_MENUENTRY && + !strcmp(line->elements[1].item, kernel)) + break; + } + + /* make sure this entry has a kernel identifier; this skips + * non-Linux boot entries (could find netbsd etc, though, which is + * unfortunate) + */ + if (line && getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines)) + break; /* found 'im! */ + } + + if (index) *index = i; + } + + return entry; +} + +struct singleEntry * findEntryByTitle(struct grubConfig * cfg, char *title, + int * index) { + struct singleEntry * entry; + struct singleLine * line; + int i; + char * newtitle; + + for (i = 0, entry = cfg->entries; entry; entry = entry->next, i++) { + if (index && i < *index) + continue; + line = getLineByType(LT_TITLE, entry->lines); + if (!line) + line = getLineByType(LT_MENUENTRY, entry->lines); + if (!line) + continue; + newtitle = grub2ExtractTitle(line); + if (!newtitle) + continue; + if (!strcmp(title, newtitle)) + break; + } + + if (!entry) + return NULL; + + if (index) + *index = i; + return entry; +} + +struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index) { + struct singleEntry * entry; + + entry = cfg->entries; + while (index && entry) { + entry = entry->next; + index--; + } + + return entry; +} + +/* Find a good template to use for the new kernel. An entry is + * good if the kernel and mkinitrd exist (even if the entry + * is going to be removed). Try and use the default entry, but + * if that doesn't work just take the first. If we can't find one, + * bail. */ +struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix, + int * indexPtr, int skipRemoved, int flags) { + struct singleEntry * entry, * entry2; + int index; + + if (cfg->cfi->defaultIsSaved) { + if (cfg->cfi->getEnv) { + char *defTitle = cfg->cfi->getEnv(cfg->cfi, "saved_entry"); + if (defTitle) { + int index = 0; + if (isnumber(defTitle)) { + index = atoi(defTitle); + entry = findEntryByIndex(cfg, index); + } else { + entry = findEntryByTitle(cfg, defTitle, &index); + } + if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { + cfg->defaultImage = index; + if (indexPtr) + *indexPtr = index; + return entry; + } + } + } + } else if (cfg->defaultImage > -1) { + entry = findEntryByIndex(cfg, cfg->defaultImage); + if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { + if (indexPtr) *indexPtr = cfg->defaultImage; + return entry; + } + } + + index = 0; + while ((entry = findEntryByIndex(cfg, index))) { + if (suitableImage(entry, prefix, skipRemoved, flags)) { + int j; + for (j = 0; j < index; j++) { + entry2 = findEntryByIndex(cfg, j); + if (entry2->skip) index--; + } + if (indexPtr) *indexPtr = index; + + return entry; + } + + index++; + } + + fprintf(stderr, _("grubby fatal error: unable to find a suitable template\n")); + + return NULL; +} + +char * findBootPrefix(void) { + struct stat sb, sb2; + + stat("/", &sb); +#ifdef __ia64__ + stat("/boot/efi/EFI/redhat/", &sb2); +#else + stat("/boot", &sb2); +#endif + + if (sb.st_dev == sb2.st_dev) + return strdup(""); + +#ifdef __ia64__ + return strdup("/boot/efi/EFI/redhat/"); +#else + return strdup("/boot"); +#endif +} + +void markRemovedImage(struct grubConfig * cfg, const char * image, + const char * prefix) { + struct singleEntry * entry; + + if (!image) + return; + + /* check and see if we're removing the default image */ + if (isdigit(*image)) { + entry = findEntryByPath(cfg, image, prefix, NULL); + if(entry) + entry->skip = 1; + return; + } + + while ((entry = findEntryByPath(cfg, image, prefix, NULL))) + entry->skip = 1; +} + +void setDefaultImage(struct grubConfig * config, int hasNew, + const char * defaultKernelPath, int newIsDefault, + const char * prefix, int flags, int index) { + struct singleEntry * entry, * entry2, * newDefault; + int i, j; + + if (newIsDefault) { + config->defaultImage = 0; + return; + } else if ((index >= 0) && config->cfi->defaultIsIndex) { + if (findEntryByIndex(config, index)) + config->defaultImage = index; + else + config->defaultImage = -1; + return; + } else if (defaultKernelPath) { + i = 0; + if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { + config->defaultImage = i; + } else { + config->defaultImage = -1; + return; + } + } + + /* defaultImage now points to what we'd like to use, but before any order + changes */ + if ((config->defaultImage == DEFAULT_SAVED) || + (config->defaultImage == DEFAULT_SAVED_GRUB2)) + /* default is set to saved, we don't want to change it */ + return; + + if (config->defaultImage > -1) + entry = findEntryByIndex(config, config->defaultImage); + else + entry = NULL; + + if (entry && !entry->skip) { + /* we can preserve the default */ + if (hasNew) + config->defaultImage++; + + /* count the number of entries erased before this one */ + for (j = 0; j < config->defaultImage; j++) { + entry2 = findEntryByIndex(config, j); + if (entry2->skip) config->defaultImage--; + } + } else if (hasNew) { + config->defaultImage = 0; + } else { + /* Either we just erased the default (or the default line was bad + * to begin with) and didn't put a new one in. We'll use the first + * valid image. */ + newDefault = findTemplate(config, prefix, &config->defaultImage, 1, + flags); + if (!newDefault) + config->defaultImage = -1; + } +} + +void setFallbackImage(struct grubConfig * config, int hasNew) { + struct singleEntry * entry, * entry2; + int j; + + if (config->fallbackImage == -1) return; + + entry = findEntryByIndex(config, config->fallbackImage); + if (!entry || entry->skip) { + config->fallbackImage = -1; + return; + } + + if (hasNew) + config->fallbackImage++; + + /* count the number of entries erased before this one */ + for (j = 0; j < config->fallbackImage; j++) { + entry2 = findEntryByIndex(config, j); + if (entry2->skip) config->fallbackImage--; + } +} + +void displayEntry(struct singleEntry * entry, const char * prefix, int index) { + struct singleLine * line; + char * root = NULL; + int i; + int j; + + printf("index=%d\n", index); + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) { + printf("non linux entry\n"); + return; + } + + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("kernel=%s\n", line->elements[1].item); + else + printf("kernel=%s%s\n", prefix, line->elements[1].item); + + if (line->numElements >= 3) { + printf("args=\""); + i = 2; + while (i < line->numElements) { + if (!strncmp(line->elements[i].item, "root=", 5)) { + root = line->elements[i].item + 5; + } else { + printf("%s%s", line->elements[i].item, + line->elements[i].indent); + } + + i++; + } + printf("\"\n"); + } else { + line = getLineByType(LT_KERNELARGS, entry->lines); + if (line) { + char * s; + + printf("args=\""); + i = 1; + while (i < line->numElements) { + if (!strncmp(line->elements[i].item, "root=", 5)) { + root = line->elements[i].item + 5; + } else { + s = line->elements[i].item; + + printf("%s%s", s, line->elements[i].indent); + } + + i++; + } + + s = line->elements[i - 1].indent; + printf("\"\n"); + } + } + + if (!root) { + line = getLineByType(LT_ROOT, entry->lines); + if (line && line->numElements >= 2) + root=line->elements[1].item; + } + + if (root) { + char * s = alloca(strlen(root) + 1); + + strcpy(s, root); + if (s[strlen(s) - 1] == '"') + s[strlen(s) - 1] = '\0'; + /* make sure the root doesn't have a trailing " */ + printf("root=%s\n", s); + } + + line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); + + if (line && line->numElements >= 2) { + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("initrd="); + else + printf("initrd=%s", prefix); + + for (i = 1; i < line->numElements; i++) + printf("%s%s", line->elements[i].item, line->elements[i].indent); + printf("\n"); + } + + line = getLineByType(LT_TITLE, entry->lines); + if (line) { + printf("title=%s\n", line->elements[1].item); + } else { + char * title; + line = getLineByType(LT_MENUENTRY, entry->lines); + if (line) { + title = grub2ExtractTitle(line); + if (title) + printf("title=%s\n", title); + } + } + + for (j = 0, line = entry->lines; line; line = line->next) { + if ((line->type & LT_MBMODULE) && line->numElements >= 2) { + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("mbmodule%d=", j); + else + printf("mbmodule%d=%s", j, prefix); + + for (i = 1; i < line->numElements; i++) + printf("%s%s", line->elements[i].item, line->elements[i].indent); + printf("\n"); + j++; + } + } +} + +int isSuseSystem(void) { + const char * path; + const static char default_path[] = "/etc/SuSE-release"; + + if ((path = getenv("GRUBBY_SUSE_RELEASE")) == NULL) + path = default_path; + + if (!access(path, R_OK)) + return 1; + return 0; +} + +int isSuseGrubConf(const char * path) { + FILE * grubConf; + char * line = NULL; + size_t len = 0, res = 0; + + grubConf = fopen(path, "r"); + if (!grubConf) { + dbgPrintf("Could not open SuSE configuration file '%s'\n", path); + return 0; + } + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (!strncmp(line, "setup", 5)) { + fclose(grubConf); + free(line); + return 1; + } + } + + dbgPrintf("SuSE configuration file '%s' does not appear to be valid\n", + path); + + fclose(grubConf); + free(line); + return 0; +} + +int suseGrubConfGetLba(const char * path, int * lbaPtr) { + FILE * grubConf; + char * line = NULL; + size_t res = 0, len = 0; + + if (!path) return 1; + if (!lbaPtr) return 1; + + grubConf = fopen(path, "r"); + if (!grubConf) return 1; + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + if (!strncmp(line, "setup", 5)) { + if (strstr(line, "--force-lba")) { + *lbaPtr = 1; + } else { + *lbaPtr = 0; + } + dbgPrintf("lba: %i\n", *lbaPtr); + break; + } + } + + free(line); + fclose(grubConf); + return 0; +} + +int suseGrubConfGetInstallDevice(const char * path, char ** devicePtr) { + FILE * grubConf; + char * line = NULL; + size_t res = 0, len = 0; + char * lastParamPtr = NULL; + char * secLastParamPtr = NULL; + char installDeviceNumber = '\0'; + char * bounds = NULL; + + if (!path) return 1; + if (!devicePtr) return 1; + + grubConf = fopen(path, "r"); + if (!grubConf) return 1; + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (strncmp(line, "setup", 5)) + continue; + + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + lastParamPtr = bounds = line + res; + + /* Last parameter in grub may be an optional IMAGE_DEVICE */ + while (!isspace(*lastParamPtr)) + lastParamPtr--; + lastParamPtr++; + + secLastParamPtr = lastParamPtr - 2; + dbgPrintf("lastParamPtr: %s\n", lastParamPtr); + + if (lastParamPtr + 3 > bounds) { + dbgPrintf("lastParamPtr going over boundary"); + fclose(grubConf); + free(line); + return 1; + } + if (!strncmp(lastParamPtr, "(hd", 3)) + lastParamPtr += 3; + dbgPrintf("lastParamPtr: %c\n", *lastParamPtr); + + /* + * Second last parameter will decide wether last parameter is + * an IMAGE_DEVICE or INSTALL_DEVICE + */ + while (!isspace(*secLastParamPtr)) + secLastParamPtr--; + secLastParamPtr++; + + if (secLastParamPtr + 3 > bounds) { + dbgPrintf("secLastParamPtr going over boundary"); + fclose(grubConf); + free(line); + return 1; + } + dbgPrintf("secLastParamPtr: %s\n", secLastParamPtr); + if (!strncmp(secLastParamPtr, "(hd", 3)) { + secLastParamPtr += 3; + dbgPrintf("secLastParamPtr: %c\n", *secLastParamPtr); + installDeviceNumber = *secLastParamPtr; + } else { + installDeviceNumber = *lastParamPtr; + } + + *devicePtr = malloc(6); + snprintf(*devicePtr, 6, "(hd%c)", installDeviceNumber); + dbgPrintf("installDeviceNumber: %c\n", installDeviceNumber); + fclose(grubConf); + free(line); + return 0; + } + + free(line); + fclose(grubConf); + return 1; +} + +int grubGetBootFromDeviceMap(const char * device, + char ** bootPtr) { + FILE * deviceMap; + char * line = NULL; + size_t res = 0, len = 0; + char * devicePtr; + char * bounds = NULL; + const char * path; + const static char default_path[] = "/boot/grub/device.map"; + + if (!device) return 1; + if (!bootPtr) return 1; + + if ((path = getenv("GRUBBY_GRUB_DEVICE_MAP")) == NULL) + path = default_path; + + dbgPrintf("opening grub device.map file from: %s\n", path); + deviceMap = fopen(path, "r"); + if (!deviceMap) + return 1; + + while ((res = getline(&line, &len, deviceMap)) != -1) { + if (!strncmp(line, "#", 1)) + continue; + + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + devicePtr = line; + bounds = line + res; + + while ((isspace(*line) && ((devicePtr + 1) <= bounds))) + devicePtr++; + dbgPrintf("device: %s\n", devicePtr); + + if (!strncmp(devicePtr, device, strlen(device))) { + devicePtr += strlen(device); + while (isspace(*devicePtr) && ((devicePtr + 1) <= bounds)) + devicePtr++; + + *bootPtr = strdup(devicePtr); + break; + } + } + + free(line); + fclose(deviceMap); + return 0; +} + +int suseGrubConfGetBoot(const char * path, char ** bootPtr) { + char * grubDevice = NULL; + + if (suseGrubConfGetInstallDevice(path, &grubDevice)) + dbgPrintf("error looking for grub installation device\n"); + else + dbgPrintf("grubby installation device: %s\n", grubDevice); + + if (grubGetBootFromDeviceMap(grubDevice, bootPtr)) + dbgPrintf("error looking for grub boot device\n"); + else + dbgPrintf("grubby boot device: %s\n", *bootPtr); + + free(grubDevice); + return 0; +} + +int parseSuseGrubConf(int * lbaPtr, char ** bootPtr) { + /* + * This SuSE grub configuration file at this location is not your average + * grub configuration file, but instead the grub commands used to setup + * grub on that system. + */ + const char * path; + const static char default_path[] = "/etc/grub.conf"; + + if ((path = getenv("GRUBBY_SUSE_GRUB_CONF")) == NULL) + path = default_path; + + if (!isSuseGrubConf(path)) return 1; + + if (lbaPtr) { + *lbaPtr = 0; + if (suseGrubConfGetLba(path, lbaPtr)) + return 1; + } + + if (bootPtr) { + *bootPtr = NULL; + suseGrubConfGetBoot(path, bootPtr); + } + + return 0; +} + +int parseSysconfigGrub(int * lbaPtr, char ** bootPtr) { + FILE * in; + char buf[1024]; + char * chptr; + char * start; + char * param; + + in = fopen("/etc/sysconfig/grub", "r"); + if (!in) return 1; + + if (lbaPtr) *lbaPtr = 0; + if (bootPtr) *bootPtr = NULL; + + while (fgets(buf, sizeof(buf), in)) { + start = buf; + while (isspace(*start)) start++; + if (*start == '#') continue; + + chptr = strchr(start, '='); + if (!chptr) continue; + chptr--; + while (*chptr && isspace(*chptr)) chptr--; + chptr++; + *chptr = '\0'; + + param = chptr + 1; + while (*param && isspace(*param)) param++; + if (*param == '=') { + param++; + while (*param && isspace(*param)) param++; + } + + chptr = param; + while (*chptr && !isspace(*chptr)) chptr++; + *chptr = '\0'; + + if (!strcmp(start, "forcelba") && !strcmp(param, "1") && lbaPtr) + *lbaPtr = 1; + else if (!strcmp(start, "boot") && bootPtr) + *bootPtr = strdup(param); + } + + fclose(in); + + return 0; +} + +void dumpSysconfigGrub(void) { + char * boot = NULL; + int lba; + + if (isSuseSystem()) { + if (parseSuseGrubConf(&lba, &boot)) { + free(boot); + return; + } + } else { + if (parseSysconfigGrub(&lba, &boot)) { + free(boot); + return; + } + } + + if (lba) printf("lba\n"); + if (boot) { + printf("boot=%s\n", boot); + free(boot); + } +} + +int displayInfo(struct grubConfig * config, char * kernel, + const char * prefix) { + int i = 0; + struct singleEntry * entry; + struct singleLine * line; + + entry = findEntryByPath(config, kernel, prefix, &i); + if (!entry) { + fprintf(stderr, _("grubby: kernel not found\n")); + return 1; + } + + /* this is a horrible hack to support /etc/sysconfig/grub; there must + be a better way */ + if (config->cfi == &grubConfigType) { + dumpSysconfigGrub(); + } else { + line = getLineByType(LT_BOOT, config->theLines); + if (line && line->numElements >= 1) { + printf("boot=%s\n", line->elements[1].item); + } + + line = getLineByType(LT_LBA, config->theLines); + if (line) printf("lba\n"); + } + + displayEntry(entry, prefix, i); + + i++; + while ((entry = findEntryByPath(config, kernel, prefix, &i))) { + displayEntry(entry, prefix, i); + i++; + } + + return 0; +} + +struct singleLine * addLineTmpl(struct singleEntry * entry, + struct singleLine * tmplLine, + struct singleLine * prevLine, + const char * val, + struct configFileInfo * cfi) +{ + struct singleLine * newLine = lineDup(tmplLine); + + if (isEfi && cfi == &grub2ConfigType) { + enum lineType_e old = newLine->type; + newLine->type = preferredLineType(newLine->type, cfi); + if (old != newLine->type) + newLine->elements[0].item = getKeyByType(newLine->type, cfi); + } + + if (val) { + /* override the inherited value with our own. + * This is a little weak because it only applies to elements[1] + */ + if (newLine->numElements > 1) + removeElement(newLine, 1); + insertElement(newLine, val, 1, cfi); + + /* but try to keep the rootspec from the template... sigh */ + if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { + char * rootspec = getRootSpecifier(tmplLine->elements[1].item); + if (rootspec != NULL) { + free(newLine->elements[1].item); + newLine->elements[1].item = + sdupprintf("%s%s", rootspec, val); + } + } + } + + dbgPrintf("addLineTmpl(%s)\n", newLine->numElements ? + newLine->elements[0].item : ""); + + if (!entry->lines) { + /* first one on the list */ + entry->lines = newLine; + } else if (prevLine) { + /* add after prevLine */ + newLine->next = prevLine->next; + prevLine->next = newLine; + } + + return newLine; +} + +/* val may be NULL */ +struct singleLine * addLine(struct singleEntry * entry, + struct configFileInfo * cfi, + enum lineType_e type, char * defaultIndent, + const char * val) { + struct singleLine * line, * prev; + struct keywordTypes * kw; + struct singleLine tmpl; + + /* NB: This function shouldn't allocate items on the heap, rather on the + * stack since it calls addLineTmpl which will make copies. + */ + if (type == LT_TITLE && cfi->titleBracketed) { + /* we're doing a bracketed title (zipl) */ + tmpl.type = type; + tmpl.numElements = 1; + tmpl.elements = alloca(sizeof(*tmpl.elements)); + tmpl.elements[0].item = alloca(strlen(val)+3); + sprintf(tmpl.elements[0].item, "[%s]", val); + tmpl.elements[0].indent = ""; + val = NULL; + } else if (type == LT_MENUENTRY) { + char *lineend = "--class gnu-linux --class gnu --class os {"; + if (!val) { + fprintf(stderr, "Line type LT_MENUENTRY requires a value\n"); + abort(); + } + kw = getKeywordByType(type, cfi); + if (!kw) { + fprintf(stderr, "Looking up keyword for unknown type %d\n", type); + abort(); + } + tmpl.indent = ""; + tmpl.type = type; + tmpl.numElements = 3; + tmpl.elements = alloca(sizeof(*tmpl.elements) * tmpl.numElements); + tmpl.elements[0].item = kw->key; + tmpl.elements[0].indent = alloca(2); + sprintf(tmpl.elements[0].indent, "%c", kw->nextChar); + tmpl.elements[1].item = (char *)val; + tmpl.elements[1].indent = alloca(2); + sprintf(tmpl.elements[1].indent, "%c", kw->nextChar); + tmpl.elements[2].item = alloca(strlen(lineend)+1); + strcpy(tmpl.elements[2].item, lineend); + tmpl.elements[2].indent = ""; + } else { + kw = getKeywordByType(type, cfi); + if (!kw) { + fprintf(stderr, "Looking up keyword for unknown type %d\n", type); + abort(); + } + tmpl.type = type; + tmpl.numElements = val ? 2 : 1; + tmpl.elements = alloca(sizeof(*tmpl.elements) * tmpl.numElements); + tmpl.elements[0].item = kw->key; + tmpl.elements[0].indent = alloca(2); + sprintf(tmpl.elements[0].indent, "%c", kw->nextChar); + if (val) { + tmpl.elements[1].item = (char *)val; + tmpl.elements[1].indent = ""; + } + } + + /* The last non-empty line gives us the indention to us and the line + to insert after. Note that comments are considered empty lines, which + may not be ideal? If there are no lines or we are looking at the + first line, we use defaultIndent (the first line is normally indented + differently from the rest) */ + for (line = entry->lines, prev = NULL; line; line = line->next) { + if (line->numElements) prev = line; + /* fall back on the last line if prev isn't otherwise set */ + if (!line->next && !prev) prev = line; + } + + struct singleLine *menuEntry; + menuEntry = getLineByType(LT_MENUENTRY, entry->lines); + if (tmpl.type == LT_ENTRY_END) { + if (menuEntry) + tmpl.indent = menuEntry->indent; + else + tmpl.indent = defaultIndent ?: ""; + } else if (tmpl.type != LT_MENUENTRY) { + if (menuEntry) + tmpl.indent = "\t"; + else if (prev == entry->lines) + tmpl.indent = defaultIndent ?: ""; + else + tmpl.indent = prev->indent; + } + + return addLineTmpl(entry, &tmpl, prev, val, cfi); +} + +void removeLine(struct singleEntry * entry, struct singleLine * line) { + struct singleLine * prev; + int i; + + for (i = 0; i < line->numElements; i++) { + free(line->elements[i].item); + free(line->elements[i].indent); + } + free(line->elements); + free(line->indent); + + if (line == entry->lines) { + entry->lines = line->next; + } else { + prev = entry->lines; + while (prev->next != line) prev = prev->next; + prev->next = line->next; + } + + free(line); +} + +static void requote(struct singleLine *tmplLine, struct configFileInfo * cfi) +{ + struct singleLine newLine = { + .indent = tmplLine->indent, + .type = tmplLine->type, + .next = tmplLine->next, + }; + int firstQuotedItem = -1; + int quoteLen = 0; + int j; + int element = 0; + char *c; + + c = malloc(strlen(tmplLine->elements[0].item) + 1); + strcpy(c, tmplLine->elements[0].item); + insertElement(&newLine, c, element++, cfi); + free(c); + c = NULL; + + for (j = 1; j < tmplLine->numElements; j++) { + if (firstQuotedItem == -1) { + quoteLen += strlen(tmplLine->elements[j].item); + + if (isquote(tmplLine->elements[j].item[0])) { + firstQuotedItem = j; + quoteLen += strlen(tmplLine->elements[j].indent); + } else { + c = malloc(quoteLen + 1); + strcpy(c, tmplLine->elements[j].item); + insertElement(&newLine, c, element++, cfi); + free(c); + quoteLen = 0; + } + } else { + int itemlen = strlen(tmplLine->elements[j].item); + quoteLen += itemlen; + quoteLen += strlen(tmplLine->elements[j].indent); + + if (isquote(tmplLine->elements[j].item[itemlen - 1])) { + c = malloc(quoteLen + 1); + c[0] = '\0'; + for (int i = firstQuotedItem; i < j+1; i++) { + strcat(c, tmplLine->elements[i].item); + strcat(c, tmplLine->elements[i].indent); + } + insertElement(&newLine, c, element++, cfi); + free(c); + + firstQuotedItem = -1; + quoteLen = 0; + } + } + } + while (tmplLine->numElements) + removeElement(tmplLine, 0); + if (tmplLine->elements) + free(tmplLine->elements); + + tmplLine->numElements = newLine.numElements; + tmplLine->elements = newLine.elements; +} + +static void insertElement(struct singleLine * line, + const char * item, int insertHere, + struct configFileInfo * cfi) +{ + struct keywordTypes * kw; + char indent[2] = ""; + + /* sanity check */ + if (insertHere > line->numElements) { + dbgPrintf("insertElement() adjusting insertHere from %d to %d\n", + insertHere, line->numElements); + insertHere = line->numElements; + } + + line->elements = realloc(line->elements, (line->numElements + 1) * + sizeof(*line->elements)); + memmove(&line->elements[insertHere+1], + &line->elements[insertHere], + (line->numElements - insertHere) * + sizeof(*line->elements)); + line->elements[insertHere].item = strdup(item); + + kw = getKeywordByType(line->type, cfi); + + if (line->numElements == 0) { + indent[0] = '\0'; + } else if (insertHere == 0) { + indent[0] = kw->nextChar; + } else if (kw->separatorChar != '\0') { + indent[0] = kw->separatorChar; + } else { + indent[0] = ' '; + } + + if (insertHere > 0 && line->elements[insertHere-1].indent[0] == '\0') { + /* move the end-of-line forward */ + line->elements[insertHere].indent = + line->elements[insertHere-1].indent; + line->elements[insertHere-1].indent = strdup(indent); + } else { + line->elements[insertHere].indent = strdup(indent); + } + + line->numElements++; + + dbgPrintf("insertElement(%s, '%s%s', %d)\n", + line->elements[0].item, + line->elements[insertHere].item, + line->elements[insertHere].indent, + insertHere); +} + +static void removeElement(struct singleLine * line, int removeHere) { + int i; + + /* sanity check */ + if (removeHere >= line->numElements) return; + + dbgPrintf("removeElement(%s, %d:%s)\n", line->elements[0].item, + removeHere, line->elements[removeHere].item); + + free(line->elements[removeHere].item); + + if (removeHere > 1) { + /* previous argument gets this argument's post-indentation */ + free(line->elements[removeHere-1].indent); + line->elements[removeHere-1].indent = + line->elements[removeHere].indent; + } else { + free(line->elements[removeHere].indent); + } + + /* now collapse the array, but don't bother to realloc smaller */ + for (i = removeHere; i < line->numElements - 1; i++) + line->elements[i] = line->elements[i + 1]; + + line->numElements--; +} + +int argMatch(const char * one, const char * two) { + char * first, * second; + char * chptr; + + first = strcpy(alloca(strlen(one) + 1), one); + second = strcpy(alloca(strlen(two) + 1), two); + + chptr = strchr(first, '='); + if (chptr) *chptr = '\0'; + + chptr = strchr(second, '='); + if (chptr) *chptr = '\0'; + + return strcmp(first, second); +} + +int updateActualImage(struct grubConfig * cfg, const char * image, + const char * prefix, const char * addArgs, + const char * removeArgs, int multibootArgs) { + struct singleEntry * entry; + struct singleLine * line, * rootLine; + int index = 0; + int i, k; + const char ** newArgs, ** oldArgs; + const char ** arg; + int useKernelArgs, useRoot; + int firstElement; + int *usedElements; + int doreplace; + + if (!image) return 0; + + if (!addArgs) { + newArgs = malloc(sizeof(*newArgs)); + *newArgs = NULL; + } else { + if (poptParseArgvString(addArgs, NULL, &newArgs)) { + fprintf(stderr, + _("grubby: error separating arguments '%s'\n"), addArgs); + return 1; + } + } + + if (!removeArgs) { + oldArgs = malloc(sizeof(*oldArgs)); + *oldArgs = NULL; + } else { + if (poptParseArgvString(removeArgs, NULL, &oldArgs)) { + fprintf(stderr, + _("grubby: error separating arguments '%s'\n"), removeArgs); + free(newArgs); + return 1; + } + } + + + useKernelArgs = (getKeywordByType(LT_KERNELARGS, cfg->cfi) + && (!multibootArgs || cfg->cfi->mbConcatArgs)); + + useRoot = (getKeywordByType(LT_ROOT, cfg->cfi) + && !multibootArgs); + + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { + + if (multibootArgs && !entry->multiboot) + continue; + + /* Determine where to put the args. If this config supports + * LT_KERNELARGS, use that. Otherwise use + * LT_HYPER/LT_KERNEL/LT_MBMODULE lines. + */ + if (useKernelArgs) { + line = getLineByType(LT_KERNELARGS, entry->lines); + if (!line) { + /* no LT_KERNELARGS, need to add it */ + line = addLine(entry, cfg->cfi, LT_KERNELARGS, + cfg->secondaryIndent, NULL); + } + firstElement = 1; + + } else if (multibootArgs) { + line = getLineByType(LT_HYPER, entry->lines); + if (!line) { + /* a multiboot entry without LT_HYPER? */ + continue; + } + firstElement = 2; + + } else { + line = getLineByType(LT_KERNEL|LT_MBMODULE|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) { + /* no LT_KERNEL or LT_MBMODULE in this entry? */ + continue; + } + firstElement = 2; + } + + /* handle the elilo case which does: + * append="hypervisor args -- kernel args" + */ + if (entry->multiboot && cfg->cfi->mbConcatArgs) { + /* this is a multiboot entry, make sure there's + * -- on the args line + */ + for (i = firstElement; i < line->numElements; i++) { + if (!strcmp(line->elements[i].item, "--")) + break; + } + if (i == line->numElements) { + /* assume all existing args are kernel args, + * prepend -- to make it official + */ + insertElement(line, "--", firstElement, cfg->cfi); + i = firstElement; + } + if (!multibootArgs) { + /* kernel args start after the -- */ + firstElement = i + 1; + } + } else if (cfg->cfi->mbConcatArgs) { + /* this is a non-multiboot entry, remove hyper args */ + for (i = firstElement; i < line->numElements; i++) { + if (!strcmp(line->elements[i].item, "--")) + break; + } + if (i < line->numElements) { + /* remove args up to -- */ + while (strcmp(line->elements[firstElement].item, "--")) + removeElement(line, firstElement); + /* remove -- */ + removeElement(line, firstElement); + } + } + + usedElements = calloc(line->numElements, sizeof(*usedElements)); + + for (k = 0, arg = newArgs; *arg; arg++, k++) { + + doreplace = 1; + for (i = firstElement; i < line->numElements; i++) { + if (multibootArgs && cfg->cfi->mbConcatArgs && + !strcmp(line->elements[i].item, "--")) + { + /* reached the end of hyper args, insert here */ + doreplace = 0; + break; + } + if (usedElements[i]) + continue; + if (!argMatch(line->elements[i].item, *arg)) { + usedElements[i]=1; + break; + } + } + + if (i < line->numElements && doreplace) { + /* direct replacement */ + free(line->elements[i].item); + line->elements[i].item = strdup(*arg); + + } else if (useRoot && !strncmp(*arg, "root=/dev/", 10)) { + /* root= replacement */ + rootLine = getLineByType(LT_ROOT, entry->lines); + if (rootLine) { + free(rootLine->elements[1].item); + rootLine->elements[1].item = strdup(*arg + 5); + } else { + rootLine = addLine(entry, cfg->cfi, LT_ROOT, + cfg->secondaryIndent, *arg + 5); + } + } + + else { + /* insert/append */ + insertElement(line, *arg, i, cfg->cfi); + usedElements = realloc(usedElements, line->numElements * + sizeof(*usedElements)); + memmove(&usedElements[i + 1], &usedElements[i], + line->numElements - i - 1); + usedElements[i] = 1; + + /* if we updated a root= here even though there is a + LT_ROOT available we need to remove the LT_ROOT entry + (this will happen if we switch from a device to a label) */ + if (useRoot && !strncmp(*arg, "root=", 5)) { + rootLine = getLineByType(LT_ROOT, entry->lines); + if (rootLine) + removeLine(entry, rootLine); + } + } + } + + free(usedElements); + + for (arg = oldArgs; *arg; arg++) { + for (i = firstElement; i < line->numElements; i++) { + if (multibootArgs && cfg->cfi->mbConcatArgs && + !strcmp(line->elements[i].item, "--")) + /* reached the end of hyper args, stop here */ + break; + if (!argMatch(line->elements[i].item, *arg)) { + removeElement(line, i); + break; + } + } + /* handle removing LT_ROOT line too */ + if (useRoot && !strncmp(*arg, "root=", 5)) { + rootLine = getLineByType(LT_ROOT, entry->lines); + if (rootLine) + removeLine(entry, rootLine); + } + } + + if (line->numElements == 1) { + /* don't need the line at all (note it has to be a + LT_KERNELARGS for this to happen */ + removeLine(entry, line); + } + } + + free(newArgs); + free(oldArgs); + + return 0; +} + +int updateImage(struct grubConfig * cfg, const char * image, + const char * prefix, const char * addArgs, + const char * removeArgs, + const char * addMBArgs, const char * removeMBArgs) { + int rc = 0; + + if (!image) return rc; + + /* update the main args first... */ + if (addArgs || removeArgs) + rc = updateActualImage(cfg, image, prefix, addArgs, removeArgs, 0); + if (rc) return rc; + + /* and now any multiboot args */ + if (addMBArgs || removeMBArgs) + rc = updateActualImage(cfg, image, prefix, addMBArgs, removeMBArgs, 1); + return rc; +} + +int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, + const char * image, const char * prefix, const char * initrd, + const char * title) { + struct singleEntry * entry; + struct singleLine * line, * kernelLine, *endLine = NULL; + int index = 0; + + if (!image) return 0; + + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { + kernelLine = getLineByType(LT_MBMODULE, entry->lines); + if (!kernelLine) continue; + + /* if title is supplied, the entry's title must match it. */ + if (title) { + char *linetitle; + + line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines); + if (!line) + continue; + + linetitle = extractTitle(cfg, line); + if (!linetitle) + continue; + if (strcmp(title, linetitle)) { + free(linetitle); + continue; + } + free(linetitle); + } + + if (prefix) { + int prefixLen = strlen(prefix); + if (!strncmp(initrd, prefix, prefixLen)) + initrd += prefixLen; + } + endLine = getLineByType(LT_ENTRY_END, entry->lines); + if (endLine) + removeLine(entry, endLine); + line = addLine(entry, cfg->cfi, preferredLineType(LT_MBMODULE,cfg->cfi), + kernelLine->indent, initrd); + if (!line) + return 1; + if (endLine) { + line = addLine(entry, cfg->cfi, LT_ENTRY_END, "", NULL); + if (!line) + return 1; + } + + break; + } + + return 0; +} + +int updateInitrd(struct grubConfig * cfg, const char * image, + const char * prefix, const char * initrd, const char * title) { + struct singleEntry * entry; + struct singleLine * line, * kernelLine, *endLine = NULL; + int index = 0; + + if (!image) return 0; + + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { + kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!kernelLine) continue; + + /* if title is supplied, the entry's title must match it. */ + if (title) { + char *linetitle; + + line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines); + if (!line) + continue; + + linetitle = extractTitle(cfg, line); + if (!linetitle) + continue; + if (strcmp(title, linetitle)) { + free(linetitle); + continue; + } + free(linetitle); + } + + line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); + if (line) + removeLine(entry, line); + if (prefix) { + int prefixLen = strlen(prefix); + if (!strncmp(initrd, prefix, prefixLen)) + initrd += prefixLen; + } + endLine = getLineByType(LT_ENTRY_END, entry->lines); + if (endLine) + removeLine(entry, endLine); + enum lineType_e lt; + switch(kernelLine->type) { + case LT_KERNEL: + lt = LT_INITRD; + break; + case LT_KERNEL_EFI: + lt = LT_INITRD_EFI; + break; + case LT_KERNEL_16: + lt = LT_INITRD_16; + break; + default: + lt = preferredLineType(LT_INITRD, cfg->cfi); + } + line = addLine(entry, cfg->cfi, lt, kernelLine->indent, initrd); + if (!line) + return 1; + if (endLine) { + line = addLine(entry, cfg->cfi, LT_ENTRY_END, "", NULL); + if (!line) + return 1; + } + + break; + } + + return 0; +} + +int checkDeviceBootloader(const char * device, const unsigned char * boot) { + int fd; + unsigned char bootSect[512]; + int offset; + + fd = open(device, O_RDONLY); + if (fd < 0) { + fprintf(stderr, _("grubby: unable to open %s: %s\n"), + device, strerror(errno)); + return 1; + } + + if (read(fd, bootSect, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + device, strerror(errno)); + return 1; + } + close(fd); + + /* first three bytes should match, a jmp short should be in there */ + if (memcmp(boot, bootSect, 3)) + return 0; + + if (boot[1] == JMP_SHORT_OPCODE) { + offset = boot[2] + 2; + } else if (boot[1] == 0xe8 || boot[1] == 0xe9) { + offset = (boot[3] << 8) + boot[2] + 2; + } else if (boot[0] == JMP_SHORT_OPCODE) { + offset = boot[1] + 2; + /* + * it looks like grub, when copying stage1 into the mbr, patches stage1 + * right after the JMP location, replacing other instructions such as + * JMPs for NOOPs. So, relax the check a little bit by skipping those + * different bytes. + */ + if ((bootSect[offset + 1] == NOOP_OPCODE) + && (bootSect[offset + 2] == NOOP_OPCODE)) { + offset = offset + 3; + } + } else if (boot[0] == 0xe8 || boot[0] == 0xe9) { + offset = (boot[2] << 8) + boot[1] + 2; + } else { + return 0; + } + + if (memcmp(boot + offset, bootSect + offset, CODE_SEG_SIZE)) + return 0; + + return 2; +} + +int checkLiloOnRaid(char * mdDev, const unsigned char * boot) { + int fd; + char buf[65536]; + char * end; + char * chptr; + char * chptr2; + int rc; + + /* it's on raid; we need to parse /proc/mdstat and check all of the + *raw* devices listed in there */ + + if (!strncmp(mdDev, "/dev/", 5)) + mdDev += 5; + + if ((fd = open("/proc/mdstat", O_RDONLY)) < 0) { + fprintf(stderr, _("grubby: failed to open /proc/mdstat: %s\n"), + strerror(errno)); + return 2; + } + + rc = read(fd, buf, sizeof(buf) - 1); + if (rc < 0 || rc == (sizeof(buf) - 1)) { + fprintf(stderr, _("grubby: failed to read /proc/mdstat: %s\n"), + strerror(errno)); + close(fd); + return 2; + } + close(fd); + buf[rc] = '\0'; + + chptr = buf; + while (*chptr) { + end = strchr(chptr, '\n'); + if (!end) break; + *end = '\0'; + + if (!strncmp(chptr, mdDev, strlen(mdDev)) && + chptr[strlen(mdDev)] == ' ') { + + /* found the device */ + while (*chptr && *chptr != ':') chptr++; + chptr++; + while (*chptr && isspace(*chptr)) chptr++; + + /* skip the "active" bit */ + while (*chptr && !isspace(*chptr)) chptr++; + while (*chptr && isspace(*chptr)) chptr++; + + /* skip the raid level */ + while (*chptr && !isspace(*chptr)) chptr++; + while (*chptr && isspace(*chptr)) chptr++; + + /* everything else is partition stuff */ + while (*chptr) { + chptr2 = chptr; + while (*chptr2 && *chptr2 != '[') chptr2++; + if (!*chptr2) break; + + /* yank off the numbers at the end */ + chptr2--; + while (isdigit(*chptr2) && chptr2 > chptr) chptr2--; + chptr2++; + *chptr2 = '\0'; + + /* Better, now we need the /dev/ back. We're done with + * everything before this point, so we can just put + * the /dev/ part there. There will always be room. */ + memcpy(chptr - 5, "/dev/", 5); + rc = checkDeviceBootloader(chptr - 5, boot); + if (rc != 2) { + return rc; + } + + chptr = chptr2 + 1; + /* skip the [11] bit */ + while (*chptr && !isspace(*chptr)) chptr++; + /* and move to the next one */ + while (*chptr && isspace(*chptr)) chptr++; + } + + /* we're good to go */ + return 2; + } + + chptr = end + 1; + } + + fprintf(stderr, + _("grubby: raid device /dev/%s not found in /proc/mdstat\n"), + mdDev); + return 0; +} + +int checkForLilo(struct grubConfig * config) { + int fd; + unsigned char boot[512]; + struct singleLine * line; + + for (line = config->theLines; line; line = line->next) + if (line->type == LT_BOOT) break; + + if (!line) { + fprintf(stderr, + _("grubby: no boot line found in lilo configuration\n")); + return 1; + } + + if (line->numElements != 2) return 1; + + fd = open("/boot/boot.b", O_RDONLY); + if (fd < 0) { + fprintf(stderr, _("grubby: unable to open %s: %s\n"), + "/boot/boot.b", strerror(errno)); + return 1; + } + + if (read(fd, boot, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + "/boot/boot.b", strerror(errno)); + return 1; + } + close(fd); + + if (!strncmp("/dev/md", line->elements[1].item, 7)) + return checkLiloOnRaid(line->elements[1].item, boot); + + return checkDeviceBootloader(line->elements[1].item, boot); +} + +int checkForGrub2(struct grubConfig * config) { + if (!access("/etc/grub.d/", R_OK)) + return 2; + + return 1; +} + +int checkForGrub(struct grubConfig * config) { + int fd; + unsigned char bootSect[512]; + char * boot; + int onSuse = isSuseSystem(); + + + if (onSuse) { + if (parseSuseGrubConf(NULL, &boot)) + return 0; + } else { + if (parseSysconfigGrub(NULL, &boot)) + return 0; + } + + /* assume grub is not installed -- not an error condition */ + if (!boot) + return 0; + + fd = open("/boot/grub/stage1", O_RDONLY); + if (fd < 0) + /* this doesn't exist if grub hasn't been installed */ + return 0; + + if (read(fd, bootSect, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + "/boot/grub/stage1", strerror(errno)); + close(fd); + return 1; + } + close(fd); + + /* The more elaborate checks do not work on SuSE. The checks done + * seem to be reasonble (at least for now), so just return success + */ + if (onSuse) + return 2; + + return checkDeviceBootloader(boot, bootSect); +} + +int checkForExtLinux(struct grubConfig * config) { + int fd; + unsigned char bootSect[512]; + char * boot; + char executable[] = "/boot/extlinux/extlinux"; + + printf("entered: checkForExtLinux()\n"); + + if (parseSysconfigGrub(NULL, &boot)) + return 0; + + /* assume grub is not installed -- not an error condition */ + if (!boot) + return 0; + + fd = open(executable, O_RDONLY); + if (fd < 0) + /* this doesn't exist if grub hasn't been installed */ + return 0; + + if (read(fd, bootSect, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + executable, strerror(errno)); + return 1; + } + close(fd); + + return checkDeviceBootloader(boot, bootSect); +} + +int checkForYaboot(struct grubConfig * config) { + /* + * This is a simplistic check that we consider good enough for own puporses + * + * If we were to properly check if yaboot is *installed* we'd need to: + * 1) get the system boot device (LT_BOOT) + * 2) considering it's a raw filesystem, check if the yaboot binary matches + * the content on the boot device + * 3) if not, copy the binary to a temporary file and run "addnote" on it + * 4) check again if binary and boot device contents match + */ + if (!access("/etc/yaboot.conf", R_OK)) + return 2; + + return 1; +} + +int checkForElilo(struct grubConfig * config) { + if (!access("/etc/elilo.conf", R_OK)) + return 2; + + return 1; +} + +static char * getRootSpecifier(char * str) { + char * idx, * rootspec = NULL; + + if (*str == '(') { + idx = rootspec = strdup(str); + while(*idx && (*idx != ')') && (!isspace(*idx))) idx++; + *(++idx) = '\0'; + } + return rootspec; +} + +static char * getInitrdVal(struct grubConfig * config, + const char * prefix, struct singleLine *tmplLine, + const char * newKernelInitrd, + const char ** extraInitrds, int extraInitrdCount) +{ + char *initrdVal, *end; + int i; + size_t totalSize; + size_t prefixLen; + char separatorChar; + + prefixLen = strlen(prefix); + totalSize = strlen(newKernelInitrd) - prefixLen + 1 /* \0 */; + + for (i = 0; i < extraInitrdCount; i++) { + totalSize += sizeof(separatorChar); + totalSize += strlen(extraInitrds[i]) - prefixLen; + } + + initrdVal = end = malloc(totalSize); + + end = stpcpy (end, newKernelInitrd + prefixLen); + + separatorChar = getKeywordByType(LT_INITRD, config->cfi)->separatorChar; + for (i = 0; i < extraInitrdCount; i++) { + const char *extraInitrd; + int j; + + extraInitrd = extraInitrds[i] + prefixLen; + /* Don't add entries that are already there */ + if (tmplLine != NULL) { + for (j = 2; j < tmplLine->numElements; j++) + if (strcmp(extraInitrd, tmplLine->elements[j].item) == 0) + break; + + if (j != tmplLine->numElements) + continue; + } + + *end++ = separatorChar; + end = stpcpy(end, extraInitrd); + } + + return initrdVal; +} + +int addNewKernel(struct grubConfig * config, struct singleEntry * template, + const char * prefix, + const char * newKernelPath, const char * newKernelTitle, + const char * newKernelArgs, const char * newKernelInitrd, + const char ** extraInitrds, int extraInitrdCount, + const char * newMBKernel, const char * newMBKernelArgs, + const char * newDevTreePath) { + struct singleEntry * new; + struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; + int needs; + char * chptr; + + if (!newKernelPath) return 0; + + /* if the newKernelTitle is too long silently munge it into something + * we can live with. truncating is first check, then we'll just mess with + * it until it looks better */ + if (config->cfi->maxTitleLength && + (strlen(newKernelTitle) > config->cfi->maxTitleLength)) { + char * buf = alloca(config->cfi->maxTitleLength + 7); + char * numBuf = alloca(config->cfi->maxTitleLength + 1); + int i = 1; + + sprintf(buf, "TITLE=%.*s", config->cfi->maxTitleLength, newKernelTitle); + while (findEntryByPath(config, buf, NULL, NULL)) { + sprintf(numBuf, "%d", i++); + strcpy(buf + strlen(buf) - strlen(numBuf), numBuf); + } + + newKernelTitle = buf + 6; + } + + new = malloc(sizeof(*new)); + new->skip = 0; + new->multiboot = 0; + new->next = config->entries; + new->lines = NULL; + config->entries = new; + + /* copy/update from the template */ + needs = NEED_KERNEL | NEED_TITLE; + if (newKernelInitrd) + needs |= NEED_INITRD; + if (newMBKernel) { + needs |= NEED_MB; + new->multiboot = 1; + } + if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi)) + needs |= NEED_DEVTREE; + + if (template) { + for (masterLine = template->lines; + masterLine && (tmplLine = lineDup(masterLine)); + lineFree(tmplLine), masterLine = masterLine->next) + { + dbgPrintf("addNewKernel processing %d\n", tmplLine->type); + + /* skip comments */ + chptr = tmplLine->indent; + while (*chptr && isspace(*chptr)) chptr++; + if (*chptr == '#') continue; + + if (iskernel(tmplLine->type) && tmplLine->numElements >= 2) { + if (!template->multiboot && (needs & NEED_MB)) { + /* it's not a multiboot template and this is the kernel + * line. Try to be intelligent about inserting the + * hypervisor at the same time. + */ + if (config->cfi->mbHyperFirst) { + /* insert the hypervisor first */ + newLine = addLine(new, config->cfi, LT_HYPER, + tmplLine->indent, + newMBKernel + strlen(prefix)); + /* set up for adding the kernel line */ + free(tmplLine->indent); + tmplLine->indent = strdup(config->secondaryIndent); + needs &= ~NEED_MB; + } + if (needs & NEED_KERNEL) { + /* use addLineTmpl to preserve line elements, + * otherwise we could just call addLine. Unfortunately + * this means making some changes to the template + * such as the indent change above and the type + * change below. + */ + struct keywordTypes * mbm_kw = + getKeywordByType(LT_MBMODULE, config->cfi); + if (mbm_kw) { + tmplLine->type = LT_MBMODULE; + free(tmplLine->elements[0].item); + tmplLine->elements[0].item = strdup(mbm_kw->key); + } + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + strlen(prefix), config->cfi); + needs &= ~NEED_KERNEL; + } + if (needs & NEED_MB) { /* !mbHyperFirst */ + newLine = addLine(new, config->cfi, LT_HYPER, + config->secondaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + } + } else if (needs & NEED_KERNEL) { + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + strlen(prefix), config->cfi); + needs &= ~NEED_KERNEL; + } + + } else if (tmplLine->type == LT_HYPER && + tmplLine->numElements >= 2) { + if (needs & NEED_MB) { + newLine = addLineTmpl(new, tmplLine, newLine, + newMBKernel + strlen(prefix), config->cfi); + needs &= ~NEED_MB; + } + + } else if (tmplLine->type == LT_MBMODULE && + tmplLine->numElements >= 2) { + if (new->multiboot) { + if (needs & NEED_KERNEL) { + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + + strlen(prefix), config->cfi); + needs &= ~NEED_KERNEL; + } else if (config->cfi->mbInitRdIsModule && + (needs & NEED_INITRD)) { + char *initrdVal; + initrdVal = getInitrdVal(config, prefix, tmplLine, + newKernelInitrd, extraInitrds, + extraInitrdCount); + newLine = addLineTmpl(new, tmplLine, newLine, + initrdVal, config->cfi); + free(initrdVal); + needs &= ~NEED_INITRD; + } + } else if (needs & NEED_KERNEL) { + /* template is multi but new is not, + * insert the kernel in the first module slot + */ + tmplLine->type = preferredLineType(LT_KERNEL, config->cfi); + free(tmplLine->elements[0].item); + tmplLine->elements[0].item = + strdup(getKeywordByType(tmplLine->type, + config->cfi)->key); + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + strlen(prefix), + config->cfi); + needs &= ~NEED_KERNEL; + } else if (needs & NEED_INITRD) { + char *initrdVal; + /* template is multi but new is not, + * insert the initrd in the second module slot + */ + tmplLine->type = preferredLineType(LT_INITRD, config->cfi); + free(tmplLine->elements[0].item); + tmplLine->elements[0].item = + strdup(getKeywordByType(tmplLine->type, + config->cfi)->key); + initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); + free(initrdVal); + needs &= ~NEED_INITRD; + } + + } else if (isinitrd(tmplLine->type) && tmplLine->numElements >= 2) { + if (needs & NEED_INITRD && + new->multiboot && !template->multiboot && + config->cfi->mbInitRdIsModule) { + /* make sure we don't insert the module initrd + * before the module kernel... if we don't do it here, + * it will be inserted following the template. + */ + if (!needs & NEED_KERNEL) { + char *initrdVal; + + initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLine(new, config->cfi, LT_MBMODULE, + config->secondaryIndent, + initrdVal); + free(initrdVal); + needs &= ~NEED_INITRD; + } + } else if (needs & NEED_INITRD) { + char *initrdVal; + initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); + free(initrdVal); + needs &= ~NEED_INITRD; + } + + } else if (tmplLine->type == LT_MENUENTRY && + (needs & NEED_TITLE)) { + requote(tmplLine, config->cfi); + char *nkt = malloc(strlen(newKernelTitle)+3); + strcpy(nkt, "'"); + strcat(nkt, newKernelTitle); + strcat(nkt, "'"); + newLine = addLineTmpl(new, tmplLine, newLine, nkt, config->cfi); + free(nkt); + needs &= ~NEED_TITLE; + } else if (tmplLine->type == LT_TITLE && + (needs & NEED_TITLE)) { + if (tmplLine->numElements >= 2) { + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelTitle, config->cfi); + needs &= ~NEED_TITLE; + } else if (tmplLine->numElements == 1 && + config->cfi->titleBracketed) { + /* addLineTmpl doesn't handle titleBracketed */ + newLine = addLine(new, config->cfi, LT_TITLE, + tmplLine->indent, newKernelTitle); + needs &= ~NEED_TITLE; + } + } else if (tmplLine->type == LT_ECHO) { + requote(tmplLine, config->cfi); + static const char *prefix = "'Loading "; + if (tmplLine->numElements > 1 && + strstr(tmplLine->elements[1].item, prefix) && + masterLine->next && + iskernel(masterLine->next->type)) { + char *newTitle = malloc(strlen(prefix) + + strlen(newKernelTitle) + 2); + + strcpy(newTitle, prefix); + strcat(newTitle, newKernelTitle); + strcat(newTitle, "'"); + newLine = addLine(new, config->cfi, LT_ECHO, + tmplLine->indent, newTitle); + free(newTitle); + } else { + /* pass through other lines from the template */ + newLine = addLineTmpl(new, tmplLine, newLine, NULL, + config->cfi); + } + } else if (tmplLine->type == LT_DEVTREE && + tmplLine->numElements == 2 && newDevTreePath) { + newLine = addLineTmpl(new, tmplLine, newLine, + newDevTreePath + strlen(prefix), + config->cfi); + needs &= ~NEED_DEVTREE; + } else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) { + const char *ndtp = newDevTreePath; + if (!strncmp(newDevTreePath, prefix, strlen(prefix))) + ndtp += strlen(prefix); + newLine = addLine(new, config->cfi, LT_DEVTREE, + config->secondaryIndent, + ndtp); + needs &= ~NEED_DEVTREE; + newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); + } else { + /* pass through other lines from the template */ + newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); + } + } + + } else { + /* don't have a template, so start the entry with the + * appropriate starting line + */ + switch (config->cfi->entryStart) { + case LT_KERNEL: + case LT_KERNEL_EFI: + case LT_KERNEL_16: + if (new->multiboot && config->cfi->mbHyperFirst) { + /* fall through to LT_HYPER */ + } else { + newLine = addLine(new, config->cfi, + preferredLineType(LT_KERNEL, config->cfi), + config->primaryIndent, + newKernelPath + strlen(prefix)); + needs &= ~NEED_KERNEL; + break; + } + + case LT_HYPER: + newLine = addLine(new, config->cfi, LT_HYPER, + config->primaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + break; + + case LT_MENUENTRY: { + char *nkt = malloc(strlen(newKernelTitle)+3); + strcpy(nkt, "'"); + strcat(nkt, newKernelTitle); + strcat(nkt, "'"); + newLine = addLine(new, config->cfi, LT_MENUENTRY, + config->primaryIndent, nkt); + free(nkt); + needs &= ~NEED_TITLE; + needs |= NEED_END; + break; + } + case LT_TITLE: + if( useextlinuxmenu != 0 ){ // We just need useextlinuxmenu to not be zero (set above) + char * templabel; + int x = 0, y = 0; + + templabel = strdup(newKernelTitle); + while( templabel[x]){ + if( templabel[x] == ' ' ){ + y = x; + while( templabel[y] ){ + templabel[y] = templabel[y+1]; + y++; + } + } + x++; + } + newLine = addLine(new, config->cfi, LT_TITLE, + config->primaryIndent, templabel); + free(templabel); + }else{ + newLine = addLine(new, config->cfi, LT_TITLE, + config->primaryIndent, newKernelTitle); + } + needs &= ~NEED_TITLE; + break; + + default: + abort(); + } + } + + struct singleLine *endLine = NULL; + endLine = getLineByType(LT_ENTRY_END, new->lines); + if (endLine) { + removeLine(new, endLine); + needs |= NEED_END; + } + + /* add the remainder of the lines, i.e. those that either + * weren't present in the template, or in the case of no template, + * all the lines following the entryStart. + */ + if (needs & NEED_TITLE) { + newLine = addLine(new, config->cfi, LT_TITLE, + config->secondaryIndent, + newKernelTitle); + needs &= ~NEED_TITLE; + } + if ((needs & NEED_MB) && config->cfi->mbHyperFirst) { + newLine = addLine(new, config->cfi, LT_HYPER, + config->secondaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + } + if (needs & NEED_KERNEL) { + newLine = addLine(new, config->cfi, + (new->multiboot && getKeywordByType(LT_MBMODULE, + config->cfi)) + ? LT_MBMODULE + : preferredLineType(LT_KERNEL, config->cfi), + config->secondaryIndent, + newKernelPath + strlen(prefix)); + needs &= ~NEED_KERNEL; + } + if (needs & NEED_MB) { + newLine = addLine(new, config->cfi, LT_HYPER, + config->secondaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + } + if (needs & NEED_INITRD) { + char *initrdVal; + initrdVal = getInitrdVal(config, prefix, NULL, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLine(new, config->cfi, + (new->multiboot && getKeywordByType(LT_MBMODULE, + config->cfi)) + ? LT_MBMODULE + : preferredLineType(LT_INITRD, config->cfi), + config->secondaryIndent, + initrdVal); + free(initrdVal); + needs &= ~NEED_INITRD; + } + if (needs & NEED_DEVTREE) { + newLine = addLine(new, config->cfi, LT_DEVTREE, + config->secondaryIndent, + newDevTreePath); + needs &= ~NEED_DEVTREE; + } + + /* NEEDS_END must be last on bootloaders that need it... */ + if (needs & NEED_END) { + newLine = addLine(new, config->cfi, LT_ENTRY_END, + config->secondaryIndent, NULL); + needs &= ~NEED_END; + } + + if (needs) { + printf(_("grubby: needs=%d, aborting\n"), needs); + abort(); + } + + if (updateImage(config, "0", prefix, newKernelArgs, NULL, + newMBKernelArgs, NULL)) return 1; + + return 0; +} + +static void traceback(int signum) +{ + void *array[40]; + size_t size; + + signal(SIGSEGV, SIG_DFL); + memset(array, '\0', sizeof (array)); + size = backtrace(array, 40); + + fprintf(stderr, "grubby received SIGSEGV! Backtrace (%ld):\n", + (unsigned long)size); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + +int main(int argc, const char ** argv) { + poptContext optCon; + const char * grubConfig = NULL; + char * outputFile = NULL; + int arg = 0; + int flags = 0; + int badImageOkay = 0; + int configureGrub2 = 0; + int configureLilo = 0, configureELilo = 0, configureGrub = 0; + int configureYaboot = 0, configureSilo = 0, configureZipl = 0; + int configureExtLinux = 0; + int bootloaderProbe = 0; + int extraInitrdCount = 0; + char * updateKernelPath = NULL; + char * newKernelPath = NULL; + char * removeKernelPath = NULL; + char * newKernelArgs = NULL; + char * newKernelInitrd = NULL; + char * newKernelTitle = NULL; + char * newDevTreePath = NULL; + char * newMBKernel = NULL; + char * newMBKernelArgs = NULL; + char * removeMBKernelArgs = NULL; + char * removeMBKernel = NULL; + char * bootPrefix = NULL; + char * defaultKernel = NULL; + char * removeArgs = NULL; + char * kernelInfo = NULL; + char * extraInitrds[MAX_EXTRA_INITRDS] = { NULL }; + char * envPath = NULL; + const char * chptr = NULL; + struct configFileInfo * cfi = NULL; + struct grubConfig * config; + struct singleEntry * template = NULL; + int copyDefault = 0, makeDefault = 0; + int displayDefault = 0; + int displayDefaultIndex = 0; + int displayDefaultTitle = 0; + int defaultIndex = -1; + struct poptOption options[] = { + { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, + _("add an entry for the specified kernel"), _("kernel-path") }, + { "add-multiboot", 0, POPT_ARG_STRING, &newMBKernel, 0, + _("add an entry for the specified multiboot kernel"), NULL }, + { "args", 0, POPT_ARG_STRING, &newKernelArgs, 0, + _("default arguments for the new kernel or new arguments for " + "kernel being updated"), _("args") }, + { "mbargs", 0, POPT_ARG_STRING, &newMBKernelArgs, 0, + _("default arguments for the new multiboot kernel or " + "new arguments for multiboot kernel being updated"), NULL }, + { "bad-image-okay", 0, 0, &badImageOkay, 0, + _("don't sanity check images in boot entries (for testing only)"), + NULL }, + { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0, + _("filestystem which contains /boot directory (for testing only)"), + _("bootfs") }, +#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) || defined (__ia64__) + { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0, + _("check which bootloader is installed on boot sector") }, +#endif + { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0, + _("path to grub config file to update (\"-\" for stdin)"), + _("path") }, + { "copy-default", 0, 0, ©Default, 0, + _("use the default boot entry as a template for the new entry " + "being added; if the default is not a linux image, or if " + "the kernel referenced by the default image does not exist, " + "the first linux entry whose kernel does exist is used as the " + "template"), NULL }, + { "debug", 0, 0, &debug, 0, + _("print debugging information for failures") }, + { "default-kernel", 0, 0, &displayDefault, 0, + _("display the path of the default kernel") }, + { "default-index", 0, 0, &displayDefaultIndex, 0, + _("display the index of the default kernel") }, + { "default-title", 0, 0, &displayDefaultTitle, 0, + _("display the title of the default kernel") }, + { "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, + _("device tree file for new stanza"), _("dtb-path") }, + { "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0, + _("device tree directory for new stanza"), _("dtb-path") }, + { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, + _("configure elilo bootloader") }, + { "efi", 0, POPT_ARG_NONE, &isEfi, 0, + _("force grub2 stanzas to use efi") }, + { "env", 0, POPT_ARG_STRING, &envPath, 0, + _("path for environment data"), + _("path") }, + { "extlinux", 0, POPT_ARG_NONE, &configureExtLinux, 0, + _("configure extlinux bootloader (from syslinux)") }, + { "grub", 0, POPT_ARG_NONE, &configureGrub, 0, + _("configure grub bootloader") }, + { "grub2", 0, POPT_ARG_NONE, &configureGrub2, 0, + _("configure grub2 bootloader") }, + { "info", 0, POPT_ARG_STRING, &kernelInfo, 0, + _("display boot information for specified kernel"), + _("kernel-path") }, + { "initrd", 0, POPT_ARG_STRING, &newKernelInitrd, 0, + _("initrd image for the new kernel"), _("initrd-path") }, + { "extra-initrd", 'i', POPT_ARG_STRING, NULL, 'i', + _("auxiliary initrd image for things other than the new kernel"), _("initrd-path") }, + { "lilo", 0, POPT_ARG_NONE, &configureLilo, 0, + _("configure lilo bootloader") }, + { "make-default", 0, 0, &makeDefault, 0, + _("make the newly added entry the default boot entry"), NULL }, + { "output-file", 'o', POPT_ARG_STRING, &outputFile, 0, + _("path to output updated config file (\"-\" for stdout)"), + _("path") }, + { "remove-args", 0, POPT_ARG_STRING, &removeArgs, 0, + _("remove kernel arguments"), NULL }, + { "remove-mbargs", 0, POPT_ARG_STRING, &removeMBKernelArgs, 0, + _("remove multiboot kernel arguments"), NULL }, + { "remove-kernel", 0, POPT_ARG_STRING, &removeKernelPath, 0, + _("remove all entries for the specified kernel"), + _("kernel-path") }, + { "remove-multiboot", 0, POPT_ARG_STRING, &removeMBKernel, 0, + _("remove all entries for the specified multiboot kernel"), NULL }, + { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, + _("make the first entry referencing the specified kernel " + "the default"), _("kernel-path") }, + { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, + _("make the given entry index the default entry"), + _("entry-index") }, + { "silo", 0, POPT_ARG_NONE, &configureSilo, 0, + _("configure silo bootloader") }, + { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, + _("title to use for the new kernel entry"), _("entry-title") }, + { "update-kernel", 0, POPT_ARG_STRING, &updateKernelPath, 0, + _("updated information for the specified kernel"), + _("kernel-path") }, + { "version", 'v', 0, NULL, 'v', + _("print the version of this program and exit"), NULL }, + { "yaboot", 0, POPT_ARG_NONE, &configureYaboot, 0, + _("configure yaboot bootloader") }, + { "zipl", 0, POPT_ARG_NONE, &configureZipl, 0, + _("configure zipl bootloader") }, + POPT_AUTOHELP + { 0, 0, 0, 0, 0 } + }; + + useextlinuxmenu=0; + + signal(SIGSEGV, traceback); + + int i = 0; + for (int j = 1; j < argc; j++) + i += strlen(argv[j]) + 1; + + if (i > 0) { + saved_command_line = malloc(i); + if (!saved_command_line) { + fprintf(stderr, "grubby: %m\n"); + exit(1); + } + saved_command_line[0] = '\0'; + int cmdline_len = 0, arg_len; + for (int j = 1; j < argc; j++) { + arg_len = strlen(argv[j]); + memcpy(saved_command_line + cmdline_len, argv[j], arg_len); + cmdline_len += arg_len; + if (j != argc - 1) { + memcpy(saved_command_line + cmdline_len, " ", 1); + cmdline_len++; + } + } + saved_command_line[cmdline_len] = '\0'; + } + + optCon = poptGetContext("grubby", argc, argv, options, 0); + poptReadDefaultConfig(optCon, 1); + + while ((arg = poptGetNextOpt(optCon)) >= 0) { + switch (arg) { + case 'v': + printf("grubby version %s\n", VERSION); + exit(0); + break; + case 'i': + if (extraInitrdCount < MAX_EXTRA_INITRDS) { + extraInitrds[extraInitrdCount++] = strdup(poptGetOptArg(optCon)); + } else { + fprintf(stderr, _("grubby: extra initrd maximum is %d\n"), extraInitrdCount); + return 1; + } + break; + } + } + + if (arg < -1) { + fprintf(stderr, _("grubby: bad argument %s: %s\n"), + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(arg)); + return 1; + } + + if ((chptr = poptGetArg(optCon))) { + fprintf(stderr, _("grubby: unexpected argument %s\n"), chptr); + return 1; + } + + if ((configureLilo + configureGrub2 + configureGrub + configureELilo + + configureYaboot + configureSilo + configureZipl + + configureExtLinux ) > 1) { + fprintf(stderr, _("grubby: cannot specify multiple bootloaders\n")); + return 1; + } else if (bootloaderProbe && grubConfig) { + fprintf(stderr, + _("grubby: cannot specify config file with --bootloader-probe\n")); + return 1; + } else if (configureGrub2) { + cfi = &grub2ConfigType; + if (envPath) + cfi->envFile = envPath; + } else if (configureLilo) { + cfi = &liloConfigType; + } else if (configureGrub) { + cfi = &grubConfigType; + } else if (configureELilo) { + cfi = &eliloConfigType; + } else if (configureYaboot) { + cfi = &yabootConfigType; + } else if (configureSilo) { + cfi = &siloConfigType; + } else if (configureZipl) { + cfi = &ziplConfigType; + } else if (configureExtLinux) { + cfi = &extlinuxConfigType; + useextlinuxmenu=1; + } + + if (!cfi) { + if (grub2FindConfig(&grub2ConfigType)) + cfi = &grub2ConfigType; + else + #ifdef __ia64__ + cfi = &eliloConfigType; + #elif __powerpc__ + cfi = &yabootConfigType; + #elif __sparc__ + cfi = &siloConfigType; + #elif __s390__ + cfi = &ziplConfigType; + #elif __s390x__ + cfi = &ziplConfigtype; + #else + cfi = &grubConfigType; + #endif + } + + if (!grubConfig) { + if (cfi->findConfig) + grubConfig = cfi->findConfig(cfi); + if (!grubConfig) + grubConfig = cfi->defaultConfig; + } + + if (bootloaderProbe && (displayDefault || kernelInfo || + newKernelPath || removeKernelPath || makeDefault || + defaultKernel || displayDefaultIndex || displayDefaultTitle || + (defaultIndex >= 0))) { + fprintf(stderr, _("grubby: --bootloader-probe may not be used with " + "specified option")); + return 1; + } + + if ((displayDefault || kernelInfo) && (newKernelPath || + removeKernelPath)) { + fprintf(stderr, _("grubby: --default-kernel and --info may not " + "be used when adding or removing kernels\n")); + return 1; + } + + if (newKernelPath && !newKernelTitle) { + fprintf(stderr, _("grubby: kernel title must be specified\n")); + return 1; + } else if (!newKernelPath && (copyDefault || + (newKernelInitrd && !updateKernelPath)|| + makeDefault || extraInitrdCount > 0)) { + fprintf(stderr, _("grubby: kernel path expected\n")); + return 1; + } + + if (newKernelPath && updateKernelPath) { + fprintf(stderr, _("grubby: --add-kernel and --update-kernel may" + "not be used together")); + return 1; + } + + if (makeDefault && defaultKernel) { + fprintf(stderr, _("grubby: --make-default and --default-kernel " + "may not be used together\n")); + return 1; + } else if (defaultKernel && removeKernelPath && + !strcmp(defaultKernel, removeKernelPath)) { + fprintf(stderr, _("grubby: cannot make removed kernel the default\n")); + return 1; + } else if (defaultKernel && newKernelPath && + !strcmp(defaultKernel, newKernelPath)) { + makeDefault = 1; + defaultKernel = NULL; + } + else if (defaultKernel && (defaultIndex >= 0)) { + fprintf(stderr, _("grubby: --set-default and --set-default-index " + "may not be used together\n")); + return 1; + } + + if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { + fprintf(stderr, _("grubby: output file must be specified if stdin " + "is used\n")); + return 1; + } + + if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel + && !kernelInfo && !bootloaderProbe && !updateKernelPath + && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle + && (defaultIndex == -1)) { + fprintf(stderr, _("grubby: no action specified\n")); + return 1; + } + + flags |= badImageOkay ? GRUBBY_BADIMAGE_OKAY : 0; + + if (cfi->needsBootPrefix) { + if (!bootPrefix) { + bootPrefix = findBootPrefix(); + if (!bootPrefix) return 1; + } else { + /* this shouldn't end with a / */ + if (bootPrefix[strlen(bootPrefix) - 1] == '/') + bootPrefix[strlen(bootPrefix) - 1] = '\0'; + } + } else { + bootPrefix = ""; + } + + if (!cfi->mbAllowExtraInitRds && + extraInitrdCount > 0) { + fprintf(stderr, _("grubby: %s doesn't allow multiple initrds\n"), cfi->defaultConfig); + return 1; + } + + if (bootloaderProbe) { + int lrc = 0, grc = 0, gr2c = 0, extrc = 0, yrc = 0, erc = 0; + struct grubConfig * lconfig, * gconfig, * yconfig, * econfig; + + const char *grub2config = grub2FindConfig(&grub2ConfigType); + if (grub2config) { + gconfig = readConfig(grub2config, &grub2ConfigType); + if (!gconfig) + gr2c = 1; + else + gr2c = checkForGrub2(gconfig); + } + + const char *grubconfig = grubFindConfig(&grubConfigType); + if (!access(grubconfig, F_OK)) { + gconfig = readConfig(grubconfig, &grubConfigType); + if (!gconfig) + grc = 1; + else + grc = checkForGrub(gconfig); + } + + if (!access(liloConfigType.defaultConfig, F_OK)) { + lconfig = readConfig(liloConfigType.defaultConfig, &liloConfigType); + if (!lconfig) + lrc = 1; + else + lrc = checkForLilo(lconfig); + } + + if (!access(eliloConfigType.defaultConfig, F_OK)) { + econfig = readConfig(eliloConfigType.defaultConfig, + &eliloConfigType); + if (!econfig) + erc = 1; + else + erc = checkForElilo(econfig); + } + + if (!access(extlinuxConfigType.defaultConfig, F_OK)) { + lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType); + if (!lconfig) + extrc = 1; + else + extrc = checkForExtLinux(lconfig); + } + + + if (!access(yabootConfigType.defaultConfig, F_OK)) { + yconfig = readConfig(yabootConfigType.defaultConfig, + &yabootConfigType); + if (!yconfig) + yrc = 1; + else + yrc = checkForYaboot(yconfig); + } + + if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 || + erc == 1) + return 1; + + if (lrc == 2) printf("lilo\n"); + if (gr2c == 2) printf("grub2\n"); + if (grc == 2) printf("grub\n"); + if (extrc == 2) printf("extlinux\n"); + if (yrc == 2) printf("yaboot\n"); + if (erc == 2) printf("elilo\n"); + + return 0; + } + + if (grubConfig == NULL) { + printf("Could not find bootloader configuration file.\n"); + exit(1); + } + + config = readConfig(grubConfig, cfi); + if (!config) return 1; + + if (displayDefault) { + struct singleLine * line; + struct singleEntry * entry; + char * rootspec; + + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && + cfi->defaultIsSaved) + config->defaultImage = 0; + entry = findEntryByIndex(config, config->defaultImage); + if (!entry) return 0; + if (!suitableImage(entry, bootPrefix, 0, flags)) return 0; + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) return 0; + + rootspec = getRootSpecifier(line->elements[1].item); + printf("%s%s\n", bootPrefix, line->elements[1].item + + ((rootspec != NULL) ? strlen(rootspec) : 0)); + + return 0; + + } else if (displayDefaultTitle) { + struct singleLine * line; + struct singleEntry * entry; + + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && + cfi->defaultIsSaved) + config->defaultImage = 0; + entry = findEntryByIndex(config, config->defaultImage); + if (!entry) return 0; + + if (!configureGrub2) { + line = getLineByType(LT_TITLE, entry->lines); + if (!line) return 0; + printf("%s\n", line->elements[1].item); + + } else { + char * title; + + dbgPrintf("This is GRUB2, default title is embeded in menuentry\n"); + line = getLineByType(LT_MENUENTRY, entry->lines); + if (!line) return 0; + title = grub2ExtractTitle(line); + if (title) + printf("%s\n", title); + } + return 0; + + } else if (displayDefaultIndex) { + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && + cfi->defaultIsSaved) + config->defaultImage = 0; + printf("%i\n", config->defaultImage); + return 0; + + } else if (kernelInfo) + return displayInfo(config, kernelInfo, bootPrefix); + + if (copyDefault) { + template = findTemplate(config, bootPrefix, NULL, 0, flags); + if (!template) return 1; + } + + markRemovedImage(config, removeKernelPath, bootPrefix); + markRemovedImage(config, removeMBKernel, bootPrefix); + setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, + bootPrefix, flags, defaultIndex); + setFallbackImage(config, newKernelPath != NULL); + if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, + removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; + if (updateKernelPath && newKernelInitrd) { + if (newMBKernel) { + if (addMBInitrd(config, newMBKernel, updateKernelPath, + bootPrefix, newKernelInitrd, + newKernelTitle)) + return 1; + } else { + if (updateInitrd(config, updateKernelPath, bootPrefix, + newKernelInitrd, newKernelTitle)) + return 1; + } + } + if (addNewKernel(config, template, bootPrefix, newKernelPath, + newKernelTitle, newKernelArgs, newKernelInitrd, + (const char **)extraInitrds, extraInitrdCount, + newMBKernel, newMBKernelArgs, newDevTreePath)) return 1; + + + if (numEntries(config) == 0) { + fprintf(stderr, _("grubby: doing this would leave no kernel entries. " + "Not writing out new config.\n")); + return 1; + } + + if (!outputFile) + outputFile = (char *)grubConfig; + + return writeConfig(config, outputFile, bootPrefix); +} diff --git a/grubby-8.40-1/grubby.c.orig b/grubby-8.40-1/grubby.c.orig new file mode 100644 index 0000000..0b61e8e --- /dev/null +++ b/grubby-8.40-1/grubby.c.orig @@ -0,0 +1,4739 @@ +/* + * grubby.c + * + * Copyright (C) 2001-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "log.h" + +#ifndef DEBUG +#define DEBUG 0 +#endif + +#if DEBUG +#define dbgPrintf(format, args...) fprintf(stderr, format , ## args) +#else +#define dbgPrintf(format, args...) +#endif + +int debug = 0; /* Currently just for template debugging */ + +#define _(A) (A) + +#define MAX_EXTRA_INITRDS 16 /* code segment checked by --bootloader-probe */ +#define CODE_SEG_SIZE 128 /* code segment checked by --bootloader-probe */ + +#define NOOP_OPCODE 0x90 +#define JMP_SHORT_OPCODE 0xeb + +int isEfi = 0; + +#if defined(__aarch64__) +#define isEfiOnly 1 +#else +#define isEfiOnly 0 +#endif + +char *saved_command_line = NULL; + +/* comments get lumped in with indention */ +struct lineElement { + char * item; + char * indent; +}; + +enum lineType_e { + LT_WHITESPACE = 1 << 0, + LT_TITLE = 1 << 1, + LT_KERNEL = 1 << 2, + LT_INITRD = 1 << 3, + LT_HYPER = 1 << 4, + LT_DEFAULT = 1 << 5, + LT_MBMODULE = 1 << 6, + LT_ROOT = 1 << 7, + LT_FALLBACK = 1 << 8, + LT_KERNELARGS = 1 << 9, + LT_BOOT = 1 << 10, + LT_BOOTROOT = 1 << 11, + LT_LBA = 1 << 12, + LT_OTHER = 1 << 13, + LT_GENERIC = 1 << 14, + LT_ECHO = 1 << 16, + LT_MENUENTRY = 1 << 17, + LT_ENTRY_END = 1 << 18, + LT_SET_VARIABLE = 1 << 19, + LT_KERNEL_EFI = 1 << 20, + LT_INITRD_EFI = 1 << 21, + LT_KERNEL_16 = 1 << 22, + LT_INITRD_16 = 1 << 23, + LT_DEVTREE = 1 << 24, + LT_UNKNOWN = 1 << 25, +}; + +struct singleLine { + char * indent; + int numElements; + struct lineElement * elements; + struct singleLine * next; + enum lineType_e type; +}; + +struct singleEntry { + struct singleLine * lines; + int skip; + int multiboot; + struct singleEntry * next; +}; + +#define GRUBBY_BADIMAGE_OKAY (1 << 0) + +#define GRUB_CONFIG_NO_DEFAULT (1 << 0) /* don't write out default=0 */ + +/* These defines are (only) used in addNewKernel() */ +#define NEED_KERNEL (1 << 0) +#define NEED_INITRD (1 << 1) +#define NEED_TITLE (1 << 2) +#define NEED_ARGS (1 << 3) +#define NEED_MB (1 << 4) +#define NEED_END (1 << 5) +#define NEED_DEVTREE (1 << 6) + +#define MAIN_DEFAULT (1 << 0) +#define DEFAULT_SAVED -2 +#define DEFAULT_SAVED_GRUB2 -3 + +struct keywordTypes { + char * key; + enum lineType_e type; + char nextChar; + char separatorChar; +}; + +struct configFileInfo; + +typedef const char *(*findConfigFunc)(struct configFileInfo *); +typedef const int (*writeLineFunc)(struct configFileInfo *, + struct singleLine *line); +typedef char *(*getEnvFunc)(struct configFileInfo *, char *name); +typedef int (*setEnvFunc)(struct configFileInfo *, char *name, char *value); + +struct configFileInfo { + char * defaultConfig; + findConfigFunc findConfig; + writeLineFunc writeLine; + getEnvFunc getEnv; + setEnvFunc setEnv; + struct keywordTypes * keywords; + int caseInsensitive; + int defaultIsIndex; + int defaultIsVariable; + int defaultSupportSaved; + int defaultIsSaved; + int defaultIsUnquoted; + enum lineType_e entryStart; + enum lineType_e entryEnd; + int needsBootPrefix; + int argsInQuotes; + int maxTitleLength; + int titleBracketed; + int titlePosition; + int mbHyperFirst; + int mbInitRdIsModule; + int mbConcatArgs; + int mbAllowExtraInitRds; + char *envFile; +}; + +struct keywordTypes grubKeywords[] = { + { "title", LT_TITLE, ' ' }, + { "root", LT_BOOTROOT, ' ' }, + { "default", LT_DEFAULT, ' ' }, + { "fallback", LT_FALLBACK, ' ' }, + { "kernel", LT_KERNEL, ' ' }, + { "initrd", LT_INITRD, ' ', ' ' }, + { "module", LT_MBMODULE, ' ' }, + { "kernel", LT_HYPER, ' ' }, + { NULL, 0, 0 }, +}; + +const char *grubFindConfig(struct configFileInfo *cfi) { + static const char *configFiles[] = { + "/boot/grub/menu.lst", + "/etc/grub.conf", + NULL + }; + static int i = -1; + + if (i == -1) { + for (i = 0; configFiles[i] != NULL; i++) { + dbgPrintf("Checking \"%s\": ", configFiles[i]); + if (!access(configFiles[i], R_OK)) { + dbgPrintf("found\n"); + return configFiles[i]; + } + dbgPrintf("not found\n"); + } + } + return configFiles[i]; +} + +struct configFileInfo grubConfigType = { + .findConfig = grubFindConfig, + .keywords = grubKeywords, + .defaultIsIndex = 1, + .defaultSupportSaved = 1, + .entryStart = LT_TITLE, + .needsBootPrefix = 1, + .mbHyperFirst = 1, + .mbInitRdIsModule = 1, + .mbAllowExtraInitRds = 1, + .titlePosition = 1, +}; + +struct keywordTypes grub2Keywords[] = { + { "menuentry", LT_MENUENTRY, ' ' }, + { "}", LT_ENTRY_END, ' ' }, + { "echo", LT_ECHO, ' ' }, + { "set", LT_SET_VARIABLE,' ', '=' }, + { "root", LT_BOOTROOT, ' ' }, + { "default", LT_DEFAULT, ' ' }, + { "fallback", LT_FALLBACK, ' ' }, + { "linux", LT_KERNEL, ' ' }, + { "linuxefi", LT_KERNEL_EFI, ' ' }, + { "linux16", LT_KERNEL_16, ' ' }, + { "initrd", LT_INITRD, ' ', ' ' }, + { "initrdefi", LT_INITRD_EFI, ' ', ' ' }, + { "initrd16", LT_INITRD_16, ' ', ' ' }, + { "module", LT_MBMODULE, ' ' }, + { "kernel", LT_HYPER, ' ' }, + { "devicetree", LT_DEVTREE, ' ' }, + { NULL, 0, 0 }, +}; + +const char *grub2FindConfig(struct configFileInfo *cfi) { + static const char *configFiles[] = { + "/etc/grub2-efi.cfg", + "/etc/grub2.cfg", + "/boot/grub2/grub.cfg", + "/boot/grub2-efi/grub.cfg", + NULL + }; + static int i = -1; + static const char *grub_cfg = "/boot/grub/grub.cfg"; + int rc = -1; + + if (i == -1) { + for (i = 0; configFiles[i] != NULL; i++) { + dbgPrintf("Checking \"%s\": ", configFiles[i]); + if ((rc = access(configFiles[i], R_OK))) { + if (errno == EACCES) { + printf("Unable to access bootloader configuration file " + "\"%s\": %m\n", configFiles[i]); + exit(1); + } + continue; + } else { + dbgPrintf("found\n"); + return configFiles[i]; + } + } + } + + /* Ubuntu renames grub2 to grub, so check for the grub.d directory + * that isn't in grub1, and if it exists, return the config file path + * that they use. */ + if (configFiles[i] == NULL && !access("/etc/grub.d/", R_OK)) { + dbgPrintf("found\n"); + return grub_cfg; + } + + dbgPrintf("not found\n"); + return configFiles[i]; +} + +/* kind of hacky. It'll give the first 1024 bytes, ish. */ +static char *grub2GetEnv(struct configFileInfo *info, char *name) +{ + static char buf[1025]; + char *s = NULL; + char *ret = NULL; + char *envFile = info->envFile ? info->envFile : "/boot/grub2/grubenv"; + int rc = asprintf(&s, "grub2-editenv %s list | grep '^%s='", envFile, name); + + if (rc < 0) + return NULL; + + FILE *f = popen(s, "r"); + if (!f) + goto out; + + memset(buf, '\0', sizeof (buf)); + ret = fgets(buf, 1024, f); + pclose(f); + + if (ret) { + ret += strlen(name) + 1; + ret[strlen(ret) - 1] = '\0'; + } + dbgPrintf("grub2GetEnv(%s): %s\n", name, ret); +out: + free(s); + return ret; +} + +static int sPopCount(const char *s, const char *c) +{ + int ret = 0; + if (!s) + return -1; + for (int i = 0; s[i] != '\0'; i++) + for (int j = 0; c[j] != '\0'; j++) + if (s[i] == c[j]) + ret++; + return ret; +} + +static char *shellEscape(const char *s) +{ + int l = strlen(s) + sPopCount(s, "'") * 2; + + char *ret = calloc(l+1, sizeof (*ret)); + if (!ret) + return NULL; + for (int i = 0, j = 0; s[i] != '\0'; i++, j++) { + if (s[i] == '\'') + ret[j++] = '\\'; + ret[j] = s[i]; + } + return ret; +} + +static void unquote(char *s) +{ + int l = strlen(s); + + if ((s[l-1] == '\'' && s[0] == '\'') || (s[l-1] == '"' && s[0] == '"')) { + memmove(s, s+1, l-2); + s[l-2] = '\0'; + } +} + +static int grub2SetEnv(struct configFileInfo *info, char *name, char *value) +{ + char *s = NULL; + int rc = 0; + char *envFile = info->envFile ? info->envFile : "/boot/grub2/grubenv"; + + unquote(value); + value = shellEscape(value); + if (!value) + return -1; + + rc = asprintf(&s, "grub2-editenv %s set '%s=%s'", envFile, name, value); + free(value); + if (rc <0) + return -1; + + dbgPrintf("grub2SetEnv(%s): %s\n", name, s); + rc = system(s); + free(s); + return rc; +} + +/* this is a gigantic hack to avoid clobbering grub2 variables... */ +static int is_special_grub2_variable(const char *name) +{ + if (!strcmp(name,"\"${next_entry}\"")) + return 1; + if (!strcmp(name,"\"${prev_saved_entry}\"")) + return 1; + return 0; +} + +int sizeOfSingleLine(struct singleLine * line) { + int count = 0; + + for (int i = 0; i < line->numElements; i++) { + int indentSize = 0; + + count = count + strlen(line->elements[i].item); + + indentSize = strlen(line->elements[i].indent); + if (indentSize > 0) + count = count + indentSize; + else + /* be extra safe and add room for whitespaces */ + count = count + 1; + } + + /* room for trailing terminator */ + count = count + 1; + + return count; +} + +static int isquote(char q) +{ + if (q == '\'' || q == '\"') + return 1; + return 0; +} + +static int iskernel(enum lineType_e type) { + return (type == LT_KERNEL || type == LT_KERNEL_EFI || type == LT_KERNEL_16); +} + +static int isinitrd(enum lineType_e type) { + return (type == LT_INITRD || type == LT_INITRD_EFI || type == LT_INITRD_16); +} + +char *grub2ExtractTitle(struct singleLine * line) { + char * current; + char * current_indent; + int current_len; + int current_indent_len; + int i; + + /* bail out if line does not start with menuentry */ + if (strcmp(line->elements[0].item, "menuentry")) + return NULL; + + i = 1; + current = line->elements[i].item; + current_len = strlen(current); + + /* if second word is quoted, strip the quotes and return single word */ + if (isquote(*current) && isquote(current[current_len - 1])) { + char *tmp; + + tmp = strdup(current); + *(tmp + current_len - 1) = '\0'; + return ++tmp; + } + + /* if no quotes, return second word verbatim */ + if (!isquote(*current)) + return current; + + /* second element start with a quote, so we have to find the element + * whose last character is also quote (assuming it's the closing one) */ + int resultMaxSize; + char * result; + + resultMaxSize = sizeOfSingleLine(line); + result = malloc(resultMaxSize); + snprintf(result, resultMaxSize, "%s", ++current); + + i++; + int result_len = 0; + for (; i < line->numElements; ++i) { + current = line->elements[i].item; + current_len = strlen(current); + current_indent = line->elements[i].indent; + current_indent_len = strlen(current_indent); + + memcpy(result + result_len, current_indent, current_indent_len); + result_len += current_indent_len; + + if (!isquote(current[current_len-1])) { + memcpy(result + result_len, current_indent, current_indent_len); + result_len += current_len; + } else { + memcpy(result + result_len, current_indent, current_indent_len); + result_len += (current_len - 1); + break; + } + } + result[result_len] = '\0'; + return result; +} + +struct configFileInfo grub2ConfigType = { + .findConfig = grub2FindConfig, + .getEnv = grub2GetEnv, + .setEnv = grub2SetEnv, + .keywords = grub2Keywords, + .defaultIsIndex = 1, + .defaultSupportSaved = 1, + .defaultIsVariable = 1, + .entryStart = LT_MENUENTRY, + .entryEnd = LT_ENTRY_END, + .titlePosition = 1, + .needsBootPrefix = 1, + .mbHyperFirst = 1, + .mbInitRdIsModule = 1, + .mbAllowExtraInitRds = 1, +}; + +struct keywordTypes yabootKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "bsd", LT_GENERIC, '=' }, + { "macos", LT_GENERIC, '=' }, + { "macosx", LT_GENERIC, '=' }, + { "magicboot", LT_GENERIC, '=' }, + { "darwin", LT_GENERIC, '=' }, + { "timeout", LT_GENERIC, '=' }, + { "install", LT_GENERIC, '=' }, + { "fstype", LT_GENERIC, '=' }, + { "hfstype", LT_GENERIC, '=' }, + { "delay", LT_GENERIC, '=' }, + { "defaultos", LT_GENERIC, '=' }, + { "init-message", LT_GENERIC, '=' }, + { "enablecdboot", LT_GENERIC, ' ' }, + { "enableofboot", LT_GENERIC, ' ' }, + { "enablenetboot", LT_GENERIC, ' ' }, + { "nonvram", LT_GENERIC, ' ' }, + { "hide", LT_GENERIC, ' ' }, + { "protect", LT_GENERIC, ' ' }, + { "nobless", LT_GENERIC, ' ' }, + { "nonvram", LT_GENERIC, ' ' }, + { "brokenosx", LT_GENERIC, ' ' }, + { "usemount", LT_GENERIC, ' ' }, + { "mntpoint", LT_GENERIC, '=' }, + { "partition", LT_GENERIC, '=' }, + { "device", LT_GENERIC, '=' }, + { "fstype", LT_GENERIC, '=' }, + { "initrd", LT_INITRD, '=', ';' }, + { "append", LT_KERNELARGS, '=' }, + { "boot", LT_BOOT, '=' }, + { "lba", LT_LBA, ' ' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes liloKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "other", LT_OTHER, '=' }, + { "initrd", LT_INITRD, '=' }, + { "append", LT_KERNELARGS, '=' }, + { "boot", LT_BOOT, '=' }, + { "lba", LT_LBA, ' ' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes eliloKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "initrd", LT_INITRD, '=' }, + { "append", LT_KERNELARGS, '=' }, + { "vmm", LT_HYPER, '=' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes siloKeywords[] = { + { "label", LT_TITLE, '=' }, + { "root", LT_ROOT, '=' }, + { "default", LT_DEFAULT, '=' }, + { "image", LT_KERNEL, '=' }, + { "other", LT_OTHER, '=' }, + { "initrd", LT_INITRD, '=' }, + { "append", LT_KERNELARGS, '=' }, + { "boot", LT_BOOT, '=' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes ziplKeywords[] = { + { "target", LT_BOOTROOT, '=' }, + { "image", LT_KERNEL, '=' }, + { "ramdisk", LT_INITRD, '=' }, + { "parameters", LT_KERNELARGS, '=' }, + { "default", LT_DEFAULT, '=' }, + { NULL, 0, 0 }, +}; + +struct keywordTypes extlinuxKeywords[] = { + { "label", LT_TITLE, ' ' }, + { "root", LT_ROOT, ' ' }, + { "default", LT_DEFAULT, ' ' }, + { "kernel", LT_KERNEL, ' ' }, + { "initrd", LT_INITRD, ' ', ',' }, + { "append", LT_KERNELARGS, ' ' }, + { "prompt", LT_UNKNOWN, ' ' }, + { "fdt", LT_DEVTREE, ' ' }, + { "fdtdir", LT_DEVTREE, ' ' }, + { NULL, 0, 0 }, +}; +int useextlinuxmenu; +struct configFileInfo eliloConfigType = { + .defaultConfig = "/boot/efi/EFI/redhat/elilo.conf", + .keywords = eliloKeywords, + .entryStart = LT_KERNEL, + .needsBootPrefix = 1, + .argsInQuotes = 1, + .mbConcatArgs = 1, + .titlePosition = 1, +}; + +struct configFileInfo liloConfigType = { + .defaultConfig = "/etc/lilo.conf", + .keywords = liloKeywords, + .entryStart = LT_KERNEL, + .argsInQuotes = 1, + .maxTitleLength = 15, + .titlePosition = 1, +}; + +struct configFileInfo yabootConfigType = { + .defaultConfig = "/etc/yaboot.conf", + .keywords = yabootKeywords, + .entryStart = LT_KERNEL, + .needsBootPrefix = 1, + .argsInQuotes = 1, + .maxTitleLength = 15, + .mbAllowExtraInitRds = 1, + .titlePosition = 1, +}; + +struct configFileInfo siloConfigType = { + .defaultConfig = "/etc/silo.conf", + .keywords = siloKeywords, + .entryStart = LT_KERNEL, + .needsBootPrefix = 1, + .argsInQuotes = 1, + .maxTitleLength = 15, + .titlePosition = 1, +}; + +struct configFileInfo ziplConfigType = { + .defaultConfig = "/etc/zipl.conf", + .keywords = ziplKeywords, + .entryStart = LT_TITLE, + .argsInQuotes = 1, + .titleBracketed = 1, +}; + +struct configFileInfo extlinuxConfigType = { + .defaultConfig = "/boot/extlinux/extlinux.conf", + .keywords = extlinuxKeywords, + .caseInsensitive = 1, + .entryStart = LT_TITLE, + .needsBootPrefix = 1, + .maxTitleLength = 255, + .mbAllowExtraInitRds = 1, + .defaultIsUnquoted = 1, + .titlePosition = 1, +}; + +struct grubConfig { + struct singleLine * theLines; + struct singleEntry * entries; + char * primaryIndent; + char * secondaryIndent; + int defaultImage; /* -1 if none specified -- this value is + * written out, overriding original */ + int fallbackImage; /* just like defaultImage */ + int flags; + struct configFileInfo * cfi; +}; + +blkid_cache blkid; + +struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index); +struct singleEntry * findEntryByPath(struct grubConfig * cfg, + const char * path, const char * prefix, + int * index); +struct singleEntry * findEntryByTitle(struct grubConfig * cfg, char *title, + int * index); +static int readFile(int fd, char ** bufPtr); +static void lineInit(struct singleLine * line); +struct singleLine * lineDup(struct singleLine * line); +static void lineFree(struct singleLine * line); +static int lineWrite(FILE * out, struct singleLine * line, + struct configFileInfo * cfi); +static int getNextLine(char ** bufPtr, struct singleLine * line, + struct configFileInfo * cfi); +static char * getRootSpecifier(char * str); +static void requote(struct singleLine *line, struct configFileInfo * cfi); +static void insertElement(struct singleLine * line, + const char * item, int insertHere, + struct configFileInfo * cfi); +static void removeElement(struct singleLine * line, int removeHere); +static struct keywordTypes * getKeywordByType(enum lineType_e type, + struct configFileInfo * cfi); +static enum lineType_e getTypeByKeyword(char * keyword, + struct configFileInfo * cfi); +static struct singleLine * getLineByType(enum lineType_e type, + struct singleLine * line); +static int checkForExtLinux(struct grubConfig * config); +struct singleLine * addLineTmpl(struct singleEntry * entry, + struct singleLine * tmplLine, + struct singleLine * prevLine, + const char * val, + struct configFileInfo * cfi); +struct singleLine * addLine(struct singleEntry * entry, + struct configFileInfo * cfi, + enum lineType_e type, char * defaultIndent, + const char * val); + +static char * sdupprintf(const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 1, 2))); +#else + ; +#endif + +static char * sdupprintf(const char *format, ...) { + char *buf = NULL; + char c; + va_list args; + size_t size = 0; + va_start(args, format); + + /* XXX requires C99 vsnprintf behavior */ + size = vsnprintf(&c, 1, format, args) + 1; + if (size == -1) { + printf("ERROR: vsnprintf behavior is not C99\n"); + abort(); + } + + va_end(args); + va_start(args, format); + + buf = malloc(size); + if (buf == NULL) + return NULL; + vsnprintf(buf, size, format, args); + va_end (args); + + return buf; +} + +static enum lineType_e preferredLineType(enum lineType_e type, + struct configFileInfo *cfi) { + if (isEfi && cfi == &grub2ConfigType) { + switch (type) { + case LT_KERNEL: + return isEfiOnly ? LT_KERNEL : LT_KERNEL_EFI; + case LT_INITRD: + return isEfiOnly ? LT_INITRD : LT_INITRD_EFI; + default: + return type; + } +#if defined(__i386__) || defined(__x86_64__) + } else if (cfi == &grub2ConfigType) { + switch (type) { + case LT_KERNEL: + return LT_KERNEL_16; + case LT_INITRD: + return LT_INITRD_16; + default: + return type; + } +#endif + } + return type; +} + +static struct keywordTypes * getKeywordByType(enum lineType_e type, + struct configFileInfo * cfi) { + for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { + if (kw->type == type) + return kw; + } + return NULL; +} + +static char *getKeyByType(enum lineType_e type, struct configFileInfo * cfi) { + struct keywordTypes *kt = getKeywordByType(type, cfi); + if (kt) + return kt->key; + return "unknown"; +} + +static char * getpathbyspec(char *device) { + if (!blkid) + blkid_get_cache(&blkid, NULL); + + return blkid_get_devname(blkid, device, NULL); +} + +static char * getuuidbydev(char *device) { + if (!blkid) + blkid_get_cache(&blkid, NULL); + + return blkid_get_tag_value(blkid, "UUID", device); +} + +static enum lineType_e getTypeByKeyword(char * keyword, + struct configFileInfo * cfi) { + for (struct keywordTypes *kw = cfi->keywords; kw->key; kw++) { + if (cfi->caseInsensitive) { + if (!strcasecmp(keyword, kw->key)) + return kw->type; + } else { + if (!strcmp(keyword, kw->key)) + return kw->type; + } + } + return LT_UNKNOWN; +} + +static struct singleLine * getLineByType(enum lineType_e type, + struct singleLine * line) { + dbgPrintf("getLineByType(%d): ", type); + for (; line; line = line->next) { + dbgPrintf("%d:%s ", line->type, + line->numElements ? line->elements[0].item : "(empty)"); + if (line->type & type) break; + } + dbgPrintf(line ? "\n" : " (failed)\n"); + return line; +} + +static int isBracketedTitle(struct singleLine * line) { + if (line->numElements == 1 && *line->elements[0].item == '[') { + int len = strlen(line->elements[0].item); + if (*(line->elements[0].item + len - 1) == ']') { + /* FIXME: this is a hack... */ + if (strcmp(line->elements[0].item, "[defaultboot]")) { + return 1; + } + } + } + return 0; +} + +static int isEntryStart(struct singleLine * line, + struct configFileInfo * cfi) { + return line->type == cfi->entryStart || line->type == LT_OTHER || + (cfi->titleBracketed && isBracketedTitle(line)); +} + +/* extract the title from within brackets (for zipl) */ +static char * extractTitle(struct grubConfig *cfg, struct singleLine * line) { + /* bracketed title... let's extract it */ + char * title = NULL; + if (line->type == LT_TITLE) { + char *tmp = line->elements[cfg->cfi->titlePosition].item; + if (cfg->cfi->titleBracketed) { + tmp++; + title = strdup(tmp); + *(title + strlen(title) - 1) = '\0'; + } else { + title = strdup(tmp); + } + } else if (line->type == LT_MENUENTRY) + title = strdup(line->elements[1].item); + else + return NULL; + return title; +} + +static int readFile(int fd, char ** bufPtr) { + int alloced = 0, size = 0, i = 0; + char * buf = NULL; + + do { + size += i; + if ((size + 1024) > alloced) { + alloced += 4096; + buf = realloc(buf, alloced + 1); + } + } while ((i = read(fd, buf + size, 1024)) > 0); + + if (i < 0) { + fprintf(stderr, _("error reading input: %s\n"), strerror(errno)); + free(buf); + return 1; + } + + buf = realloc(buf, size + 2); + if (size == 0) + buf[size++] = '\n'; + else + if (buf[size - 1] != '\n') + buf[size++] = '\n'; + buf[size] = '\0'; + + *bufPtr = buf; + + return 0; +} + +static void lineInit(struct singleLine * line) { + line->indent = NULL; + line->elements = NULL; + line->numElements = 0; + line->next = NULL; +} + +struct singleLine * lineDup(struct singleLine * line) { + struct singleLine * newLine = malloc(sizeof(*newLine)); + + newLine->indent = strdup(line->indent); + newLine->next = NULL; + newLine->type = line->type; + newLine->numElements = line->numElements; + newLine->elements = malloc(sizeof(*newLine->elements) * + newLine->numElements); + + for (int i = 0; i < newLine->numElements; i++) { + newLine->elements[i].indent = strdup(line->elements[i].indent); + newLine->elements[i].item = strdup(line->elements[i].item); + } + + return newLine; +} + +static void lineFree(struct singleLine * line) { + if (line->indent) free(line->indent); + + for (int i = 0; i < line->numElements; i++) { + free(line->elements[i].item); + free(line->elements[i].indent); + } + + if (line->elements) free(line->elements); + lineInit(line); +} + +static int lineWrite(FILE * out, struct singleLine * line, + struct configFileInfo * cfi) { + if (fprintf(out, "%s", line->indent) == -1) return -1; + + for (int i = 0; i < line->numElements; i++) { + /* Need to handle this, because we strip the quotes from + * menuentry when read it. */ + if (line->type == LT_MENUENTRY && i == 1) { + if(!isquote(*line->elements[i].item)) + fprintf(out, "\'%s\'", line->elements[i].item); + else + fprintf(out, "%s", line->elements[i].item); + fprintf(out, "%s", line->elements[i].indent); + + continue; + } + + if (i == 1 && line->type == LT_KERNELARGS && cfi->argsInQuotes) + if (fputc('"', out) == EOF) return -1; + + if (fprintf(out, "%s", line->elements[i].item) == -1) return -1; + if (i < line->numElements - 1) + if (fprintf(out, "%s", line->elements[i].indent) == -1) return -1; + } + + if (line->type == LT_KERNELARGS && cfi->argsInQuotes) + if (fputc('"', out) == EOF) return -1; + + if (fprintf(out, "\n") == -1) return -1; + + return 0; +} + +/* we've guaranteed that the buffer ends w/ \n\0 */ +static int getNextLine(char ** bufPtr, struct singleLine * line, + struct configFileInfo * cfi) { + char * end; + char * start = *bufPtr; + char * chptr; + int elementsAlloced = 0; + struct lineElement * element; + int first = 1; + + lineFree(line); + + end = strchr(start, '\n'); + *end = '\0'; + *bufPtr = end + 1; + + for (chptr = start; *chptr && isspace(*chptr); chptr++) ; + + line->indent = strndup(start, chptr - start); + start = chptr; + + while (start < end) { + /* we know !isspace(*start) */ + + if (elementsAlloced == line->numElements) { + elementsAlloced += 5; + line->elements = realloc(line->elements, + sizeof(*line->elements) * elementsAlloced); + } + + element = line->elements + line->numElements; + + chptr = start; + while (*chptr && !isspace(*chptr)) { + if (first && *chptr == '=') break; + chptr++; + } + element->item = strndup(start, chptr - start); + start = chptr; + + /* lilo actually accepts the pathological case of append = " foo " */ + if (*start == '=') + chptr = start + 1; + else + chptr = start; + + do { + for (; *chptr && isspace(*chptr); chptr++); + if (*chptr == '=') + chptr = chptr + 1; + } while (isspace(*chptr)); + + element->indent = strndup(start, chptr - start); + start = chptr; + + line->numElements++; + first = 0; + } + + if (!line->numElements) + line->type = LT_WHITESPACE; + else { + line->type = getTypeByKeyword(line->elements[0].item, cfi); + if (line->type == LT_UNKNOWN) { + /* zipl does [title] instead of something reasonable like all + * the other boot loaders. kind of ugly */ + if (cfi->titleBracketed && isBracketedTitle(line)) { + line->type = LT_TITLE; + } + + /* this is awkward, but we need to be able to handle keywords + that begin with a # (specifically for #boot in grub.conf), + but still make comments lines with no elements (everything + stored in the indent */ + if (*line->elements[0].item == '#') { + char * fullLine; + int len; + + len = strlen(line->indent); + for (int i = 0; i < line->numElements; i++) + len += strlen(line->elements[i].item) + + strlen(line->elements[i].indent); + + fullLine = malloc(len + 1); + strcpy(fullLine, line->indent); + free(line->indent); + line->indent = fullLine; + + for (int i = 0; i < line->numElements; i++) { + strcat(fullLine, line->elements[i].item); + strcat(fullLine, line->elements[i].indent); + free(line->elements[i].item); + free(line->elements[i].indent); + } + + line->type = LT_WHITESPACE; + line->numElements = 0; + } + } else { + struct keywordTypes *kw; + + kw = getKeywordByType(line->type, cfi); + + /* space isn't the only separator, we need to split + * elements up more + */ + if (!isspace(kw->separatorChar)) { + char indent[2] = ""; + indent[0] = kw->separatorChar; + for (int i = 1; i < line->numElements; i++) { + char *p; + int numNewElements; + + numNewElements = 0; + p = line->elements[i].item; + while (*p != '\0') { + if (*p == kw->separatorChar) + numNewElements++; + p++; + } + if (line->numElements + numNewElements >= elementsAlloced) { + elementsAlloced += numNewElements + 5; + line->elements = realloc(line->elements, + sizeof(*line->elements) * elementsAlloced); + } + + for (int j = line->numElements; j > i; j--) { + line->elements[j + numNewElements] = line->elements[j]; + } + line->numElements += numNewElements; + + p = line->elements[i].item; + while (*p != '\0') { + + while (*p != kw->separatorChar && *p != '\0') p++; + if (*p == '\0') { + break; + } + + line->elements[i + 1].indent = line->elements[i].indent; + line->elements[i].indent = strdup(indent); + *p++ = '\0'; + i++; + line->elements[i].item = strdup(p); + } + } + } + } + } + + return 0; +} + +static int isnumber(const char *s) +{ + int i; + for (i = 0; s[i] != '\0'; i++) + if (s[i] < '0' || s[i] > '9') + return 0; + return i; +} + +static struct grubConfig * readConfig(const char * inName, + struct configFileInfo * cfi) { + int in; + char * incoming = NULL, * head; + int rc; + int sawEntry = 0; + int movedLine = 0; + struct grubConfig * cfg; + struct singleLine * last = NULL, * line, * defaultLine = NULL; + char * end; + struct singleEntry * entry = NULL; + int len; + char * buf; + + if (inName == NULL) { + printf("Could not find bootloader configuration\n"); + exit(1); + } else if (!strcmp(inName, "-")) { + in = 0; + } else { + if ((in = open(inName, O_RDONLY)) < 0) { + fprintf(stderr, _("error opening %s for read: %s\n"), + inName, strerror(errno)); + return NULL; + } + } + + rc = readFile(in, &incoming); + close(in); + if (rc) return NULL; + + head = incoming; + cfg = malloc(sizeof(*cfg)); + cfg->primaryIndent = strdup(""); + cfg->secondaryIndent = strdup("\t"); + cfg->flags = GRUB_CONFIG_NO_DEFAULT; + cfg->cfi = cfi; + cfg->theLines = NULL; + cfg->entries = NULL; + cfg->fallbackImage = 0; + + /* copy everything we have */ + while (*head) { + line = malloc(sizeof(*line)); + lineInit(line); + + if (getNextLine(&head, line, cfi)) { + free(line); + /* XXX memory leak of everything in cfg */ + return NULL; + } + + if (!sawEntry && line->numElements) { + free(cfg->primaryIndent); + cfg->primaryIndent = strdup(line->indent); + } else if (line->numElements) { + free(cfg->secondaryIndent); + cfg->secondaryIndent = strdup(line->indent); + } + + if (isEntryStart(line, cfi) || (cfg->entries && !sawEntry)) { + sawEntry = 1; + if (!entry) { + cfg->entries = malloc(sizeof(*entry)); + entry = cfg->entries; + } else { + entry->next = malloc(sizeof(*entry)); + entry = entry->next; + } + + entry->skip = 0; + entry->multiboot = 0; + entry->lines = NULL; + entry->next = NULL; + } + + if (line->type == LT_SET_VARIABLE) { + dbgPrintf("found 'set' command (%d elements): ", line->numElements); + dbgPrintf("%s", line->indent); + for (int i = 0; i < line->numElements; i++) + dbgPrintf("\"%s\"%s", line->elements[i].item, line->elements[i].indent); + dbgPrintf("\n"); + struct keywordTypes *kwType = getKeywordByType(LT_DEFAULT, cfi); + if (kwType && line->numElements == 3 && + !strcmp(line->elements[1].item, kwType->key) && + !is_special_grub2_variable(line->elements[2].item)) { + dbgPrintf("Line sets default config\n"); + cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; + defaultLine = line; + } + + } else if (iskernel(line->type)) { + /* if by some freak chance this is multiboot and the "module" + * lines came earlier in the template, make sure to use LT_HYPER + * instead of LT_KERNEL now + */ + if (entry && entry->multiboot) + line->type = LT_HYPER; + + } else if (line->type == LT_MBMODULE) { + /* go back and fix the LT_KERNEL line to indicate LT_HYPER + * instead, now that we know this is a multiboot entry. + * This only applies to grub, but that's the only place we + * should find LT_MBMODULE lines anyway. + */ + for (struct singleLine *l = entry->lines; l; l = l->next) { + if (l->type == LT_HYPER) + break; + else if (iskernel(l->type)) { + l->type = LT_HYPER; + break; + } + } + entry->multiboot = 1; + + } else if (line->type == LT_HYPER) { + entry->multiboot = 1; + + } else if (line->type == LT_FALLBACK && line->numElements == 2) { + cfg->fallbackImage = strtol(line->elements[1].item, &end, 10); + if (*end) cfg->fallbackImage = -1; + + } else if ((line->type == LT_DEFAULT && cfi->defaultIsUnquoted) || + (line->type == LT_TITLE && line->numElements > 1)) { + /* make the title/default a single argument (undoing our parsing) */ + len = 0; + for (int i = 1; i < line->numElements; i++) { + len += strlen(line->elements[i].item); + len += strlen(line->elements[i].indent); + } + buf = malloc(len + 1); + *buf = '\0'; + + for (int i = 1; i < line->numElements; i++) { + strcat(buf, line->elements[i].item); + free(line->elements[i].item); + + if ((i + 1) != line->numElements) { + strcat(buf, line->elements[i].indent); + free(line->elements[i].indent); + } + } + + line->elements[1].indent = + line->elements[line->numElements - 1].indent; + line->elements[1].item = buf; + line->numElements = 2; + } else if (line->type == LT_MENUENTRY && line->numElements > 3) { + /* let --remove-kernel="TITLE=what" work */ + len = 0; + char *extras; + char *title; + + for (int i = 1; i < line->numElements; i++) { + len += strlen(line->elements[i].item); + len += strlen(line->elements[i].indent); + } + buf = malloc(len + 1); + *buf = '\0'; + + /* allocate mem for extra flags. */ + extras = malloc(len + 1); + *extras = '\0'; + + int buf_len = 0; + /* get title. */ + for (int i = 0; i < line->numElements; i++) { + if (!strcmp(line->elements[i].item, "menuentry")) + continue; + if (isquote(*line->elements[i].item)) + title = line->elements[i].item + 1; + else + title = line->elements[i].item; + + len = strlen(title); + if (isquote(title[len-1])) { + memcpy(buf + buf_len, title, len - 1); + buf_len += (len - 1); + break; + } else { + memcpy(buf + buf_len, title, len); + buf_len += len; + len = strlen(line->elements[i].indent); + memcpy(buf + buf_len, line->elements[i].indent, len); + buf_len += len; + } + } + buf[buf_len] = '\0'; + + /* get extras */ + int count = 0; + for (int i = 0; i < line->numElements; i++) { + if (count >= 2) { + strcat(extras, line->elements[i].item); + strcat(extras, line->elements[i].indent); + } + + if (!strcmp(line->elements[i].item, "menuentry")) + continue; + + /* count ' or ", there should be two in menuentry line. */ + if (isquote(*line->elements[i].item)) + count++; + + len = strlen(line->elements[i].item); + + if (isquote(line->elements[i].item[len -1])) + count++; + + /* ok, we get the final ' or ", others are extras. */ + } + line->elements[1].indent = + line->elements[line->numElements - 2].indent; + line->elements[1].item = buf; + line->elements[2].indent = + line->elements[line->numElements - 2].indent; + line->elements[2].item = extras; + line->numElements = 3; + } else if (line->type == LT_KERNELARGS && cfi->argsInQuotes) { + /* Strip off any " which may be present; they'll be put back + on write. This is one of the few (the only?) places that grubby + canonicalizes the output */ + + if (line->numElements >= 2) { + int last, len; + + if (isquote(*line->elements[1].item)) + memmove(line->elements[1].item, line->elements[1].item + 1, + strlen(line->elements[1].item + 1) + 1); + + last = line->numElements - 1; + len = strlen(line->elements[last].item) - 1; + if (isquote(line->elements[last].item[len])) + line->elements[last].item[len] = '\0'; + } + } + + if (line->type == LT_DEFAULT && line->numElements == 2) { + cfg->flags &= ~GRUB_CONFIG_NO_DEFAULT; + defaultLine = line; + } + + /* If we find a generic config option which should live at the + top of the file, move it there. Old versions of grubby were + probably responsible for putting new images in the wrong + place in front of it anyway. */ + if (sawEntry && line->type == LT_GENERIC) { + struct singleLine **l = &cfg->theLines; + struct singleLine **last_nonws = &cfg->theLines; + while (*l) { + if ((*l)->type != LT_WHITESPACE) + last_nonws = &((*l)->next); + l = &((*l)->next); + } + line->next = *last_nonws; + *last_nonws = line; + movedLine = 1; + continue; /* without setting 'last' */ + } + + /* If a second line of whitespace happens after a generic option + which was moved, drop it. */ + if (movedLine && line->type == LT_WHITESPACE && last->type == LT_WHITESPACE) { + lineFree(line); + free(line); + movedLine = 0; + continue; + } + movedLine = 0; + + if (sawEntry) { + if (!entry->lines) + entry->lines = line; + else + last->next = line; + dbgPrintf("readConfig added %s to %p\n", getKeyByType(line->type, cfi), entry); + + /* we could have seen this outside of an entry... if so, we + * ignore it like any other line we don't grok */ + if (line->type == LT_ENTRY_END && sawEntry) + sawEntry = 0; + } else { + if (!cfg->theLines) + cfg->theLines = line; + else + last->next = line; + dbgPrintf("readConfig added %s to cfg\n", getKeyByType(line->type, cfi)); + } + + last = line; + } + + free(incoming); + + dbgPrintf("defaultLine is %s\n", defaultLine ? "set" : "unset"); + if (defaultLine) { + if (defaultLine->numElements > 2 && + cfi->defaultSupportSaved && + !strncmp(defaultLine->elements[2].item,"\"${saved_entry}\"", 16)) { + cfg->cfi->defaultIsSaved = 1; + cfg->defaultImage = DEFAULT_SAVED_GRUB2; + if (cfg->cfi->getEnv) { + char *defTitle = cfi->getEnv(cfg->cfi, "saved_entry"); + if (defTitle) { + int index = 0; + if (isnumber(defTitle)) { + index = atoi(defTitle); + entry = findEntryByIndex(cfg, index); + } else { + entry = findEntryByTitle(cfg, defTitle, &index); + } + if (entry) + cfg->defaultImage = index; + } + } + } else if (cfi->defaultIsVariable) { + char *value = defaultLine->elements[2].item; + while (*value && (*value == '"' || *value == '\'' || + *value == ' ' || *value == '\t')) + value++; + cfg->defaultImage = strtol(value, &end, 10); + while (*end && (*end == '"' || *end == '\'' || + *end == ' ' || *end == '\t')) + end++; + if (*end) cfg->defaultImage = -1; + } else if (cfi->defaultSupportSaved && + !strncmp(defaultLine->elements[1].item, "saved", 5)) { + cfg->defaultImage = DEFAULT_SAVED; + } else if (cfi->defaultIsIndex) { + cfg->defaultImage = strtol(defaultLine->elements[1].item, &end, 10); + if (*end) cfg->defaultImage = -1; + } else if (defaultLine->numElements >= 2) { + int i = 0; + while ((entry = findEntryByIndex(cfg, i))) { + for (line = entry->lines; line; line = line->next) + if (line->type == LT_TITLE) break; + + if (!cfi->titleBracketed) { + if (line && (line->numElements >= 2) && + !strcmp(defaultLine->elements[1].item, + line->elements[1].item)) break; + } else if (line) { + if (!strcmp(defaultLine->elements[1].item, + extractTitle(cfg, line))) break; + } + i++; + entry = NULL; + } + + if (entry){ + cfg->defaultImage = i; + }else{ + cfg->defaultImage = -1; + } + } + } else if (cfg->cfi->defaultIsSaved && cfg->cfi->getEnv) { + char *defTitle = cfi->getEnv(cfg->cfi, "saved_entry"); + if (defTitle) { + int index = 0; + if (isnumber(defTitle)) { + index = atoi(defTitle); + entry = findEntryByIndex(cfg, index); + } else { + entry = findEntryByTitle(cfg, defTitle, &index); + } + if (entry) + cfg->defaultImage = index; + } + } else { + cfg->defaultImage = 0; + } + + return cfg; +} + +static void writeDefault(FILE * out, char * indent, + char * separator, struct grubConfig * cfg) { + struct singleEntry * entry; + struct singleLine * line; + int i; + + if (!cfg->defaultImage && cfg->flags == GRUB_CONFIG_NO_DEFAULT) return; + + if (cfg->defaultImage == DEFAULT_SAVED) + fprintf(out, "%sdefault%ssaved\n", indent, separator); + else if (cfg->cfi->defaultIsSaved) { + fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); + if (cfg->defaultImage >= 0 && cfg->cfi->setEnv) { + char *title; + entry = findEntryByIndex(cfg, cfg->defaultImage); + line = getLineByType(LT_MENUENTRY, entry->lines); + if (!line) + line = getLineByType(LT_TITLE, entry->lines); + if (line) { + title = extractTitle(cfg, line); + if (title) + cfg->cfi->setEnv(cfg->cfi, "saved_entry", title); + } + } + } else if (cfg->defaultImage > -1) { + if (cfg->cfi->defaultIsIndex) { + if (cfg->cfi->defaultIsVariable) { + fprintf(out, "%sset default=\"%d\"\n", indent, + cfg->defaultImage); + } else { + fprintf(out, "%sdefault%s%d\n", indent, separator, + cfg->defaultImage); + } + } else { + int image = cfg->defaultImage; + + entry = cfg->entries; + while (entry && entry->skip) entry = entry->next; + + i = 0; + while (entry && i < image) { + entry = entry->next; + + while (entry && entry->skip) entry = entry->next; + i++; + } + + if (!entry) return; + + line = getLineByType(LT_TITLE, entry->lines); + + if (line && line->numElements >= 2) + fprintf(out, "%sdefault%s%s\n", indent, separator, + line->elements[1].item); + else if (line && (line->numElements == 1) && + cfg->cfi->titleBracketed) { + fprintf(out, "%sdefault%s%s\n", indent, separator, + extractTitle(cfg, line)); + } + } + } +} + +static int writeConfig(struct grubConfig * cfg, char * outName, + const char * prefix) { + FILE * out; + struct singleLine * line; + struct singleEntry * entry; + char * tmpOutName; + int needs = MAIN_DEFAULT; + struct stat sb; + int i; + + if (!strcmp(outName, "-")) { + out = stdout; + tmpOutName = NULL; + } else { + if (!lstat(outName, &sb) && S_ISLNK(sb.st_mode)) { + char * buf; + int len = 256; + int rc; + + /* most likely the symlink is relative, so change our + directory to the dir of the symlink */ + char *dir = strdupa(outName); + rc = chdir(dirname(dir)); + do { + buf = alloca(len + 1); + rc = readlink(basename(outName), buf, len); + if (rc == len) len += 256; + } while (rc == len); + + if (rc < 0) { + fprintf(stderr, _("grubby: error readlink link %s: %s\n"), + outName, strerror(errno)); + return 1; + } + + outName = buf; + outName[rc] = '\0'; + } + + tmpOutName = alloca(strlen(outName) + 2); + sprintf(tmpOutName, "%s-", outName); + out = fopen(tmpOutName, "w"); + if (!out) { + fprintf(stderr, _("grubby: error creating %s: %s\n"), tmpOutName, + strerror(errno)); + return 1; + } + + if (!stat(outName, &sb)) { + if (chmod(tmpOutName, sb.st_mode & ~(S_IFMT))) { + fprintf(stderr, _("grubby: error setting perms on %s: %s\n"), + tmpOutName, strerror(errno)); + fclose(out); + unlink(tmpOutName); + return 1; + } + } + } + + line = cfg->theLines; + struct keywordTypes *defaultKw = getKeywordByType(LT_DEFAULT, cfg->cfi); + while (line) { + if (line->type == LT_SET_VARIABLE && defaultKw && + line->numElements == 3 && + !strcmp(line->elements[1].item, defaultKw->key) && + !is_special_grub2_variable(line->elements[2].item)) { + writeDefault(out, line->indent, line->elements[0].indent, cfg); + needs &= ~MAIN_DEFAULT; + } else if (line->type == LT_DEFAULT) { + writeDefault(out, line->indent, line->elements[0].indent, cfg); + needs &= ~MAIN_DEFAULT; + } else if (line->type == LT_FALLBACK) { + if (cfg->fallbackImage > -1) + fprintf(out, "%s%s%s%d\n", line->indent, + line->elements[0].item, line->elements[0].indent, + cfg->fallbackImage); + } else { + if (lineWrite(out, line, cfg->cfi) == -1) { + fprintf(stderr, _("grubby: error writing %s: %s\n"), + tmpOutName, strerror(errno)); + fclose(out); + unlink(tmpOutName); + return 1; + } + } + + line = line->next; + } + + if (needs & MAIN_DEFAULT) { + writeDefault(out, cfg->primaryIndent, "=", cfg); + needs &= ~MAIN_DEFAULT; + } + + i = 0; + while ((entry = findEntryByIndex(cfg, i++))) { + if (entry->skip) continue; + + line = entry->lines; + while (line) { + if (lineWrite(out, line, cfg->cfi) == -1) { + fprintf(stderr, _("grubby: error writing %s: %s\n"), + tmpOutName, strerror(errno)); + fclose(out); + unlink(tmpOutName); + return 1; + } + line = line->next; + } + } + + if (tmpOutName) { + if (rename(tmpOutName, outName)) { + fprintf(stderr, _("grubby: error moving %s to %s: %s\n"), + tmpOutName, outName, strerror(errno)); + unlink(outName); + return 1; + } + } + + return 0; +} + +static int numEntries(struct grubConfig *cfg) { + int i = 0; + struct singleEntry * entry; + + entry = cfg->entries; + while (entry) { + if (!entry->skip) + i++; + entry = entry->next; + } + return i; +} + +static char *findDiskForRoot() +{ + int fd; + char buf[65536]; + char *devname; + char *chptr; + int rc; + + if ((fd = open(_PATH_MOUNTED, O_RDONLY)) < 0) { + fprintf(stderr, "grubby: failed to open %s: %s\n", + _PATH_MOUNTED, strerror(errno)); + return NULL; + } + + rc = read(fd, buf, sizeof(buf) - 1); + if (rc <= 0) { + fprintf(stderr, "grubby: failed to read %s: %s\n", + _PATH_MOUNTED, strerror(errno)); + close(fd); + return NULL; + } + close(fd); + buf[rc] = '\0'; + chptr = buf; + + char *foundanswer = NULL; + + while (chptr && chptr != buf+rc) { + devname = chptr; + + /* + * The first column of a mtab entry is the device, but if the entry is a + * special device it won't start with /, so move on to the next line. + */ + if (*devname != '/') { + chptr = strchr(chptr, '\n'); + if (chptr) + chptr++; + continue; + } + + /* Seek to the next space */ + chptr = strchr(chptr, ' '); + if (!chptr) { + fprintf(stderr, "grubby: error parsing %s: %s\n", + _PATH_MOUNTED, strerror(errno)); + return NULL; + } + + /* + * The second column of a mtab entry is the mount point, we are looking + * for '/' obviously. + */ + if (*(++chptr) == '/' && *(++chptr) == ' ') { + /* remember the last / entry in mtab */ + foundanswer = devname; + } + + /* Next line */ + chptr = strchr(chptr, '\n'); + if (chptr) + chptr++; + } + + /* Return the last / entry found */ + if (foundanswer) { + chptr = strchr(foundanswer, ' '); + *chptr = '\0'; + return strdup(foundanswer); + } + + return NULL; +} + +void printEntry(struct singleEntry * entry, FILE *f) { + int i; + struct singleLine * line; + + for (line = entry->lines; line; line = line->next) { + log_message(f, "DBG: %s", line->indent); + for (i = 0; i < line->numElements; i++) { + /* Need to handle this, because we strip the quotes from + * menuentry when read it. */ + if (line->type == LT_MENUENTRY && i == 1) { + if(!isquote(*line->elements[i].item)) + log_message(f, "\'%s\'", line->elements[i].item); + else + log_message(f, "%s", line->elements[i].item); + log_message(f, "%s", line->elements[i].indent); + + continue; + } + + log_message(f, "%s%s", + line->elements[i].item, line->elements[i].indent); + } + log_message(f, "\n"); + } +} + +void notSuitablePrintf(struct singleEntry * entry, int okay, const char *fmt, ...) +{ + static int once; + va_list argp, argq; + + va_start(argp, fmt); + + va_copy(argq, argp); + if (!once) { + log_time(NULL); + log_message(NULL, "command line: %s\n", saved_command_line); + } + log_message(NULL, "DBG: Image entry %s: ", okay ? "succeeded" : "failed"); + log_vmessage(NULL, fmt, argq); + + printEntry(entry, NULL); + va_end(argq); + + if (!debug) { + once = 1; + va_end(argp); + return; + } + + if (okay) { + va_end(argp); + return; + } + + if (!once) + log_message(stderr, "DBG: command line: %s\n", saved_command_line); + once = 1; + fprintf(stderr, "DBG: Image entry failed: "); + vfprintf(stderr, fmt, argp); + printEntry(entry, stderr); + va_end(argp); +} + +#define beginswith(s, c) ((s) && (s)[0] == (c)) + +static int endswith(const char *s, char c) +{ + int slen; + + if (!s || !s[0]) + return 0; + slen = strlen(s) - 1; + + return s[slen] == c; +} + +int suitableImage(struct singleEntry * entry, const char * bootPrefix, + int skipRemoved, int flags) { + struct singleLine * line; + char * fullName; + int i; + char * dev; + char * rootspec; + char * rootdev; + + if (skipRemoved && entry->skip) { + notSuitablePrintf(entry, 0, "marked to skip\n"); + return 0; + } + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) { + notSuitablePrintf(entry, 0, "no line found\n"); + return 0; + } + if (line->numElements < 2) { + notSuitablePrintf(entry, 0, "line has only %d elements\n", + line->numElements); + return 0; + } + + if (flags & GRUBBY_BADIMAGE_OKAY) { + notSuitablePrintf(entry, 1, "\n"); + return 1; + } + + fullName = alloca(strlen(bootPrefix) + + strlen(line->elements[1].item) + 1); + rootspec = getRootSpecifier(line->elements[1].item); + int rootspec_offset = rootspec ? strlen(rootspec) : 0; + int hasslash = endswith(bootPrefix, '/') || + beginswith(line->elements[1].item + rootspec_offset, '/'); + sprintf(fullName, "%s%s%s", bootPrefix, hasslash ? "" : "/", + line->elements[1].item + rootspec_offset); + if (access(fullName, R_OK)) { + notSuitablePrintf(entry, 0, "access to %s failed\n", fullName); + return 0; + } + for (i = 2; i < line->numElements; i++) + if (!strncasecmp(line->elements[i].item, "root=", 5)) break; + if (i < line->numElements) { + dev = line->elements[i].item + 5; + } else { + /* look for a lilo style LT_ROOT line */ + line = getLineByType(LT_ROOT, entry->lines); + + if (line && line->numElements >= 2) { + dev = line->elements[1].item; + } else { + /* didn't succeed in finding a LT_ROOT, let's try LT_KERNELARGS. + * grub+multiboot uses LT_MBMODULE for the args, so check that too. + */ + line = getLineByType(LT_KERNELARGS|LT_MBMODULE, entry->lines); + + /* failed to find one */ + if (!line) { + notSuitablePrintf(entry, 0, "no line found\n"); + return 0; + } + + for (i = 1; i < line->numElements; i++) + if (!strncasecmp(line->elements[i].item, "root=", 5)) break; + if (i < line->numElements) + dev = line->elements[i].item + 5; + else { + notSuitablePrintf(entry, 0, "no root= entry found\n"); + /* it failed too... can't find root= */ + return 0; + } + } + } + + dev = getpathbyspec(dev); + if (!getpathbyspec(dev)) { + notSuitablePrintf(entry, 0, "can't find blkid entry for %s\n", dev); + return 0; + } else + dev = getpathbyspec(dev); + + rootdev = findDiskForRoot(); + if (!rootdev) { + notSuitablePrintf(entry, 0, "can't find root device\n"); + return 0; + } + + if (!getuuidbydev(rootdev) || !getuuidbydev(dev)) { + notSuitablePrintf(entry, 0, "uuid missing: rootdev %s, dev %s\n", + getuuidbydev(rootdev), getuuidbydev(dev)); + free(rootdev); + return 0; + } + + if (strcmp(getuuidbydev(rootdev), getuuidbydev(dev))) { + notSuitablePrintf(entry, 0, "uuid mismatch: rootdev %s, dev %s\n", + getuuidbydev(rootdev), getuuidbydev(dev)); + free(rootdev); + return 0; + } + + free(rootdev); + notSuitablePrintf(entry, 1, "\n"); + + return 1; +} + +/* returns the first match on or after the one pointed to by index (if index + is not NULL) which is not marked as skip */ +struct singleEntry * findEntryByPath(struct grubConfig * config, + const char * kernel, const char * prefix, + int * index) { + struct singleEntry * entry = NULL; + struct singleLine * line; + int i; + char * chptr; + char * rootspec = NULL; + enum lineType_e checkType = LT_KERNEL; + + if (isdigit(*kernel)) { + int * indexVars = alloca(sizeof(*indexVars) * strlen(kernel)); + + i = 0; + indexVars[i] = strtol(kernel, &chptr, 10); + while (*chptr == ',') { + i++; + kernel = chptr + 1; + indexVars[i] = strtol(kernel, &chptr, 10); + } + + if (*chptr) { + /* can't parse it, bail */ + return NULL; + } + + indexVars[i + 1] = -1; + + i = 0; + if (index) { + while (i < *index) { + i++; + if (indexVars[i] == -1) return NULL; + } + } + + entry = findEntryByIndex(config, indexVars[i]); + if (!entry) return NULL; + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) return NULL; + + if (index) *index = indexVars[i]; + return entry; + } + + if (!strcmp(kernel, "DEFAULT")) { + if (index && *index > config->defaultImage) { + entry = NULL; + } else { + entry = findEntryByIndex(config, config->defaultImage); + if (entry && entry->skip) + entry = NULL; + else if (index) + *index = config->defaultImage; + } + } else if (!strcmp(kernel, "ALL")) { + if (index) + i = *index; + else + i = 0; + + while ((entry = findEntryByIndex(config, i))) { + if (!entry->skip) break; + i++; + } + + if (entry && index) + *index = i; + } else { + if (index) + i = *index; + else + i = 0; + + if (!strncmp(kernel, "TITLE=", 6)) { + prefix = ""; + checkType = LT_TITLE|LT_MENUENTRY; + kernel += 6; + } + + for (entry = findEntryByIndex(config, i); entry; entry = entry->next, i++) { + if (entry->skip) continue; + + dbgPrintf("findEntryByPath looking for %d %s in %p\n", checkType, kernel, entry); + + /* check all the lines matching checkType */ + for (line = entry->lines; line; line = line->next) { + enum lineType_e ct = checkType; + if (entry->multiboot && checkType == LT_KERNEL) + ct = LT_KERNEL|LT_KERNEL_EFI|LT_MBMODULE|LT_HYPER|LT_KERNEL_16; + else if (checkType & LT_KERNEL) + ct = checkType | LT_KERNEL_EFI | LT_KERNEL_16; + line = getLineByType(ct, line); + if (!line) + break; /* not found in this entry */ + + if (line && line->type != LT_MENUENTRY && + line->numElements >= 2) { + rootspec = getRootSpecifier(line->elements[1].item); + if (!strcmp(line->elements[1].item + + ((rootspec != NULL) ? strlen(rootspec) : 0), + kernel + strlen(prefix))) + break; + } + if(line->type == LT_MENUENTRY && + !strcmp(line->elements[1].item, kernel)) + break; + } + + /* make sure this entry has a kernel identifier; this skips + * non-Linux boot entries (could find netbsd etc, though, which is + * unfortunate) + */ + if (line && getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines)) + break; /* found 'im! */ + } + + if (index) *index = i; + } + + return entry; +} + +struct singleEntry * findEntryByTitle(struct grubConfig * cfg, char *title, + int * index) { + struct singleEntry * entry; + struct singleLine * line; + int i; + char * newtitle; + + for (i = 0, entry = cfg->entries; entry; entry = entry->next, i++) { + if (index && i < *index) + continue; + line = getLineByType(LT_TITLE, entry->lines); + if (!line) + line = getLineByType(LT_MENUENTRY, entry->lines); + if (!line) + continue; + newtitle = grub2ExtractTitle(line); + if (!newtitle) + continue; + if (!strcmp(title, newtitle)) + break; + } + + if (!entry) + return NULL; + + if (index) + *index = i; + return entry; +} + +struct singleEntry * findEntryByIndex(struct grubConfig * cfg, int index) { + struct singleEntry * entry; + + entry = cfg->entries; + while (index && entry) { + entry = entry->next; + index--; + } + + return entry; +} + +/* Find a good template to use for the new kernel. An entry is + * good if the kernel and mkinitrd exist (even if the entry + * is going to be removed). Try and use the default entry, but + * if that doesn't work just take the first. If we can't find one, + * bail. */ +struct singleEntry * findTemplate(struct grubConfig * cfg, const char * prefix, + int * indexPtr, int skipRemoved, int flags) { + struct singleEntry * entry, * entry2; + int index; + + if (cfg->cfi->defaultIsSaved) { + if (cfg->cfi->getEnv) { + char *defTitle = cfg->cfi->getEnv(cfg->cfi, "saved_entry"); + if (defTitle) { + int index = 0; + if (isnumber(defTitle)) { + index = atoi(defTitle); + entry = findEntryByIndex(cfg, index); + } else { + entry = findEntryByTitle(cfg, defTitle, &index); + } + if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { + cfg->defaultImage = index; + if (indexPtr) + *indexPtr = index; + return entry; + } + } + } + } else if (cfg->defaultImage > -1) { + entry = findEntryByIndex(cfg, cfg->defaultImage); + if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { + if (indexPtr) *indexPtr = cfg->defaultImage; + return entry; + } + } + + index = 0; + while ((entry = findEntryByIndex(cfg, index))) { + if (suitableImage(entry, prefix, skipRemoved, flags)) { + int j; + for (j = 0; j < index; j++) { + entry2 = findEntryByIndex(cfg, j); + if (entry2->skip) index--; + } + if (indexPtr) *indexPtr = index; + + return entry; + } + + index++; + } + + fprintf(stderr, _("grubby fatal error: unable to find a suitable template\n")); + + return NULL; +} + +char * findBootPrefix(void) { + struct stat sb, sb2; + + stat("/", &sb); +#ifdef __ia64__ + stat("/boot/efi/EFI/redhat/", &sb2); +#else + stat("/boot", &sb2); +#endif + + if (sb.st_dev == sb2.st_dev) + return strdup(""); + +#ifdef __ia64__ + return strdup("/boot/efi/EFI/redhat/"); +#else + return strdup("/boot"); +#endif +} + +void markRemovedImage(struct grubConfig * cfg, const char * image, + const char * prefix) { + struct singleEntry * entry; + + if (!image) + return; + + /* check and see if we're removing the default image */ + if (isdigit(*image)) { + entry = findEntryByPath(cfg, image, prefix, NULL); + if(entry) + entry->skip = 1; + return; + } + + while ((entry = findEntryByPath(cfg, image, prefix, NULL))) + entry->skip = 1; +} + +void setDefaultImage(struct grubConfig * config, int hasNew, + const char * defaultKernelPath, int newIsDefault, + const char * prefix, int flags, int index) { + struct singleEntry * entry, * entry2, * newDefault; + int i, j; + + if (newIsDefault) { + config->defaultImage = 0; + return; + } else if ((index >= 0) && config->cfi->defaultIsIndex) { + if (findEntryByIndex(config, index)) + config->defaultImage = index; + else + config->defaultImage = -1; + return; + } else if (defaultKernelPath) { + i = 0; + if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { + config->defaultImage = i; + } else { + config->defaultImage = -1; + return; + } + } + + /* defaultImage now points to what we'd like to use, but before any order + changes */ + if ((config->defaultImage == DEFAULT_SAVED) || + (config->defaultImage == DEFAULT_SAVED_GRUB2)) + /* default is set to saved, we don't want to change it */ + return; + + if (config->defaultImage > -1) + entry = findEntryByIndex(config, config->defaultImage); + else + entry = NULL; + + if (entry && !entry->skip) { + /* we can preserve the default */ + if (hasNew) + config->defaultImage++; + + /* count the number of entries erased before this one */ + for (j = 0; j < config->defaultImage; j++) { + entry2 = findEntryByIndex(config, j); + if (entry2->skip) config->defaultImage--; + } + } else if (hasNew) { + config->defaultImage = 0; + } else { + /* Either we just erased the default (or the default line was bad + * to begin with) and didn't put a new one in. We'll use the first + * valid image. */ + newDefault = findTemplate(config, prefix, &config->defaultImage, 1, + flags); + if (!newDefault) + config->defaultImage = -1; + } +} + +void setFallbackImage(struct grubConfig * config, int hasNew) { + struct singleEntry * entry, * entry2; + int j; + + if (config->fallbackImage == -1) return; + + entry = findEntryByIndex(config, config->fallbackImage); + if (!entry || entry->skip) { + config->fallbackImage = -1; + return; + } + + if (hasNew) + config->fallbackImage++; + + /* count the number of entries erased before this one */ + for (j = 0; j < config->fallbackImage; j++) { + entry2 = findEntryByIndex(config, j); + if (entry2->skip) config->fallbackImage--; + } +} + +void displayEntry(struct singleEntry * entry, const char * prefix, int index) { + struct singleLine * line; + char * root = NULL; + int i; + int j; + + printf("index=%d\n", index); + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) { + printf("non linux entry\n"); + return; + } + + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("kernel=%s\n", line->elements[1].item); + else + printf("kernel=%s%s\n", prefix, line->elements[1].item); + + if (line->numElements >= 3) { + printf("args=\""); + i = 2; + while (i < line->numElements) { + if (!strncmp(line->elements[i].item, "root=", 5)) { + root = line->elements[i].item + 5; + } else { + printf("%s%s", line->elements[i].item, + line->elements[i].indent); + } + + i++; + } + printf("\"\n"); + } else { + line = getLineByType(LT_KERNELARGS, entry->lines); + if (line) { + char * s; + + printf("args=\""); + i = 1; + while (i < line->numElements) { + if (!strncmp(line->elements[i].item, "root=", 5)) { + root = line->elements[i].item + 5; + } else { + s = line->elements[i].item; + + printf("%s%s", s, line->elements[i].indent); + } + + i++; + } + + s = line->elements[i - 1].indent; + printf("\"\n"); + } + } + + if (!root) { + line = getLineByType(LT_ROOT, entry->lines); + if (line && line->numElements >= 2) + root=line->elements[1].item; + } + + if (root) { + char * s = alloca(strlen(root) + 1); + + strcpy(s, root); + if (s[strlen(s) - 1] == '"') + s[strlen(s) - 1] = '\0'; + /* make sure the root doesn't have a trailing " */ + printf("root=%s\n", s); + } + + line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); + + if (line && line->numElements >= 2) { + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("initrd="); + else + printf("initrd=%s", prefix); + + for (i = 1; i < line->numElements; i++) + printf("%s%s", line->elements[i].item, line->elements[i].indent); + printf("\n"); + } + + line = getLineByType(LT_TITLE, entry->lines); + if (line) { + printf("title=%s\n", line->elements[1].item); + } else { + char * title; + line = getLineByType(LT_MENUENTRY, entry->lines); + if (line) { + title = grub2ExtractTitle(line); + if (title) + printf("title=%s\n", title); + } + } + + for (j = 0, line = entry->lines; line; line = line->next) { + if ((line->type & LT_MBMODULE) && line->numElements >= 2) { + if (!strncmp(prefix, line->elements[1].item, strlen(prefix))) + printf("mbmodule%d=", j); + else + printf("mbmodule%d=%s", j, prefix); + + for (i = 1; i < line->numElements; i++) + printf("%s%s", line->elements[i].item, line->elements[i].indent); + printf("\n"); + j++; + } + } +} + +int isSuseSystem(void) { + const char * path; + const static char default_path[] = "/etc/SuSE-release"; + + if ((path = getenv("GRUBBY_SUSE_RELEASE")) == NULL) + path = default_path; + + if (!access(path, R_OK)) + return 1; + return 0; +} + +int isSuseGrubConf(const char * path) { + FILE * grubConf; + char * line = NULL; + size_t len = 0, res = 0; + + grubConf = fopen(path, "r"); + if (!grubConf) { + dbgPrintf("Could not open SuSE configuration file '%s'\n", path); + return 0; + } + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (!strncmp(line, "setup", 5)) { + fclose(grubConf); + free(line); + return 1; + } + } + + dbgPrintf("SuSE configuration file '%s' does not appear to be valid\n", + path); + + fclose(grubConf); + free(line); + return 0; +} + +int suseGrubConfGetLba(const char * path, int * lbaPtr) { + FILE * grubConf; + char * line = NULL; + size_t res = 0, len = 0; + + if (!path) return 1; + if (!lbaPtr) return 1; + + grubConf = fopen(path, "r"); + if (!grubConf) return 1; + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + if (!strncmp(line, "setup", 5)) { + if (strstr(line, "--force-lba")) { + *lbaPtr = 1; + } else { + *lbaPtr = 0; + } + dbgPrintf("lba: %i\n", *lbaPtr); + break; + } + } + + free(line); + fclose(grubConf); + return 0; +} + +int suseGrubConfGetInstallDevice(const char * path, char ** devicePtr) { + FILE * grubConf; + char * line = NULL; + size_t res = 0, len = 0; + char * lastParamPtr = NULL; + char * secLastParamPtr = NULL; + char installDeviceNumber = '\0'; + char * bounds = NULL; + + if (!path) return 1; + if (!devicePtr) return 1; + + grubConf = fopen(path, "r"); + if (!grubConf) return 1; + + while ((res = getline(&line, &len, grubConf)) != -1) { + if (strncmp(line, "setup", 5)) + continue; + + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + lastParamPtr = bounds = line + res; + + /* Last parameter in grub may be an optional IMAGE_DEVICE */ + while (!isspace(*lastParamPtr)) + lastParamPtr--; + lastParamPtr++; + + secLastParamPtr = lastParamPtr - 2; + dbgPrintf("lastParamPtr: %s\n", lastParamPtr); + + if (lastParamPtr + 3 > bounds) { + dbgPrintf("lastParamPtr going over boundary"); + fclose(grubConf); + free(line); + return 1; + } + if (!strncmp(lastParamPtr, "(hd", 3)) + lastParamPtr += 3; + dbgPrintf("lastParamPtr: %c\n", *lastParamPtr); + + /* + * Second last parameter will decide wether last parameter is + * an IMAGE_DEVICE or INSTALL_DEVICE + */ + while (!isspace(*secLastParamPtr)) + secLastParamPtr--; + secLastParamPtr++; + + if (secLastParamPtr + 3 > bounds) { + dbgPrintf("secLastParamPtr going over boundary"); + fclose(grubConf); + free(line); + return 1; + } + dbgPrintf("secLastParamPtr: %s\n", secLastParamPtr); + if (!strncmp(secLastParamPtr, "(hd", 3)) { + secLastParamPtr += 3; + dbgPrintf("secLastParamPtr: %c\n", *secLastParamPtr); + installDeviceNumber = *secLastParamPtr; + } else { + installDeviceNumber = *lastParamPtr; + } + + *devicePtr = malloc(6); + snprintf(*devicePtr, 6, "(hd%c)", installDeviceNumber); + dbgPrintf("installDeviceNumber: %c\n", installDeviceNumber); + fclose(grubConf); + free(line); + return 0; + } + + free(line); + fclose(grubConf); + return 1; +} + +int grubGetBootFromDeviceMap(const char * device, + char ** bootPtr) { + FILE * deviceMap; + char * line = NULL; + size_t res = 0, len = 0; + char * devicePtr; + char * bounds = NULL; + const char * path; + const static char default_path[] = "/boot/grub/device.map"; + + if (!device) return 1; + if (!bootPtr) return 1; + + if ((path = getenv("GRUBBY_GRUB_DEVICE_MAP")) == NULL) + path = default_path; + + dbgPrintf("opening grub device.map file from: %s\n", path); + deviceMap = fopen(path, "r"); + if (!deviceMap) + return 1; + + while ((res = getline(&line, &len, deviceMap)) != -1) { + if (!strncmp(line, "#", 1)) + continue; + + if (line[res - 1] == '\n') + line[res - 1] = '\0'; + else if (len > res) + line[res] = '\0'; + else { + line = realloc(line, res + 1); + line[res] = '\0'; + } + + devicePtr = line; + bounds = line + res; + + while ((isspace(*line) && ((devicePtr + 1) <= bounds))) + devicePtr++; + dbgPrintf("device: %s\n", devicePtr); + + if (!strncmp(devicePtr, device, strlen(device))) { + devicePtr += strlen(device); + while (isspace(*devicePtr) && ((devicePtr + 1) <= bounds)) + devicePtr++; + + *bootPtr = strdup(devicePtr); + break; + } + } + + free(line); + fclose(deviceMap); + return 0; +} + +int suseGrubConfGetBoot(const char * path, char ** bootPtr) { + char * grubDevice; + + if (suseGrubConfGetInstallDevice(path, &grubDevice)) + dbgPrintf("error looking for grub installation device\n"); + else + dbgPrintf("grubby installation device: %s\n", grubDevice); + + if (grubGetBootFromDeviceMap(grubDevice, bootPtr)) + dbgPrintf("error looking for grub boot device\n"); + else + dbgPrintf("grubby boot device: %s\n", *bootPtr); + + free(grubDevice); + return 0; +} + +int parseSuseGrubConf(int * lbaPtr, char ** bootPtr) { + /* + * This SuSE grub configuration file at this location is not your average + * grub configuration file, but instead the grub commands used to setup + * grub on that system. + */ + const char * path; + const static char default_path[] = "/etc/grub.conf"; + + if ((path = getenv("GRUBBY_SUSE_GRUB_CONF")) == NULL) + path = default_path; + + if (!isSuseGrubConf(path)) return 1; + + if (lbaPtr) { + *lbaPtr = 0; + if (suseGrubConfGetLba(path, lbaPtr)) + return 1; + } + + if (bootPtr) { + *bootPtr = NULL; + suseGrubConfGetBoot(path, bootPtr); + } + + return 0; +} + +int parseSysconfigGrub(int * lbaPtr, char ** bootPtr) { + FILE * in; + char buf[1024]; + char * chptr; + char * start; + char * param; + + in = fopen("/etc/sysconfig/grub", "r"); + if (!in) return 1; + + if (lbaPtr) *lbaPtr = 0; + if (bootPtr) *bootPtr = NULL; + + while (fgets(buf, sizeof(buf), in)) { + start = buf; + while (isspace(*start)) start++; + if (*start == '#') continue; + + chptr = strchr(start, '='); + if (!chptr) continue; + chptr--; + while (*chptr && isspace(*chptr)) chptr--; + chptr++; + *chptr = '\0'; + + param = chptr + 1; + while (*param && isspace(*param)) param++; + if (*param == '=') { + param++; + while (*param && isspace(*param)) param++; + } + + chptr = param; + while (*chptr && !isspace(*chptr)) chptr++; + *chptr = '\0'; + + if (!strcmp(start, "forcelba") && !strcmp(param, "1") && lbaPtr) + *lbaPtr = 1; + else if (!strcmp(start, "boot") && bootPtr) + *bootPtr = strdup(param); + } + + fclose(in); + + return 0; +} + +void dumpSysconfigGrub(void) { + char * boot = NULL; + int lba; + + if (isSuseSystem()) { + if (parseSuseGrubConf(&lba, &boot)) { + free(boot); + return; + } + } else { + if (parseSysconfigGrub(&lba, &boot)) { + free(boot); + return; + } + } + + if (lba) printf("lba\n"); + if (boot) { + printf("boot=%s\n", boot); + free(boot); + } +} + +int displayInfo(struct grubConfig * config, char * kernel, + const char * prefix) { + int i = 0; + struct singleEntry * entry; + struct singleLine * line; + + entry = findEntryByPath(config, kernel, prefix, &i); + if (!entry) { + fprintf(stderr, _("grubby: kernel not found\n")); + return 1; + } + + /* this is a horrible hack to support /etc/sysconfig/grub; there must + be a better way */ + if (config->cfi == &grubConfigType) { + dumpSysconfigGrub(); + } else { + line = getLineByType(LT_BOOT, config->theLines); + if (line && line->numElements >= 1) { + printf("boot=%s\n", line->elements[1].item); + } + + line = getLineByType(LT_LBA, config->theLines); + if (line) printf("lba\n"); + } + + displayEntry(entry, prefix, i); + + i++; + while ((entry = findEntryByPath(config, kernel, prefix, &i))) { + displayEntry(entry, prefix, i); + i++; + } + + return 0; +} + +struct singleLine * addLineTmpl(struct singleEntry * entry, + struct singleLine * tmplLine, + struct singleLine * prevLine, + const char * val, + struct configFileInfo * cfi) +{ + struct singleLine * newLine = lineDup(tmplLine); + + if (isEfi && cfi == &grub2ConfigType) { + enum lineType_e old = newLine->type; + newLine->type = preferredLineType(newLine->type, cfi); + if (old != newLine->type) + newLine->elements[0].item = getKeyByType(newLine->type, cfi); + } + + if (val) { + /* override the inherited value with our own. + * This is a little weak because it only applies to elements[1] + */ + if (newLine->numElements > 1) + removeElement(newLine, 1); + insertElement(newLine, val, 1, cfi); + + /* but try to keep the rootspec from the template... sigh */ + if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) { + char * rootspec = getRootSpecifier(tmplLine->elements[1].item); + if (rootspec != NULL) { + free(newLine->elements[1].item); + newLine->elements[1].item = + sdupprintf("%s%s", rootspec, val); + } + } + } + + dbgPrintf("addLineTmpl(%s)\n", newLine->numElements ? + newLine->elements[0].item : ""); + + if (!entry->lines) { + /* first one on the list */ + entry->lines = newLine; + } else if (prevLine) { + /* add after prevLine */ + newLine->next = prevLine->next; + prevLine->next = newLine; + } + + return newLine; +} + +/* val may be NULL */ +struct singleLine * addLine(struct singleEntry * entry, + struct configFileInfo * cfi, + enum lineType_e type, char * defaultIndent, + const char * val) { + struct singleLine * line, * prev; + struct keywordTypes * kw; + struct singleLine tmpl; + + /* NB: This function shouldn't allocate items on the heap, rather on the + * stack since it calls addLineTmpl which will make copies. + */ + if (type == LT_TITLE && cfi->titleBracketed) { + /* we're doing a bracketed title (zipl) */ + tmpl.type = type; + tmpl.numElements = 1; + tmpl.elements = alloca(sizeof(*tmpl.elements)); + tmpl.elements[0].item = alloca(strlen(val)+3); + sprintf(tmpl.elements[0].item, "[%s]", val); + tmpl.elements[0].indent = ""; + val = NULL; + } else if (type == LT_MENUENTRY) { + char *lineend = "--class gnu-linux --class gnu --class os {"; + if (!val) { + fprintf(stderr, "Line type LT_MENUENTRY requires a value\n"); + abort(); + } + kw = getKeywordByType(type, cfi); + if (!kw) { + fprintf(stderr, "Looking up keyword for unknown type %d\n", type); + abort(); + } + tmpl.indent = ""; + tmpl.type = type; + tmpl.numElements = 3; + tmpl.elements = alloca(sizeof(*tmpl.elements) * tmpl.numElements); + tmpl.elements[0].item = kw->key; + tmpl.elements[0].indent = alloca(2); + sprintf(tmpl.elements[0].indent, "%c", kw->nextChar); + tmpl.elements[1].item = (char *)val; + tmpl.elements[1].indent = alloca(2); + sprintf(tmpl.elements[1].indent, "%c", kw->nextChar); + tmpl.elements[2].item = alloca(strlen(lineend)+1); + strcpy(tmpl.elements[2].item, lineend); + tmpl.elements[2].indent = ""; + } else { + kw = getKeywordByType(type, cfi); + if (!kw) { + fprintf(stderr, "Looking up keyword for unknown type %d\n", type); + abort(); + } + tmpl.type = type; + tmpl.numElements = val ? 2 : 1; + tmpl.elements = alloca(sizeof(*tmpl.elements) * tmpl.numElements); + tmpl.elements[0].item = kw->key; + tmpl.elements[0].indent = alloca(2); + sprintf(tmpl.elements[0].indent, "%c", kw->nextChar); + if (val) { + tmpl.elements[1].item = (char *)val; + tmpl.elements[1].indent = ""; + } + } + + /* The last non-empty line gives us the indention to us and the line + to insert after. Note that comments are considered empty lines, which + may not be ideal? If there are no lines or we are looking at the + first line, we use defaultIndent (the first line is normally indented + differently from the rest) */ + for (line = entry->lines, prev = NULL; line; line = line->next) { + if (line->numElements) prev = line; + /* fall back on the last line if prev isn't otherwise set */ + if (!line->next && !prev) prev = line; + } + + struct singleLine *menuEntry; + menuEntry = getLineByType(LT_MENUENTRY, entry->lines); + if (tmpl.type == LT_ENTRY_END) { + if (menuEntry) + tmpl.indent = menuEntry->indent; + else + tmpl.indent = defaultIndent ?: ""; + } else if (tmpl.type != LT_MENUENTRY) { + if (menuEntry) + tmpl.indent = "\t"; + else if (prev == entry->lines) + tmpl.indent = defaultIndent ?: ""; + else + tmpl.indent = prev->indent; + } + + return addLineTmpl(entry, &tmpl, prev, val, cfi); +} + +void removeLine(struct singleEntry * entry, struct singleLine * line) { + struct singleLine * prev; + int i; + + for (i = 0; i < line->numElements; i++) { + free(line->elements[i].item); + free(line->elements[i].indent); + } + free(line->elements); + free(line->indent); + + if (line == entry->lines) { + entry->lines = line->next; + } else { + prev = entry->lines; + while (prev->next != line) prev = prev->next; + prev->next = line->next; + } + + free(line); +} + +static void requote(struct singleLine *tmplLine, struct configFileInfo * cfi) +{ + struct singleLine newLine = { + .indent = tmplLine->indent, + .type = tmplLine->type, + .next = tmplLine->next, + }; + int firstQuotedItem = -1; + int quoteLen = 0; + int j; + int element = 0; + char *c; + + c = malloc(strlen(tmplLine->elements[0].item) + 1); + strcpy(c, tmplLine->elements[0].item); + insertElement(&newLine, c, element++, cfi); + free(c); + c = NULL; + + for (j = 1; j < tmplLine->numElements; j++) { + if (firstQuotedItem == -1) { + quoteLen += strlen(tmplLine->elements[j].item); + + if (isquote(tmplLine->elements[j].item[0])) { + firstQuotedItem = j; + quoteLen += strlen(tmplLine->elements[j].indent); + } else { + c = malloc(quoteLen + 1); + strcpy(c, tmplLine->elements[j].item); + insertElement(&newLine, c, element++, cfi); + free(c); + quoteLen = 0; + } + } else { + int itemlen = strlen(tmplLine->elements[j].item); + quoteLen += itemlen; + quoteLen += strlen(tmplLine->elements[j].indent); + + if (isquote(tmplLine->elements[j].item[itemlen - 1])) { + c = malloc(quoteLen + 1); + c[0] = '\0'; + for (int i = firstQuotedItem; i < j+1; i++) { + strcat(c, tmplLine->elements[i].item); + strcat(c, tmplLine->elements[i].indent); + } + insertElement(&newLine, c, element++, cfi); + free(c); + + firstQuotedItem = -1; + quoteLen = 0; + } + } + } + while (tmplLine->numElements) + removeElement(tmplLine, 0); + if (tmplLine->elements) + free(tmplLine->elements); + + tmplLine->numElements = newLine.numElements; + tmplLine->elements = newLine.elements; +} + +static void insertElement(struct singleLine * line, + const char * item, int insertHere, + struct configFileInfo * cfi) +{ + struct keywordTypes * kw; + char indent[2] = ""; + + /* sanity check */ + if (insertHere > line->numElements) { + dbgPrintf("insertElement() adjusting insertHere from %d to %d\n", + insertHere, line->numElements); + insertHere = line->numElements; + } + + line->elements = realloc(line->elements, (line->numElements + 1) * + sizeof(*line->elements)); + memmove(&line->elements[insertHere+1], + &line->elements[insertHere], + (line->numElements - insertHere) * + sizeof(*line->elements)); + line->elements[insertHere].item = strdup(item); + + kw = getKeywordByType(line->type, cfi); + + if (line->numElements == 0) { + indent[0] = '\0'; + } else if (insertHere == 0) { + indent[0] = kw->nextChar; + } else if (kw->separatorChar != '\0') { + indent[0] = kw->separatorChar; + } else { + indent[0] = ' '; + } + + if (insertHere > 0 && line->elements[insertHere-1].indent[0] == '\0') { + /* move the end-of-line forward */ + line->elements[insertHere].indent = + line->elements[insertHere-1].indent; + line->elements[insertHere-1].indent = strdup(indent); + } else { + line->elements[insertHere].indent = strdup(indent); + } + + line->numElements++; + + dbgPrintf("insertElement(%s, '%s%s', %d)\n", + line->elements[0].item, + line->elements[insertHere].item, + line->elements[insertHere].indent, + insertHere); +} + +static void removeElement(struct singleLine * line, int removeHere) { + int i; + + /* sanity check */ + if (removeHere >= line->numElements) return; + + dbgPrintf("removeElement(%s, %d:%s)\n", line->elements[0].item, + removeHere, line->elements[removeHere].item); + + free(line->elements[removeHere].item); + + if (removeHere > 1) { + /* previous argument gets this argument's post-indentation */ + free(line->elements[removeHere-1].indent); + line->elements[removeHere-1].indent = + line->elements[removeHere].indent; + } else { + free(line->elements[removeHere].indent); + } + + /* now collapse the array, but don't bother to realloc smaller */ + for (i = removeHere; i < line->numElements - 1; i++) + line->elements[i] = line->elements[i + 1]; + + line->numElements--; +} + +int argMatch(const char * one, const char * two) { + char * first, * second; + char * chptr; + + first = strcpy(alloca(strlen(one) + 1), one); + second = strcpy(alloca(strlen(two) + 1), two); + + chptr = strchr(first, '='); + if (chptr) *chptr = '\0'; + + chptr = strchr(second, '='); + if (chptr) *chptr = '\0'; + + return strcmp(first, second); +} + +int updateActualImage(struct grubConfig * cfg, const char * image, + const char * prefix, const char * addArgs, + const char * removeArgs, int multibootArgs) { + struct singleEntry * entry; + struct singleLine * line, * rootLine; + int index = 0; + int i, k; + const char ** newArgs, ** oldArgs; + const char ** arg; + int useKernelArgs, useRoot; + int firstElement; + int *usedElements; + int doreplace; + + if (!image) return 0; + + if (!addArgs) { + newArgs = malloc(sizeof(*newArgs)); + *newArgs = NULL; + } else { + if (poptParseArgvString(addArgs, NULL, &newArgs)) { + fprintf(stderr, + _("grubby: error separating arguments '%s'\n"), addArgs); + return 1; + } + } + + if (!removeArgs) { + oldArgs = malloc(sizeof(*oldArgs)); + *oldArgs = NULL; + } else { + if (poptParseArgvString(removeArgs, NULL, &oldArgs)) { + fprintf(stderr, + _("grubby: error separating arguments '%s'\n"), removeArgs); + free(newArgs); + return 1; + } + } + + + useKernelArgs = (getKeywordByType(LT_KERNELARGS, cfg->cfi) + && (!multibootArgs || cfg->cfi->mbConcatArgs)); + + useRoot = (getKeywordByType(LT_ROOT, cfg->cfi) + && !multibootArgs); + + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { + + if (multibootArgs && !entry->multiboot) + continue; + + /* Determine where to put the args. If this config supports + * LT_KERNELARGS, use that. Otherwise use + * LT_HYPER/LT_KERNEL/LT_MBMODULE lines. + */ + if (useKernelArgs) { + line = getLineByType(LT_KERNELARGS, entry->lines); + if (!line) { + /* no LT_KERNELARGS, need to add it */ + line = addLine(entry, cfg->cfi, LT_KERNELARGS, + cfg->secondaryIndent, NULL); + } + firstElement = 1; + + } else if (multibootArgs) { + line = getLineByType(LT_HYPER, entry->lines); + if (!line) { + /* a multiboot entry without LT_HYPER? */ + continue; + } + firstElement = 2; + + } else { + line = getLineByType(LT_KERNEL|LT_MBMODULE|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) { + /* no LT_KERNEL or LT_MBMODULE in this entry? */ + continue; + } + firstElement = 2; + } + + /* handle the elilo case which does: + * append="hypervisor args -- kernel args" + */ + if (entry->multiboot && cfg->cfi->mbConcatArgs) { + /* this is a multiboot entry, make sure there's + * -- on the args line + */ + for (i = firstElement; i < line->numElements; i++) { + if (!strcmp(line->elements[i].item, "--")) + break; + } + if (i == line->numElements) { + /* assume all existing args are kernel args, + * prepend -- to make it official + */ + insertElement(line, "--", firstElement, cfg->cfi); + i = firstElement; + } + if (!multibootArgs) { + /* kernel args start after the -- */ + firstElement = i + 1; + } + } else if (cfg->cfi->mbConcatArgs) { + /* this is a non-multiboot entry, remove hyper args */ + for (i = firstElement; i < line->numElements; i++) { + if (!strcmp(line->elements[i].item, "--")) + break; + } + if (i < line->numElements) { + /* remove args up to -- */ + while (strcmp(line->elements[firstElement].item, "--")) + removeElement(line, firstElement); + /* remove -- */ + removeElement(line, firstElement); + } + } + + usedElements = calloc(line->numElements, sizeof(*usedElements)); + + for (k = 0, arg = newArgs; *arg; arg++, k++) { + + doreplace = 1; + for (i = firstElement; i < line->numElements; i++) { + if (multibootArgs && cfg->cfi->mbConcatArgs && + !strcmp(line->elements[i].item, "--")) + { + /* reached the end of hyper args, insert here */ + doreplace = 0; + break; + } + if (usedElements[i]) + continue; + if (!argMatch(line->elements[i].item, *arg)) { + usedElements[i]=1; + break; + } + } + + if (i < line->numElements && doreplace) { + /* direct replacement */ + free(line->elements[i].item); + line->elements[i].item = strdup(*arg); + + } else if (useRoot && !strncmp(*arg, "root=/dev/", 10)) { + /* root= replacement */ + rootLine = getLineByType(LT_ROOT, entry->lines); + if (rootLine) { + free(rootLine->elements[1].item); + rootLine->elements[1].item = strdup(*arg + 5); + } else { + rootLine = addLine(entry, cfg->cfi, LT_ROOT, + cfg->secondaryIndent, *arg + 5); + } + } + + else { + /* insert/append */ + insertElement(line, *arg, i, cfg->cfi); + usedElements = realloc(usedElements, line->numElements * + sizeof(*usedElements)); + memmove(&usedElements[i + 1], &usedElements[i], + line->numElements - i - 1); + usedElements[i] = 1; + + /* if we updated a root= here even though there is a + LT_ROOT available we need to remove the LT_ROOT entry + (this will happen if we switch from a device to a label) */ + if (useRoot && !strncmp(*arg, "root=", 5)) { + rootLine = getLineByType(LT_ROOT, entry->lines); + if (rootLine) + removeLine(entry, rootLine); + } + } + } + + free(usedElements); + + for (arg = oldArgs; *arg; arg++) { + for (i = firstElement; i < line->numElements; i++) { + if (multibootArgs && cfg->cfi->mbConcatArgs && + !strcmp(line->elements[i].item, "--")) + /* reached the end of hyper args, stop here */ + break; + if (!argMatch(line->elements[i].item, *arg)) { + removeElement(line, i); + break; + } + } + /* handle removing LT_ROOT line too */ + if (useRoot && !strncmp(*arg, "root=", 5)) { + rootLine = getLineByType(LT_ROOT, entry->lines); + if (rootLine) + removeLine(entry, rootLine); + } + } + + if (line->numElements == 1) { + /* don't need the line at all (note it has to be a + LT_KERNELARGS for this to happen */ + removeLine(entry, line); + } + } + + free(newArgs); + free(oldArgs); + + return 0; +} + +int updateImage(struct grubConfig * cfg, const char * image, + const char * prefix, const char * addArgs, + const char * removeArgs, + const char * addMBArgs, const char * removeMBArgs) { + int rc = 0; + + if (!image) return rc; + + /* update the main args first... */ + if (addArgs || removeArgs) + rc = updateActualImage(cfg, image, prefix, addArgs, removeArgs, 0); + if (rc) return rc; + + /* and now any multiboot args */ + if (addMBArgs || removeMBArgs) + rc = updateActualImage(cfg, image, prefix, addMBArgs, removeMBArgs, 1); + return rc; +} + +int addMBInitrd(struct grubConfig * cfg, const char *newMBKernel, + const char * image, const char * prefix, const char * initrd, + const char * title) { + struct singleEntry * entry; + struct singleLine * line, * kernelLine, *endLine = NULL; + int index = 0; + + if (!image) return 0; + + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { + kernelLine = getLineByType(LT_MBMODULE, entry->lines); + if (!kernelLine) continue; + + /* if title is supplied, the entry's title must match it. */ + if (title) { + char *linetitle; + + line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines); + if (!line) + continue; + + linetitle = extractTitle(cfg, line); + if (!linetitle) + continue; + if (strcmp(title, linetitle)) { + free(linetitle); + continue; + } + free(linetitle); + } + + if (prefix) { + int prefixLen = strlen(prefix); + if (!strncmp(initrd, prefix, prefixLen)) + initrd += prefixLen; + } + endLine = getLineByType(LT_ENTRY_END, entry->lines); + if (endLine) + removeLine(entry, endLine); + line = addLine(entry, cfg->cfi, preferredLineType(LT_MBMODULE,cfg->cfi), + kernelLine->indent, initrd); + if (!line) + return 1; + if (endLine) { + line = addLine(entry, cfg->cfi, LT_ENTRY_END, "", NULL); + if (!line) + return 1; + } + + break; + } + + return 0; +} + +int updateInitrd(struct grubConfig * cfg, const char * image, + const char * prefix, const char * initrd, const char * title) { + struct singleEntry * entry; + struct singleLine * line, * kernelLine, *endLine = NULL; + int index = 0; + + if (!image) return 0; + + for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) { + kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!kernelLine) continue; + + /* if title is supplied, the entry's title must match it. */ + if (title) { + char *linetitle; + + line = getLineByType(LT_TITLE|LT_MENUENTRY, entry->lines); + if (!line) + continue; + + linetitle = extractTitle(cfg, line); + if (!linetitle) + continue; + if (strcmp(title, linetitle)) { + free(linetitle); + continue; + } + free(linetitle); + } + + line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines); + if (line) + removeLine(entry, line); + if (prefix) { + int prefixLen = strlen(prefix); + if (!strncmp(initrd, prefix, prefixLen)) + initrd += prefixLen; + } + endLine = getLineByType(LT_ENTRY_END, entry->lines); + if (endLine) + removeLine(entry, endLine); + enum lineType_e lt; + switch(kernelLine->type) { + case LT_KERNEL: + lt = LT_INITRD; + break; + case LT_KERNEL_EFI: + lt = LT_INITRD_EFI; + break; + case LT_KERNEL_16: + lt = LT_INITRD_16; + break; + default: + lt = preferredLineType(LT_INITRD, cfg->cfi); + } + line = addLine(entry, cfg->cfi, lt, kernelLine->indent, initrd); + if (!line) + return 1; + if (endLine) { + line = addLine(entry, cfg->cfi, LT_ENTRY_END, "", NULL); + if (!line) + return 1; + } + + break; + } + + return 0; +} + +int checkDeviceBootloader(const char * device, const unsigned char * boot) { + int fd; + unsigned char bootSect[512]; + int offset; + + fd = open(device, O_RDONLY); + if (fd < 0) { + fprintf(stderr, _("grubby: unable to open %s: %s\n"), + device, strerror(errno)); + return 1; + } + + if (read(fd, bootSect, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + device, strerror(errno)); + return 1; + } + close(fd); + + /* first three bytes should match, a jmp short should be in there */ + if (memcmp(boot, bootSect, 3)) + return 0; + + if (boot[1] == JMP_SHORT_OPCODE) { + offset = boot[2] + 2; + } else if (boot[1] == 0xe8 || boot[1] == 0xe9) { + offset = (boot[3] << 8) + boot[2] + 2; + } else if (boot[0] == JMP_SHORT_OPCODE) { + offset = boot[1] + 2; + /* + * it looks like grub, when copying stage1 into the mbr, patches stage1 + * right after the JMP location, replacing other instructions such as + * JMPs for NOOPs. So, relax the check a little bit by skipping those + * different bytes. + */ + if ((bootSect[offset + 1] == NOOP_OPCODE) + && (bootSect[offset + 2] == NOOP_OPCODE)) { + offset = offset + 3; + } + } else if (boot[0] == 0xe8 || boot[0] == 0xe9) { + offset = (boot[2] << 8) + boot[1] + 2; + } else { + return 0; + } + + if (memcmp(boot + offset, bootSect + offset, CODE_SEG_SIZE)) + return 0; + + return 2; +} + +int checkLiloOnRaid(char * mdDev, const unsigned char * boot) { + int fd; + char buf[65536]; + char * end; + char * chptr; + char * chptr2; + int rc; + + /* it's on raid; we need to parse /proc/mdstat and check all of the + *raw* devices listed in there */ + + if (!strncmp(mdDev, "/dev/", 5)) + mdDev += 5; + + if ((fd = open("/proc/mdstat", O_RDONLY)) < 0) { + fprintf(stderr, _("grubby: failed to open /proc/mdstat: %s\n"), + strerror(errno)); + return 2; + } + + rc = read(fd, buf, sizeof(buf) - 1); + if (rc < 0 || rc == (sizeof(buf) - 1)) { + fprintf(stderr, _("grubby: failed to read /proc/mdstat: %s\n"), + strerror(errno)); + close(fd); + return 2; + } + close(fd); + buf[rc] = '\0'; + + chptr = buf; + while (*chptr) { + end = strchr(chptr, '\n'); + if (!end) break; + *end = '\0'; + + if (!strncmp(chptr, mdDev, strlen(mdDev)) && + chptr[strlen(mdDev)] == ' ') { + + /* found the device */ + while (*chptr && *chptr != ':') chptr++; + chptr++; + while (*chptr && isspace(*chptr)) chptr++; + + /* skip the "active" bit */ + while (*chptr && !isspace(*chptr)) chptr++; + while (*chptr && isspace(*chptr)) chptr++; + + /* skip the raid level */ + while (*chptr && !isspace(*chptr)) chptr++; + while (*chptr && isspace(*chptr)) chptr++; + + /* everything else is partition stuff */ + while (*chptr) { + chptr2 = chptr; + while (*chptr2 && *chptr2 != '[') chptr2++; + if (!*chptr2) break; + + /* yank off the numbers at the end */ + chptr2--; + while (isdigit(*chptr2) && chptr2 > chptr) chptr2--; + chptr2++; + *chptr2 = '\0'; + + /* Better, now we need the /dev/ back. We're done with + * everything before this point, so we can just put + * the /dev/ part there. There will always be room. */ + memcpy(chptr - 5, "/dev/", 5); + rc = checkDeviceBootloader(chptr - 5, boot); + if (rc != 2) { + return rc; + } + + chptr = chptr2 + 1; + /* skip the [11] bit */ + while (*chptr && !isspace(*chptr)) chptr++; + /* and move to the next one */ + while (*chptr && isspace(*chptr)) chptr++; + } + + /* we're good to go */ + return 2; + } + + chptr = end + 1; + } + + fprintf(stderr, + _("grubby: raid device /dev/%s not found in /proc/mdstat\n"), + mdDev); + return 0; +} + +int checkForLilo(struct grubConfig * config) { + int fd; + unsigned char boot[512]; + struct singleLine * line; + + for (line = config->theLines; line; line = line->next) + if (line->type == LT_BOOT) break; + + if (!line) { + fprintf(stderr, + _("grubby: no boot line found in lilo configuration\n")); + return 1; + } + + if (line->numElements != 2) return 1; + + fd = open("/boot/boot.b", O_RDONLY); + if (fd < 0) { + fprintf(stderr, _("grubby: unable to open %s: %s\n"), + "/boot/boot.b", strerror(errno)); + return 1; + } + + if (read(fd, boot, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + "/boot/boot.b", strerror(errno)); + return 1; + } + close(fd); + + if (!strncmp("/dev/md", line->elements[1].item, 7)) + return checkLiloOnRaid(line->elements[1].item, boot); + + return checkDeviceBootloader(line->elements[1].item, boot); +} + +int checkForGrub2(struct grubConfig * config) { + if (!access("/etc/grub.d/", R_OK)) + return 2; + + return 1; +} + +int checkForGrub(struct grubConfig * config) { + int fd; + unsigned char bootSect[512]; + char * boot; + int onSuse = isSuseSystem(); + + + if (onSuse) { + if (parseSuseGrubConf(NULL, &boot)) + return 0; + } else { + if (parseSysconfigGrub(NULL, &boot)) + return 0; + } + + /* assume grub is not installed -- not an error condition */ + if (!boot) + return 0; + + fd = open("/boot/grub/stage1", O_RDONLY); + if (fd < 0) + /* this doesn't exist if grub hasn't been installed */ + return 0; + + if (read(fd, bootSect, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + "/boot/grub/stage1", strerror(errno)); + close(fd); + return 1; + } + close(fd); + + /* The more elaborate checks do not work on SuSE. The checks done + * seem to be reasonble (at least for now), so just return success + */ + if (onSuse) + return 2; + + return checkDeviceBootloader(boot, bootSect); +} + +int checkForExtLinux(struct grubConfig * config) { + int fd; + unsigned char bootSect[512]; + char * boot; + char executable[] = "/boot/extlinux/extlinux"; + + printf("entered: checkForExtLinux()\n"); + + if (parseSysconfigGrub(NULL, &boot)) + return 0; + + /* assume grub is not installed -- not an error condition */ + if (!boot) + return 0; + + fd = open(executable, O_RDONLY); + if (fd < 0) + /* this doesn't exist if grub hasn't been installed */ + return 0; + + if (read(fd, bootSect, 512) != 512) { + fprintf(stderr, _("grubby: unable to read %s: %s\n"), + executable, strerror(errno)); + return 1; + } + close(fd); + + return checkDeviceBootloader(boot, bootSect); +} + +int checkForYaboot(struct grubConfig * config) { + /* + * This is a simplistic check that we consider good enough for own puporses + * + * If we were to properly check if yaboot is *installed* we'd need to: + * 1) get the system boot device (LT_BOOT) + * 2) considering it's a raw filesystem, check if the yaboot binary matches + * the content on the boot device + * 3) if not, copy the binary to a temporary file and run "addnote" on it + * 4) check again if binary and boot device contents match + */ + if (!access("/etc/yaboot.conf", R_OK)) + return 2; + + return 1; +} + +int checkForElilo(struct grubConfig * config) { + if (!access("/etc/elilo.conf", R_OK)) + return 2; + + return 1; +} + +static char * getRootSpecifier(char * str) { + char * idx, * rootspec = NULL; + + if (*str == '(') { + idx = rootspec = strdup(str); + while(*idx && (*idx != ')') && (!isspace(*idx))) idx++; + *(++idx) = '\0'; + } + return rootspec; +} + +static char * getInitrdVal(struct grubConfig * config, + const char * prefix, struct singleLine *tmplLine, + const char * newKernelInitrd, + const char ** extraInitrds, int extraInitrdCount) +{ + char *initrdVal, *end; + int i; + size_t totalSize; + size_t prefixLen; + char separatorChar; + + prefixLen = strlen(prefix); + totalSize = strlen(newKernelInitrd) - prefixLen + 1 /* \0 */; + + for (i = 0; i < extraInitrdCount; i++) { + totalSize += sizeof(separatorChar); + totalSize += strlen(extraInitrds[i]) - prefixLen; + } + + initrdVal = end = malloc(totalSize); + + end = stpcpy (end, newKernelInitrd + prefixLen); + + separatorChar = getKeywordByType(LT_INITRD, config->cfi)->separatorChar; + for (i = 0; i < extraInitrdCount; i++) { + const char *extraInitrd; + int j; + + extraInitrd = extraInitrds[i] + prefixLen; + /* Don't add entries that are already there */ + if (tmplLine != NULL) { + for (j = 2; j < tmplLine->numElements; j++) + if (strcmp(extraInitrd, tmplLine->elements[j].item) == 0) + break; + + if (j != tmplLine->numElements) + continue; + } + + *end++ = separatorChar; + end = stpcpy(end, extraInitrd); + } + + return initrdVal; +} + +int addNewKernel(struct grubConfig * config, struct singleEntry * template, + const char * prefix, + const char * newKernelPath, const char * newKernelTitle, + const char * newKernelArgs, const char * newKernelInitrd, + const char ** extraInitrds, int extraInitrdCount, + const char * newMBKernel, const char * newMBKernelArgs, + const char * newDevTreePath) { + struct singleEntry * new; + struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL; + int needs; + char * chptr; + + if (!newKernelPath) return 0; + + /* if the newKernelTitle is too long silently munge it into something + * we can live with. truncating is first check, then we'll just mess with + * it until it looks better */ + if (config->cfi->maxTitleLength && + (strlen(newKernelTitle) > config->cfi->maxTitleLength)) { + char * buf = alloca(config->cfi->maxTitleLength + 7); + char * numBuf = alloca(config->cfi->maxTitleLength + 1); + int i = 1; + + sprintf(buf, "TITLE=%.*s", config->cfi->maxTitleLength, newKernelTitle); + while (findEntryByPath(config, buf, NULL, NULL)) { + sprintf(numBuf, "%d", i++); + strcpy(buf + strlen(buf) - strlen(numBuf), numBuf); + } + + newKernelTitle = buf + 6; + } + + new = malloc(sizeof(*new)); + new->skip = 0; + new->multiboot = 0; + new->next = config->entries; + new->lines = NULL; + config->entries = new; + + /* copy/update from the template */ + needs = NEED_KERNEL | NEED_TITLE; + if (newKernelInitrd) + needs |= NEED_INITRD; + if (newMBKernel) { + needs |= NEED_MB; + new->multiboot = 1; + } + if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi)) + needs |= NEED_DEVTREE; + + if (template) { + for (masterLine = template->lines; + masterLine && (tmplLine = lineDup(masterLine)); + lineFree(tmplLine), masterLine = masterLine->next) + { + dbgPrintf("addNewKernel processing %d\n", tmplLine->type); + + /* skip comments */ + chptr = tmplLine->indent; + while (*chptr && isspace(*chptr)) chptr++; + if (*chptr == '#') continue; + + if (iskernel(tmplLine->type) && tmplLine->numElements >= 2) { + if (!template->multiboot && (needs & NEED_MB)) { + /* it's not a multiboot template and this is the kernel + * line. Try to be intelligent about inserting the + * hypervisor at the same time. + */ + if (config->cfi->mbHyperFirst) { + /* insert the hypervisor first */ + newLine = addLine(new, config->cfi, LT_HYPER, + tmplLine->indent, + newMBKernel + strlen(prefix)); + /* set up for adding the kernel line */ + free(tmplLine->indent); + tmplLine->indent = strdup(config->secondaryIndent); + needs &= ~NEED_MB; + } + if (needs & NEED_KERNEL) { + /* use addLineTmpl to preserve line elements, + * otherwise we could just call addLine. Unfortunately + * this means making some changes to the template + * such as the indent change above and the type + * change below. + */ + struct keywordTypes * mbm_kw = + getKeywordByType(LT_MBMODULE, config->cfi); + if (mbm_kw) { + tmplLine->type = LT_MBMODULE; + free(tmplLine->elements[0].item); + tmplLine->elements[0].item = strdup(mbm_kw->key); + } + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + strlen(prefix), config->cfi); + needs &= ~NEED_KERNEL; + } + if (needs & NEED_MB) { /* !mbHyperFirst */ + newLine = addLine(new, config->cfi, LT_HYPER, + config->secondaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + } + } else if (needs & NEED_KERNEL) { + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + strlen(prefix), config->cfi); + needs &= ~NEED_KERNEL; + } + + } else if (tmplLine->type == LT_HYPER && + tmplLine->numElements >= 2) { + if (needs & NEED_MB) { + newLine = addLineTmpl(new, tmplLine, newLine, + newMBKernel + strlen(prefix), config->cfi); + needs &= ~NEED_MB; + } + + } else if (tmplLine->type == LT_MBMODULE && + tmplLine->numElements >= 2) { + if (new->multiboot) { + if (needs & NEED_KERNEL) { + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + + strlen(prefix), config->cfi); + needs &= ~NEED_KERNEL; + } else if (config->cfi->mbInitRdIsModule && + (needs & NEED_INITRD)) { + char *initrdVal; + initrdVal = getInitrdVal(config, prefix, tmplLine, + newKernelInitrd, extraInitrds, + extraInitrdCount); + newLine = addLineTmpl(new, tmplLine, newLine, + initrdVal, config->cfi); + free(initrdVal); + needs &= ~NEED_INITRD; + } + } else if (needs & NEED_KERNEL) { + /* template is multi but new is not, + * insert the kernel in the first module slot + */ + tmplLine->type = preferredLineType(LT_KERNEL, config->cfi); + free(tmplLine->elements[0].item); + tmplLine->elements[0].item = + strdup(getKeywordByType(tmplLine->type, + config->cfi)->key); + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelPath + strlen(prefix), + config->cfi); + needs &= ~NEED_KERNEL; + } else if (needs & NEED_INITRD) { + char *initrdVal; + /* template is multi but new is not, + * insert the initrd in the second module slot + */ + tmplLine->type = preferredLineType(LT_INITRD, config->cfi); + free(tmplLine->elements[0].item); + tmplLine->elements[0].item = + strdup(getKeywordByType(tmplLine->type, + config->cfi)->key); + initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); + free(initrdVal); + needs &= ~NEED_INITRD; + } + + } else if (isinitrd(tmplLine->type) && tmplLine->numElements >= 2) { + if (needs & NEED_INITRD && + new->multiboot && !template->multiboot && + config->cfi->mbInitRdIsModule) { + /* make sure we don't insert the module initrd + * before the module kernel... if we don't do it here, + * it will be inserted following the template. + */ + if (!needs & NEED_KERNEL) { + char *initrdVal; + + initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLine(new, config->cfi, LT_MBMODULE, + config->secondaryIndent, + initrdVal); + free(initrdVal); + needs &= ~NEED_INITRD; + } + } else if (needs & NEED_INITRD) { + char *initrdVal; + initrdVal = getInitrdVal(config, prefix, tmplLine, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLineTmpl(new, tmplLine, newLine, initrdVal, config->cfi); + free(initrdVal); + needs &= ~NEED_INITRD; + } + + } else if (tmplLine->type == LT_MENUENTRY && + (needs & NEED_TITLE)) { + requote(tmplLine, config->cfi); + char *nkt = malloc(strlen(newKernelTitle)+3); + strcpy(nkt, "'"); + strcat(nkt, newKernelTitle); + strcat(nkt, "'"); + newLine = addLineTmpl(new, tmplLine, newLine, nkt, config->cfi); + free(nkt); + needs &= ~NEED_TITLE; + } else if (tmplLine->type == LT_TITLE && + (needs & NEED_TITLE)) { + if (tmplLine->numElements >= 2) { + newLine = addLineTmpl(new, tmplLine, newLine, + newKernelTitle, config->cfi); + needs &= ~NEED_TITLE; + } else if (tmplLine->numElements == 1 && + config->cfi->titleBracketed) { + /* addLineTmpl doesn't handle titleBracketed */ + newLine = addLine(new, config->cfi, LT_TITLE, + tmplLine->indent, newKernelTitle); + needs &= ~NEED_TITLE; + } + } else if (tmplLine->type == LT_ECHO) { + requote(tmplLine, config->cfi); + static const char *prefix = "'Loading "; + if (tmplLine->numElements > 1 && + strstr(tmplLine->elements[1].item, prefix) && + masterLine->next && + iskernel(masterLine->next->type)) { + char *newTitle = malloc(strlen(prefix) + + strlen(newKernelTitle) + 2); + + strcpy(newTitle, prefix); + strcat(newTitle, newKernelTitle); + strcat(newTitle, "'"); + newLine = addLine(new, config->cfi, LT_ECHO, + tmplLine->indent, newTitle); + free(newTitle); + } else { + /* pass through other lines from the template */ + newLine = addLineTmpl(new, tmplLine, newLine, NULL, + config->cfi); + } + } else if (tmplLine->type == LT_DEVTREE && + tmplLine->numElements == 2 && newDevTreePath) { + newLine = addLineTmpl(new, tmplLine, newLine, + newDevTreePath + strlen(prefix), + config->cfi); + needs &= ~NEED_DEVTREE; + } else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) { + const char *ndtp = newDevTreePath; + if (!strncmp(newDevTreePath, prefix, strlen(prefix))) + ndtp += strlen(prefix); + newLine = addLine(new, config->cfi, LT_DEVTREE, + config->secondaryIndent, + ndtp); + needs &= ~NEED_DEVTREE; + newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); + } else { + /* pass through other lines from the template */ + newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi); + } + } + + } else { + /* don't have a template, so start the entry with the + * appropriate starting line + */ + switch (config->cfi->entryStart) { + case LT_KERNEL: + case LT_KERNEL_EFI: + case LT_KERNEL_16: + if (new->multiboot && config->cfi->mbHyperFirst) { + /* fall through to LT_HYPER */ + } else { + newLine = addLine(new, config->cfi, + preferredLineType(LT_KERNEL, config->cfi), + config->primaryIndent, + newKernelPath + strlen(prefix)); + needs &= ~NEED_KERNEL; + break; + } + + case LT_HYPER: + newLine = addLine(new, config->cfi, LT_HYPER, + config->primaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + break; + + case LT_MENUENTRY: { + char *nkt = malloc(strlen(newKernelTitle)+3); + strcpy(nkt, "'"); + strcat(nkt, newKernelTitle); + strcat(nkt, "'"); + newLine = addLine(new, config->cfi, LT_MENUENTRY, + config->primaryIndent, nkt); + free(nkt); + needs &= ~NEED_TITLE; + needs |= NEED_END; + break; + } + case LT_TITLE: + if( useextlinuxmenu != 0 ){ // We just need useextlinuxmenu to not be zero (set above) + char * templabel; + int x = 0, y = 0; + + templabel = strdup(newKernelTitle); + while( templabel[x]){ + if( templabel[x] == ' ' ){ + y = x; + while( templabel[y] ){ + templabel[y] = templabel[y+1]; + y++; + } + } + x++; + } + newLine = addLine(new, config->cfi, LT_TITLE, + config->primaryIndent, templabel); + free(templabel); + }else{ + newLine = addLine(new, config->cfi, LT_TITLE, + config->primaryIndent, newKernelTitle); + } + needs &= ~NEED_TITLE; + break; + + default: + abort(); + } + } + + struct singleLine *endLine = NULL; + endLine = getLineByType(LT_ENTRY_END, new->lines); + if (endLine) { + removeLine(new, endLine); + needs |= NEED_END; + } + + /* add the remainder of the lines, i.e. those that either + * weren't present in the template, or in the case of no template, + * all the lines following the entryStart. + */ + if (needs & NEED_TITLE) { + newLine = addLine(new, config->cfi, LT_TITLE, + config->secondaryIndent, + newKernelTitle); + needs &= ~NEED_TITLE; + } + if ((needs & NEED_MB) && config->cfi->mbHyperFirst) { + newLine = addLine(new, config->cfi, LT_HYPER, + config->secondaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + } + if (needs & NEED_KERNEL) { + newLine = addLine(new, config->cfi, + (new->multiboot && getKeywordByType(LT_MBMODULE, + config->cfi)) + ? LT_MBMODULE + : preferredLineType(LT_KERNEL, config->cfi), + config->secondaryIndent, + newKernelPath + strlen(prefix)); + needs &= ~NEED_KERNEL; + } + if (needs & NEED_MB) { + newLine = addLine(new, config->cfi, LT_HYPER, + config->secondaryIndent, + newMBKernel + strlen(prefix)); + needs &= ~NEED_MB; + } + if (needs & NEED_INITRD) { + char *initrdVal; + initrdVal = getInitrdVal(config, prefix, NULL, newKernelInitrd, extraInitrds, extraInitrdCount); + newLine = addLine(new, config->cfi, + (new->multiboot && getKeywordByType(LT_MBMODULE, + config->cfi)) + ? LT_MBMODULE + : preferredLineType(LT_INITRD, config->cfi), + config->secondaryIndent, + initrdVal); + free(initrdVal); + needs &= ~NEED_INITRD; + } + if (needs & NEED_DEVTREE) { + newLine = addLine(new, config->cfi, LT_DEVTREE, + config->secondaryIndent, + newDevTreePath); + needs &= ~NEED_DEVTREE; + } + + /* NEEDS_END must be last on bootloaders that need it... */ + if (needs & NEED_END) { + newLine = addLine(new, config->cfi, LT_ENTRY_END, + config->secondaryIndent, NULL); + needs &= ~NEED_END; + } + + if (needs) { + printf(_("grubby: needs=%d, aborting\n"), needs); + abort(); + } + + if (updateImage(config, "0", prefix, newKernelArgs, NULL, + newMBKernelArgs, NULL)) return 1; + + return 0; +} + +static void traceback(int signum) +{ + void *array[40]; + size_t size; + + signal(SIGSEGV, SIG_DFL); + memset(array, '\0', sizeof (array)); + size = backtrace(array, 40); + + fprintf(stderr, "grubby received SIGSEGV! Backtrace (%ld):\n", + (unsigned long)size); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + +int main(int argc, const char ** argv) { + poptContext optCon; + const char * grubConfig = NULL; + char * outputFile = NULL; + int arg = 0; + int flags = 0; + int badImageOkay = 0; + int configureGrub2 = 0; + int configureLilo = 0, configureELilo = 0, configureGrub = 0; + int configureYaboot = 0, configureSilo = 0, configureZipl = 0; + int configureExtLinux = 0; + int bootloaderProbe = 0; + int extraInitrdCount = 0; + char * updateKernelPath = NULL; + char * newKernelPath = NULL; + char * removeKernelPath = NULL; + char * newKernelArgs = NULL; + char * newKernelInitrd = NULL; + char * newKernelTitle = NULL; + char * newDevTreePath = NULL; + char * newMBKernel = NULL; + char * newMBKernelArgs = NULL; + char * removeMBKernelArgs = NULL; + char * removeMBKernel = NULL; + char * bootPrefix = NULL; + char * defaultKernel = NULL; + char * removeArgs = NULL; + char * kernelInfo = NULL; + char * extraInitrds[MAX_EXTRA_INITRDS] = { NULL }; + char * envPath = NULL; + const char * chptr = NULL; + struct configFileInfo * cfi = NULL; + struct grubConfig * config; + struct singleEntry * template = NULL; + int copyDefault = 0, makeDefault = 0; + int displayDefault = 0; + int displayDefaultIndex = 0; + int displayDefaultTitle = 0; + int defaultIndex = -1; + struct poptOption options[] = { + { "add-kernel", 0, POPT_ARG_STRING, &newKernelPath, 0, + _("add an entry for the specified kernel"), _("kernel-path") }, + { "add-multiboot", 0, POPT_ARG_STRING, &newMBKernel, 0, + _("add an entry for the specified multiboot kernel"), NULL }, + { "args", 0, POPT_ARG_STRING, &newKernelArgs, 0, + _("default arguments for the new kernel or new arguments for " + "kernel being updated"), _("args") }, + { "mbargs", 0, POPT_ARG_STRING, &newMBKernelArgs, 0, + _("default arguments for the new multiboot kernel or " + "new arguments for multiboot kernel being updated"), NULL }, + { "bad-image-okay", 0, 0, &badImageOkay, 0, + _("don't sanity check images in boot entries (for testing only)"), + NULL }, + { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0, + _("filestystem which contains /boot directory (for testing only)"), + _("bootfs") }, +#if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) || defined (__ia64__) + { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0, + _("check which bootloader is installed on boot sector") }, +#endif + { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0, + _("path to grub config file to update (\"-\" for stdin)"), + _("path") }, + { "copy-default", 0, 0, ©Default, 0, + _("use the default boot entry as a template for the new entry " + "being added; if the default is not a linux image, or if " + "the kernel referenced by the default image does not exist, " + "the first linux entry whose kernel does exist is used as the " + "template"), NULL }, + { "debug", 0, 0, &debug, 0, + _("print debugging information for failures") }, + { "default-kernel", 0, 0, &displayDefault, 0, + _("display the path of the default kernel") }, + { "default-index", 0, 0, &displayDefaultIndex, 0, + _("display the index of the default kernel") }, + { "default-title", 0, 0, &displayDefaultTitle, 0, + _("display the title of the default kernel") }, + { "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0, + _("device tree file for new stanza"), _("dtb-path") }, + { "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0, + _("device tree directory for new stanza"), _("dtb-path") }, + { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0, + _("configure elilo bootloader") }, + { "efi", 0, POPT_ARG_NONE, &isEfi, 0, + _("force grub2 stanzas to use efi") }, + { "env", 0, POPT_ARG_STRING, &envPath, 0, + _("path for environment data"), + _("path") }, + { "extlinux", 0, POPT_ARG_NONE, &configureExtLinux, 0, + _("configure extlinux bootloader (from syslinux)") }, + { "grub", 0, POPT_ARG_NONE, &configureGrub, 0, + _("configure grub bootloader") }, + { "grub2", 0, POPT_ARG_NONE, &configureGrub2, 0, + _("configure grub2 bootloader") }, + { "info", 0, POPT_ARG_STRING, &kernelInfo, 0, + _("display boot information for specified kernel"), + _("kernel-path") }, + { "initrd", 0, POPT_ARG_STRING, &newKernelInitrd, 0, + _("initrd image for the new kernel"), _("initrd-path") }, + { "extra-initrd", 'i', POPT_ARG_STRING, NULL, 'i', + _("auxiliary initrd image for things other than the new kernel"), _("initrd-path") }, + { "lilo", 0, POPT_ARG_NONE, &configureLilo, 0, + _("configure lilo bootloader") }, + { "make-default", 0, 0, &makeDefault, 0, + _("make the newly added entry the default boot entry"), NULL }, + { "output-file", 'o', POPT_ARG_STRING, &outputFile, 0, + _("path to output updated config file (\"-\" for stdout)"), + _("path") }, + { "remove-args", 0, POPT_ARG_STRING, &removeArgs, 0, + _("remove kernel arguments"), NULL }, + { "remove-mbargs", 0, POPT_ARG_STRING, &removeMBKernelArgs, 0, + _("remove multiboot kernel arguments"), NULL }, + { "remove-kernel", 0, POPT_ARG_STRING, &removeKernelPath, 0, + _("remove all entries for the specified kernel"), + _("kernel-path") }, + { "remove-multiboot", 0, POPT_ARG_STRING, &removeMBKernel, 0, + _("remove all entries for the specified multiboot kernel"), NULL }, + { "set-default", 0, POPT_ARG_STRING, &defaultKernel, 0, + _("make the first entry referencing the specified kernel " + "the default"), _("kernel-path") }, + { "set-default-index", 0, POPT_ARG_INT, &defaultIndex, 0, + _("make the given entry index the default entry"), + _("entry-index") }, + { "silo", 0, POPT_ARG_NONE, &configureSilo, 0, + _("configure silo bootloader") }, + { "title", 0, POPT_ARG_STRING, &newKernelTitle, 0, + _("title to use for the new kernel entry"), _("entry-title") }, + { "update-kernel", 0, POPT_ARG_STRING, &updateKernelPath, 0, + _("updated information for the specified kernel"), + _("kernel-path") }, + { "version", 'v', 0, NULL, 'v', + _("print the version of this program and exit"), NULL }, + { "yaboot", 0, POPT_ARG_NONE, &configureYaboot, 0, + _("configure yaboot bootloader") }, + { "zipl", 0, POPT_ARG_NONE, &configureZipl, 0, + _("configure zipl bootloader") }, + POPT_AUTOHELP + { 0, 0, 0, 0, 0 } + }; + + useextlinuxmenu=0; + + signal(SIGSEGV, traceback); + + int i = 0; + for (int j = 1; j < argc; j++) + i += strlen(argv[j]) + 1; + + if (i > 0) { + saved_command_line = malloc(i); + if (!saved_command_line) { + fprintf(stderr, "grubby: %m\n"); + exit(1); + } + saved_command_line[0] = '\0'; + int cmdline_len = 0, arg_len; + for (int j = 1; j < argc; j++) { + arg_len = strlen(argv[j]); + memcpy(saved_command_line + cmdline_len, argv[j], arg_len); + cmdline_len += arg_len; + if (j != argc - 1) { + memcpy(saved_command_line + cmdline_len, " ", 1); + cmdline_len++; + } + } + saved_command_line[cmdline_len] = '\0'; + } + + optCon = poptGetContext("grubby", argc, argv, options, 0); + poptReadDefaultConfig(optCon, 1); + + while ((arg = poptGetNextOpt(optCon)) >= 0) { + switch (arg) { + case 'v': + printf("grubby version %s\n", VERSION); + exit(0); + break; + case 'i': + if (extraInitrdCount < MAX_EXTRA_INITRDS) { + extraInitrds[extraInitrdCount++] = strdup(poptGetOptArg(optCon)); + } else { + fprintf(stderr, _("grubby: extra initrd maximum is %d\n"), extraInitrdCount); + return 1; + } + break; + } + } + + if (arg < -1) { + fprintf(stderr, _("grubby: bad argument %s: %s\n"), + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(arg)); + return 1; + } + + if ((chptr = poptGetArg(optCon))) { + fprintf(stderr, _("grubby: unexpected argument %s\n"), chptr); + return 1; + } + + if ((configureLilo + configureGrub2 + configureGrub + configureELilo + + configureYaboot + configureSilo + configureZipl + + configureExtLinux ) > 1) { + fprintf(stderr, _("grubby: cannot specify multiple bootloaders\n")); + return 1; + } else if (bootloaderProbe && grubConfig) { + fprintf(stderr, + _("grubby: cannot specify config file with --bootloader-probe\n")); + return 1; + } else if (configureGrub2) { + cfi = &grub2ConfigType; + if (envPath) + cfi->envFile = envPath; + } else if (configureLilo) { + cfi = &liloConfigType; + } else if (configureGrub) { + cfi = &grubConfigType; + } else if (configureELilo) { + cfi = &eliloConfigType; + } else if (configureYaboot) { + cfi = &yabootConfigType; + } else if (configureSilo) { + cfi = &siloConfigType; + } else if (configureZipl) { + cfi = &ziplConfigType; + } else if (configureExtLinux) { + cfi = &extlinuxConfigType; + useextlinuxmenu=1; + } + + if (!cfi) { + if (grub2FindConfig(&grub2ConfigType)) + cfi = &grub2ConfigType; + else + #ifdef __ia64__ + cfi = &eliloConfigType; + #elif __powerpc__ + cfi = &yabootConfigType; + #elif __sparc__ + cfi = &siloConfigType; + #elif __s390__ + cfi = &ziplConfigType; + #elif __s390x__ + cfi = &ziplConfigtype; + #else + cfi = &grubConfigType; + #endif + } + + if (!grubConfig) { + if (cfi->findConfig) + grubConfig = cfi->findConfig(cfi); + if (!grubConfig) + grubConfig = cfi->defaultConfig; + } + + if (bootloaderProbe && (displayDefault || kernelInfo || + newKernelPath || removeKernelPath || makeDefault || + defaultKernel || displayDefaultIndex || displayDefaultTitle || + (defaultIndex >= 0))) { + fprintf(stderr, _("grubby: --bootloader-probe may not be used with " + "specified option")); + return 1; + } + + if ((displayDefault || kernelInfo) && (newKernelPath || + removeKernelPath)) { + fprintf(stderr, _("grubby: --default-kernel and --info may not " + "be used when adding or removing kernels\n")); + return 1; + } + + if (newKernelPath && !newKernelTitle) { + fprintf(stderr, _("grubby: kernel title must be specified\n")); + return 1; + } else if (!newKernelPath && (copyDefault || + (newKernelInitrd && !updateKernelPath)|| + makeDefault || extraInitrdCount > 0)) { + fprintf(stderr, _("grubby: kernel path expected\n")); + return 1; + } + + if (newKernelPath && updateKernelPath) { + fprintf(stderr, _("grubby: --add-kernel and --update-kernel may" + "not be used together")); + return 1; + } + + if (makeDefault && defaultKernel) { + fprintf(stderr, _("grubby: --make-default and --default-kernel " + "may not be used together\n")); + return 1; + } else if (defaultKernel && removeKernelPath && + !strcmp(defaultKernel, removeKernelPath)) { + fprintf(stderr, _("grubby: cannot make removed kernel the default\n")); + return 1; + } else if (defaultKernel && newKernelPath && + !strcmp(defaultKernel, newKernelPath)) { + makeDefault = 1; + defaultKernel = NULL; + } + else if (defaultKernel && (defaultIndex >= 0)) { + fprintf(stderr, _("grubby: --set-default and --set-default-index " + "may not be used together\n")); + return 1; + } + + if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) { + fprintf(stderr, _("grubby: output file must be specified if stdin " + "is used\n")); + return 1; + } + + if (!removeKernelPath && !newKernelPath && !displayDefault && !defaultKernel + && !kernelInfo && !bootloaderProbe && !updateKernelPath + && !removeMBKernel && !displayDefaultIndex && !displayDefaultTitle + && (defaultIndex == -1)) { + fprintf(stderr, _("grubby: no action specified\n")); + return 1; + } + + flags |= badImageOkay ? GRUBBY_BADIMAGE_OKAY : 0; + + if (cfi->needsBootPrefix) { + if (!bootPrefix) { + bootPrefix = findBootPrefix(); + if (!bootPrefix) return 1; + } else { + /* this shouldn't end with a / */ + if (bootPrefix[strlen(bootPrefix) - 1] == '/') + bootPrefix[strlen(bootPrefix) - 1] = '\0'; + } + } else { + bootPrefix = ""; + } + + if (!cfi->mbAllowExtraInitRds && + extraInitrdCount > 0) { + fprintf(stderr, _("grubby: %s doesn't allow multiple initrds\n"), cfi->defaultConfig); + return 1; + } + + if (bootloaderProbe) { + int lrc = 0, grc = 0, gr2c = 0, extrc = 0, yrc = 0, erc = 0; + struct grubConfig * lconfig, * gconfig, * yconfig, * econfig; + + const char *grub2config = grub2FindConfig(&grub2ConfigType); + if (grub2config) { + gconfig = readConfig(grub2config, &grub2ConfigType); + if (!gconfig) + gr2c = 1; + else + gr2c = checkForGrub2(gconfig); + } + + const char *grubconfig = grubFindConfig(&grubConfigType); + if (!access(grubconfig, F_OK)) { + gconfig = readConfig(grubconfig, &grubConfigType); + if (!gconfig) + grc = 1; + else + grc = checkForGrub(gconfig); + } + + if (!access(liloConfigType.defaultConfig, F_OK)) { + lconfig = readConfig(liloConfigType.defaultConfig, &liloConfigType); + if (!lconfig) + lrc = 1; + else + lrc = checkForLilo(lconfig); + } + + if (!access(eliloConfigType.defaultConfig, F_OK)) { + econfig = readConfig(eliloConfigType.defaultConfig, + &eliloConfigType); + if (!econfig) + erc = 1; + else + erc = checkForElilo(econfig); + } + + if (!access(extlinuxConfigType.defaultConfig, F_OK)) { + lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType); + if (!lconfig) + extrc = 1; + else + extrc = checkForExtLinux(lconfig); + } + + + if (!access(yabootConfigType.defaultConfig, F_OK)) { + yconfig = readConfig(yabootConfigType.defaultConfig, + &yabootConfigType); + if (!yconfig) + yrc = 1; + else + yrc = checkForYaboot(yconfig); + } + + if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 || + erc == 1) + return 1; + + if (lrc == 2) printf("lilo\n"); + if (gr2c == 2) printf("grub2\n"); + if (grc == 2) printf("grub\n"); + if (extrc == 2) printf("extlinux\n"); + if (yrc == 2) printf("yaboot\n"); + if (erc == 2) printf("elilo\n"); + + return 0; + } + + if (grubConfig == NULL) { + printf("Could not find bootloader configuration file.\n"); + exit(1); + } + + config = readConfig(grubConfig, cfi); + if (!config) return 1; + + if (displayDefault) { + struct singleLine * line; + struct singleEntry * entry; + char * rootspec; + + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && + cfi->defaultIsSaved) + config->defaultImage = 0; + entry = findEntryByIndex(config, config->defaultImage); + if (!entry) return 0; + if (!suitableImage(entry, bootPrefix, 0, flags)) return 0; + + line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines); + if (!line) return 0; + + rootspec = getRootSpecifier(line->elements[1].item); + printf("%s%s\n", bootPrefix, line->elements[1].item + + ((rootspec != NULL) ? strlen(rootspec) : 0)); + + return 0; + + } else if (displayDefaultTitle) { + struct singleLine * line; + struct singleEntry * entry; + + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && + cfi->defaultIsSaved) + config->defaultImage = 0; + entry = findEntryByIndex(config, config->defaultImage); + if (!entry) return 0; + + if (!configureGrub2) { + line = getLineByType(LT_TITLE, entry->lines); + if (!line) return 0; + printf("%s\n", line->elements[1].item); + + } else { + char * title; + + dbgPrintf("This is GRUB2, default title is embeded in menuentry\n"); + line = getLineByType(LT_MENUENTRY, entry->lines); + if (!line) return 0; + title = grub2ExtractTitle(line); + if (title) + printf("%s\n", title); + } + return 0; + + } else if (displayDefaultIndex) { + if (config->defaultImage == -1) return 0; + if (config->defaultImage == DEFAULT_SAVED_GRUB2 && + cfi->defaultIsSaved) + config->defaultImage = 0; + printf("%i\n", config->defaultImage); + return 0; + + } else if (kernelInfo) + return displayInfo(config, kernelInfo, bootPrefix); + + if (copyDefault) { + template = findTemplate(config, bootPrefix, NULL, 0, flags); + if (!template) return 1; + } + + markRemovedImage(config, removeKernelPath, bootPrefix); + markRemovedImage(config, removeMBKernel, bootPrefix); + setDefaultImage(config, newKernelPath != NULL, defaultKernel, makeDefault, + bootPrefix, flags, defaultIndex); + setFallbackImage(config, newKernelPath != NULL); + if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, + removeArgs, newMBKernelArgs, removeMBKernelArgs)) return 1; + if (updateKernelPath && newKernelInitrd) { + if (newMBKernel) { + if (addMBInitrd(config, newMBKernel, updateKernelPath, + bootPrefix, newKernelInitrd, + newKernelTitle)) + return 1; + } else { + if (updateInitrd(config, updateKernelPath, bootPrefix, + newKernelInitrd, newKernelTitle)) + return 1; + } + } + if (addNewKernel(config, template, bootPrefix, newKernelPath, + newKernelTitle, newKernelArgs, newKernelInitrd, + (const char **)extraInitrds, extraInitrdCount, + newMBKernel, newMBKernelArgs, newDevTreePath)) return 1; + + + if (numEntries(config) == 0) { + fprintf(stderr, _("grubby: doing this would leave no kernel entries. " + "Not writing out new config.\n")); + return 1; + } + + if (!outputFile) + outputFile = (char *)grubConfig; + + return writeConfig(config, outputFile, bootPrefix); +} diff --git a/grubby-8.40-1/installkernel b/grubby-8.40-1/installkernel new file mode 100755 index 0000000..b887929 --- /dev/null +++ b/grubby-8.40-1/installkernel @@ -0,0 +1,87 @@ +#! /bin/sh +# +# /sbin/installkernel +# +# Copyright 2007-2008 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author(s): tyson@rwii.com +# + +usage() { + echo "Usage: `basename $0` " >&2 + exit 1 +} + +cfgLoader= + +if [ -z "$INSTALL_PATH" -o "$INSTALL_PATH" == "/boot" ]; then + INSTALL_PATH=/boot + cfgLoader=1 +fi + +LINK_PATH=/boot +RELATIVE_PATH=`echo "$INSTALL_PATH/" | sed "s|^$LINK_PATH/||"` +KERNEL_VERSION=$1 +BOOTIMAGE=$2 +MAPFILE=$3 +ARCH=$(uname -m) +if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then + KERNEL_NAME=vmlinux +else + KERNEL_NAME=vmlinuz +fi + +if [ -z "$KERNEL_VERSION" -o -z "$BOOTIMAGE" -o -z "$MAPFILE" ]; then + usage +fi + +if [ -f $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION ]; then + mv $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION \ + $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION.old; +fi + +if [ ! -L $INSTALL_PATH/$KERNEL_NAME ]; then + if [ -e $INSTALLPATH/$KERNEL_NAME ]; then + mv $INSTALL_PATH/$KERNEL_NAME $INSTALL_PATH/$KERNEL_NAME.old + fi +fi + +if [ -f $INSTALL_PATH/System.map-$KERNEL_VERSION ]; then + mv $INSTALL_PATH/System.map-$KERNEL_VERSION \ + $INSTALL_PATH/System.map-$KERNEL_VERSION.old; +fi + +if [ ! -L $INSTALL_PATH/System.map ]; then + if [ -e $INSTALLPATH/System.map ]; then + mv $INSTALL_PATH/System.map $INSTALL_PATH/System.map.old + fi +fi +ln -sf ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map + +cat $BOOTIMAGE > $INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION +cp $MAPFILE $INSTALL_PATH/System.map-$KERNEL_VERSION + +ln -fs ${RELATIVE_PATH}$INSTALL_PATH/$KERNEL_NAME-$KERNEL_VERSION $LINK_PATH/$KERNEL_NAME +ln -fs ${RELATIVE_PATH}$INSTALL_PATH/System.map-$KERNEL_VERSION $LINK_PATH/System.map + +if [ -n "$cfgLoader" ] && [ -x /sbin/new-kernel-pkg ]; then + if [ -n "$(which dracut 2>/dev/null)" ]; then + new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION + else + new-kernel-pkg --mkinitrd --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION + fi + new-kernel-pkg --rpmposttrans --kernel-name $KERNEL_NAME $KERNEL_VERSION +fi diff --git a/grubby-8.40-1/installkernel.8 b/grubby-8.40-1/installkernel.8 new file mode 100644 index 0000000..e06b802 --- /dev/null +++ b/grubby-8.40-1/installkernel.8 @@ -0,0 +1,27 @@ +.TH INSTALLKERNEL 8 "Wed Apr 14 2010" +.SH NAME +installkernel \- tool to script kernel installation + +.SH SYNOPSIS +\fBinstallkernel\fR \fI \fR + +.SH DESCRIPTION +\fBinstallkernel\fR installs a new kernel image onto the system from +the Linux source tree. It is called by the Linux kernel makefiles when +\fBmake install\fR is invoked there. + +The new kernel is installed into {directory}/vmlinuz-{version}. If a +symbolic link {directory}/vmlinuz already exists, it is refreshed by +making a link from {directory}/vmlinuz to the new kernel, and the +previously installed kernel is available as {directory}/vmlinuz.old. + +.SH "SEE ALSO" +.BR grubby(8) +.BR new-kernel-pkg(8) + +.SH AUTHORS +.nf +Erik Troan +Jeremy Katz +Peter Jones +.fi diff --git a/grubby-8.40-1/log.c b/grubby-8.40-1/log.c new file mode 100644 index 0000000..2bcfa40 --- /dev/null +++ b/grubby-8.40-1/log.c @@ -0,0 +1,118 @@ +/* + * log.c + * + * Copyright 2013 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "log.h" + +static int log_fd = -1; +static FILE *f = NULL; + +static int +open_log(void) +{ + if (log_fd > -1) + return 0; + log_fd = open("/var/log/grubby", O_RDWR|O_APPEND|O_CREAT|O_CLOEXEC, 0600); + if (log_fd < 0) + return log_fd; + + f = fdopen(log_fd, "a+"); + if (f == NULL) { + typeof(errno) saved_errno = errno; + close(log_fd); + log_fd = -1; + errno = saved_errno; + return -1; + } + + setbuf(f, NULL); + return 0; +} + +int +log_time(FILE *log) +{ + if (!log) { + int rc = open_log(); + if (rc < 0) + return rc; + } + + time_t t = time(NULL); + char timestr[27]; + + ctime_r(&t, timestr); + timestr[26] = '\0'; + for (int i = 26; i >= 0; i--) + if (timestr[i] == '\n') + timestr[i] = '\0'; + + return log_message(log, "DBG: %d: %s: ", getpid(), timestr); +} + +int +log_vmessage(FILE *log, const char *msg, va_list ap) +{ + int rc; + + if (!msg) + return -1; + if (msg[0] == '\0') + return 0; + + if (!log) { + rc = open_log(); + if (rc < 0) + return rc; + } + + va_list aq; + va_copy(aq, ap); + + vfprintf(log ? log : f, msg, aq); + va_end(aq); + fdatasync(log ? fileno(log) : log_fd); + + return 0; +} + +int +log_message(FILE *log, const char *msg, ...) +{ + va_list argp; + + va_start(argp, msg); + int rc = log_vmessage(log, msg, argp); + va_end(argp); + return rc; +} diff --git a/grubby-8.40-1/log.h b/grubby-8.40-1/log.h new file mode 100644 index 0000000..082a59e --- /dev/null +++ b/grubby-8.40-1/log.h @@ -0,0 +1,27 @@ +/* + * log.h + * + * Copyright 2013 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef GRUBBY_LOG_H +#define GRUBBY_LOG_H 1 + +extern int log_time(FILE *log); +extern int log_vmessage(FILE *log, const char *msg, va_list ap); +extern int log_message(FILE *log, const char *msg, ...); + +#endif /* GRUBBY_LOG_H */ diff --git a/grubby-8.40-1/new-kernel-pkg b/grubby-8.40-1/new-kernel-pkg new file mode 100755 index 0000000..b634388 --- /dev/null +++ b/grubby-8.40-1/new-kernel-pkg @@ -0,0 +1,926 @@ +#!/bin/bash +# +# new-kernel-pkg +# Invoked upon installation or removal of a kernel package, the following +# tasks are/can be done here: +# creation/removal of initrd +# run of depmod/removal of depmod generated files +# addition/removal of kernel images from grub/lilo configuration (via grubby) +# +# Copyright 2002-2008 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +PATH=/sbin:/bin:$PATH + +lilo=/sbin/lilo + +# some defaults that are sane for most arches +kernelName=vmlinuz + +if [ -x ./grubby ]; then + grubby=./grubby +else + grubby=/sbin/grubby +fi + +[ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel +[ -f /etc/sysconfig/uboot ] && . /etc/sysconfig/uboot + +cfgGrub2="" +cfgGrub2Efi="" +cfgGrub="" +cfgLilo="" +cfgExtlinux="" +cfguBoot="" +runLilo="" +grubConfig="" +grub2Config="" +grub2EfiConfig="" +extlinuxConfig="" +ubootScript="/boot/boot.scr" + +ARCH=$(uname -m) + +if [ $ARCH = 'ia64' ]; then + liloConfig=/boot/efi/EFI/redhat/elilo.conf + bootPrefix=/boot/efi/EFI/redhat + liloFlag=elilo + isx86="" +elif [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then + liloConfig=/etc/yaboot.conf + grub2Config=$(readlink -f /etc/grub2.cfg 2>/dev/null) + bootPrefix=/boot + lilo=/sbin/ybin + liloFlag=yaboot + runLilo="yes" + isx86="" +elif [ $ARCH = 'sparc' -o $ARCH = 'sparc64' ]; then + liloConfig=/etc/silo.conf + bootPrefix=/boot + liloFlag=silo + lilo=/sbin/silo + isx86="" +elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then + liloConfig=/etc/zipl.conf + bootPrefix=/boot + liloFlag=zipl + lilo=/sbin/zipl + runLilo="yes" + isx86="" +elif [[ ${ARCH} =~ armv[5|7].*l ]] ; then + liloConfig="" + bootPrefix=/boot + extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) + ubootDir=${UBOOT_DIR:-"/boot"} + ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} + ubootKList=${UBOOT_KLIST:-"klist.txt"} + ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} + ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} + ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} + ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} + mounted="" + liloFlag="" + isx86="" +else + # this leaves i?86 and x86_64 + liloConfig=/etc/lilo.conf + grubConfig=$(readlink -f /etc/grub.conf 2>/dev/null) + grub2Config=$(readlink -f /etc/grub2.cfg 2>/dev/null) + grub2EfiConfig=$(readlink -f /etc/grub2-efi.cfg 2>/dev/null) + extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) + bootPrefix=/boot + liloFlag=lilo + isx86="yes" +fi + +mode="" +version="" +initrd="" +dracut="" +dracuthostonly="" +initrdfile="" +devtreefile="" +moddep="" +verbose="" +makedefault="" +package="" +mbkernel="$HYPERVISOR" +mbargs="$HYPERVISOR_ARGS" +adddracutargs="" +addplymouthinitrd="" +DEBUGARG="systemd.debug" + +usage() { + echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2 + echo " [--initrdfile=] [--depmod] [--rmmoddep]" >&2 + echo " [--kernel-args=] [--remove-args=]" >&2 + echo " [--banner=] [--multiboot=multiboot]" >&2 + echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2 + echo " [--add-plymouth-initrd]" >&2 + echo " [--host-only] [--devtree=] [--devtreedir=]" >&2 + echo " <--install | --remove | --update | --rpmposttrans> " >&2 + echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2 + exit 1 +} + +rungrubby() { + if [ "$1" == "--debug" ]; then + [ "$MAKEDEBUG" != "yes" ] && return 0 + [ -n "$verbose" ] && echo "- First, making a debug entry." + declare -x debugtitle=" with debugging" + declare -x debugargs="$DEBUGARG" + shift + else + [ -n "$verbose" ] && echo "- Making a normal entry." + fi + $(eval $grubby $@) + export -n debugargs + export -n debugtitle + unset debugargs + unset debugtitle +} + +set_title() { + if [ -n "$banner" ]; then + if [ $ARCH = 's390' -o $ARCH = 's390x' ]; then + title=$(echo $banner | sed 's/ /_/g') + else + title="$banner ($version)" + fi + elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then + title=$(echo $version | sed 's/ /_/g') + elif [ -f /etc/os-release ]; then + . /etc/os-release + title="$NAME ($version) $VERSION" + elif [ -f /etc/redhat-release ]; then + title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)" + else + title="Red Hat Linux ($version)" + fi +} + +install() { + # XXX kernel should be able to be specified also (or work right on ia64) + if [ ! -f $kernelImage ] ; then + [ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby" + return + fi + + INITRD="" + if [ -f $initrdfile ]; then + [ -n "$verbose" ] && echo "found $initrdfile and using it with grubby" + INITRD="--initrd $initrdfile" + + if [ -n "$addplymouthinitrd" ]; then + INITRD="$INITRD --extra-initrd $bootPrefix/initrd-plymouth.img" + fi + fi + + DEVTREE="" + if [ -n "$devtreefile" -a -f "$devtreefile" ]; then + [ -n "$verbose" ] && echo "found $devtreefile and using it with grubby" + DEVTREE="--devtree $devtreefile" + fi + + DEVTREEDIR="" + if [ -n "$devtreedir" -a -d "$devtreedir" ]; then + [ -n "$verbose" ] && echo "found $devtreedir and using it with grubby" + DEVTREEDIR="--devtreedir $devtreedir" + fi + + # FIXME: is this a good heuristic to find out if we're on iSeries? + if [ -d /proc/iSeries ]; then + [ -n "$verbose" ] && echo "On an iSeries, just making img file" + if [ -z $initrdfile ]; then + [ -n "$verbose" ] && echo "No initrd, just adding system map" + /sbin/addSystemMap $bootPrefix/System.map-$version $kernelImage $bootPrefix/vmlinitrd-$version + else + /sbin/addSystemMap $bootPrefix/System.map-$version $kernelImage $bootPrefix/vmlinux.sm-$version + /sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null + rm $bootPrefix/vmlinux.sm-$version + fi + return + fi + + # get the root filesystem to use + rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab 2>/dev/null) + if [ "$rootdevice" = "" ]; + then + rootdevice=`grep -o -P "(?<=root=)\S+" /proc/cmdline` + fi + + if [ -n "$mbkernel" -a -n "$cfgLilo" -a "$liloFlag" != "elilo" ]; then + [ -n "$verbose" ] && echo "multiboot specified, not updating lilo.conf" + cfgLilo="" + fi + + set_title + + if [ -n "$cfgGrub" ]; then + [ -n "$verbose" ] && echo "adding $version to $grubConfig" + + ARGS="--grub -c $grubConfig --add-kernel=$kernelImage $INITRD \ + ${mbkernel:+--add-multiboot=\"$mbkernel\"} \ + ${mbargs:+--mbargs=\"$mbargs\"} \ + --title=\"$title\$debugtitle\" --copy-default \ + --args=\"root=$rootdevice $kernargs \$debugargs\" \ + --remove-kernel=\"TITLE=$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} $makedefault + else + [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97" + fi + if [ -n "$cfgGrub2" ]; then + [ -n "$verbose" ] && echo "adding $version to $grub2Config" + + ARGS="--grub2 -c $grub2Config --add-kernel=$kernelImage $INITRD \ + --copy-default --title \"$title\$debugtitle\" \ + ${mbkernel:+--add-multiboot=\"$mbkernel\"} \ + ${mbargs:+--mbargs=\"$mbargs\"} \ + --args=\"root=$rootdevice $kernargs \$debugargs\" \ + --remove-kernel=\"TITLE=$title\$debugtitle\"" + rungrubby --debug ${ARGS} + rungrubby ${ARGS} $makedefault + else + [ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2" + fi + if [ -n "$cfgGrub2Efi" ]; then + [ -n "$verbose" ] && echo "adding $version to $grub2EfiConfig" + + ARGS="--grub2 -c $grub2EfiConfig --efi \ + --add-kernel=$kernelImage $DEVTREE $INITRD \ + --copy-default --title \"$title\$debugtitle\" \ + ${mbkernel:+--add-multiboot=\"$mbkernel\"} \ + ${mbargs:+--mbargs=\"$mbargs\"} \ + --args=\"root=$rootdevice $kernargs \$debugargs\" \ + --remove-kernel=\"TITLE=$title\$debugtitle\"" + rungrubby --debug ${ARGS} + rungrubby ${ARGS} $makedefault + else + [ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby for grub 2 with UEFI" + fi + + if [ -n "$cfgLilo" ]; then + [ -n "$verbose" ] && echo "adding $version to $liloConfig" + + ARGS="--$liloFlag --add-kernel=$kernelImage $INITRD \ + --copy-default --title \"$title\$debugtitle\" \ + ${mbkernel:+--add-multiboot=\"$mbkernel\"} \ + ${mbargs:+--mbargs=\"$mbargs\"} \ + --args=\"root=$rootdevice $kernargs \$debugargs\" \ + --remove-kernel=\"TITLE=$version\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} $makedefault + if [ -n "$runLilo" ]; then + [ -n "$verbose" ] && echo "running $lilo" + if [ ! -x $lilo ] ; then + [ -n "$verbose" ] && echo "$lilo does not exist" + else + $lilo > /dev/null + fi + fi + else + [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" + fi + + if [ -n "$cfgExtlinux" ]; then + [ -n "$verbose" ] && echo "adding $version to $extlinuxConfig" + + ARGS="--extlinux -c $extlinuxConfig --add-kernel=$kernelImage \ + $DEVTREEDIR $DEVTREE \ + $INITRD --copy-default --title \"$title\$debugtitle\" \ + ${mbkernel:+--add-multiboot=\"$mbkernel\"} \ + ${mbargs:+--mbargs=\"$mbargs\"} \ + --args=\"root=$rootdevice $kernargs \$debugargs\" \ + --remove-kernel=\"TITLE=$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} $makedefault + else + [ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux" + fi +} + +rpmposttrans() +{ + local files + local f + files="/etc/kernel/postinst.d/*[^~] /etc/kernel/postinst.d/$version/*[^~]" + for f in $files ; do + [ -f $f ] && [ -x $f ] || continue + $f $version $kernelImage + done +} + +remove() { + # FIXME: is this a good heuristic to find out if we're on iSeries? + if [ -d /proc/iSeries ]; then + [ -n "$verbose" ] && echo "On an iSeries, remove img file" + rm -f $kernelImage.img 2>/dev/null + return + fi + + local files + local f + files="/etc/kernel/prerm.d/*[^~] /etc/kernel/prerm.d/$version/*[^~]" + for f in $files ; do + [ -f $f ] && [ -x $f ] || continue + $f $version $kernelImage + done + + if [ -n "$cfgGrub" ]; then + [ -n "$verbose" ] && echo "removing $version from $grubConfig" + $grubby --grub -c $grubConfig \ + --remove-kernel=$kernelImage + else + [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby for grub 0.97" + fi + if [ -n "$cfgGrub2" ]; then + [ -n "$verbose" ] && echo "removing $version from $grub2Config" + $grubby --grub2 -c $grub2Config \ + --remove-kernel=$kernelImage + else + [ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby for grub 2" + fi + if [ -n "$cfgGrub2Efi" ]; then + [ -n "$verbose" ] && echo "removing $version from $grub2EfiConfig" + $grubby --grub2 -c $grub2EfiConfig --efi \ + --remove-kernel=$kernelImage + else + [ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby grub 2 with UEFI" + fi + + if [ -n "$cfgLilo" ]; then + [ -n "$verbose" ] && echo "removing $version from $liloConfig" + $grubby --remove-kernel=$kernelImage \ + --$liloFlag + + if [ -n "$runLilo" ]; then + [ -n "$verbose" ] && echo "running $lilo" + if [ ! -x $lilo ] ; then + [ -n "$verbose" ] && echo "$lilo does not exist" + else + $lilo > /dev/null + fi + fi + else + [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" + fi + + if [ -n "$cfguBoot" ]; then + [ -n "$verbose" ] && echo "removing $version from $ubootDir..." + + if [ -f $ubootDir/$ubootKList ]; then + tmpKList=`mktemp $ubootDir/$ubootKList.XXXX` + curversion=`tail -n1 $ubootDir/$ubootKList` + sed "/$version$/d" $ubootDir/$ubootKList > $tmpKList + newversion=`tail -n1 $tmpKList` + if [ -f $ubootDir/uImage-$newversion ] && [ -f $ubootDir/uInitrd-$newversion ]; then + if [ "$curversion" != "$newversion" ]; then + cp -fp $ubootDir/uImage-$newversion $ubootDir/${ubootDefaultImage} + if [ $? -ne 0 ]; then + [ -n "$verbose" ] && echo "copy uImage-$newversion error, default kernel not replaced!" && exit + fi + cp -fp $ubootDir/uInitrd-$newversion $ubootDir/${ubootDefaultInitrd} + if [ $? -ne 0 ]; then + [ -n "$verbose" ] && echo "copy uInitrd-$newversion error, default Initrd not replaced!" && exit + fi + fi + + [ -n "$verbose" ] && echo "removing uImage-$version" + if [ -f $ubootDir/uImage-$version ]; then + rm -f $ubootDir/uImage-$version + else + [ -n "$verbose" ] && echo "uImage-$version did not exist!" + fi + + [ -n "$verbose" ] && echo "removing uInitrd-$version" + if [ -f $ubootDir/uInitrd-$version ]; then + rm -f $ubootDir/uInitrd-$version + else + [ -n "$verbose" ] && echo "uInitrd-$version did not exist!" + fi + + mv $tmpKList $ubootDir/$ubootKList + [ -x /sbin/a-b-c ] && /sbin/a-b-c + else + [ -n "$verbose" ] && echo "uImage $newversion does not exist!" + [ -f $tmpKList ] && rm -f $tmpKList + fi + else + [ -n "$verbose" ] && echo "No previous kernel version. U-Boot images not removed!" + fi + else + [ -n "$verbose" ] && echo "$ubootScript does not exist, not modifying $ubootDir" + fi + + if [ -n "$cfgExtlinux" ]; then + [ -n "$verbose" ] && echo "removing $version from $extlinuxConfig" + $grubby --extlinux -c $extlinuxConfig \ + --remove-kernel=$kernelImage + else + [ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby for extlinux" + fi +} + +update() { + if [ ! -f $kernelImage ] ; then + [ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby" + return + fi + + set_title + + INITRD="" + if [ -f $initrdfile ]; then + [ -n "$verbose" ] && echo "found $initrdfile and using it with grubby" + INITRD="--initrd $initrdfile" + + if [ -n "$addplymouthinitrd" ]; then + INITRD="$INITRD --extra-initrd $bootPrefix/initrd-plymouth.img" + fi + fi + + DEVTREE="" + if [ -n "$devtreefile" -a -f "$devtreefile" ]; then + [ -n "$verbose" ] && echo "found $devtreefile and using it with grubby" + DEVTREE="--devtree $devtreefile" + fi + + DEVTREEDIR="" + if [ -n "$devtreedir" -a -d "$devtreedir" ]; then + [ -n "$verbose" ] && echo "found $devtreedir and using it with grubby" + DEVTREEDIR="--devtreedir $devtreedir" + fi + + if [ -n "$cfgGrub" ]; then + [ -n "$verbose" ] && echo "updating $version from $grubConfig" + ARGS="--grub -c $grubConfig --update-kernel=$kernelImage $INITRD \ + ${kernargs:+--args=\"$kernargs\"} \ + ${removeargs:+--remove-args=\"$removeargs\"} \ + ${mbkernel:+--add-multiboot=\"$mbkernel\"} \ + --title=\"$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} + else + [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby" + fi + + if [ -n "$cfgGrub2" ]; then + [ -n "$verbose" ] && echo "updating $version from $grub2Config" + ARGS="--grub2 -c $grub2Config --update-kernel=$kernelImage $INITRD \ + ${kernargs:+--args=\"$kernargs\"} \ + ${removeargs:+--remove-args=\"$removeargs\"} \ + --title=\"$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} + else + [ -n "$verbose" ] && echo "$grub2Config does not exist, not running grubby" + fi + + if [ -n "$cfgGrub2Efi" ]; then + [ -n "$verbose" ] && echo "updating $version from $grub2EfiConfig" + ARGS="--grub2 -c $grub2EfiConfig --efi --update-kernel=$kernelImage \ + $INITRD ${kernargs:+--args=\"$kernargs\"} \ + ${removeargs:+--remove-args=\"$removeargs\"} \ + --title=\"$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} + else + [ -n "$verbose" ] && echo "$grub2EfiConfig does not exist, not running grubby" + fi + + if [ -n "$cfgLilo" ]; then + [ -n "$verbose" ] && echo "updating $version from $liloConfig" + ARGS="--$liloFlag --update-kernel=$kernelImage $INITRD \ + ${kernargs:+--args=\"$kernargs\"} \ + ${removeargs:+--remove-args=\"$removeargs\"} \ + --title=\"$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} + + if [ -n "$runLilo" ]; then + [ -n "$verbose" ] && echo "running $lilo" + if [ ! -x $lilo ] ; then + [ -n "$verbose" ] && echo "$lilo does not exist" + else + $lilo > /dev/null + fi + fi + else + [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" + fi + + if [ -n "$cfguBoot" ]; then + [ -n "$verbose" ] && echo "adding $version to $ubootDir..." + + [ -n "$verbose" ] && echo "creating uImage-$version" + mkimage -A arm -O linux -T kernel -C none -a $ubootAddress \ + -e $ubootAddress -n $version \ + -d $kernelImage $ubootDir/uImage-$version + + [ -n "$verbose" ] && echo "creating uInitrd-$version" + mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ + -n initramfs -d $initrdfile $ubootDir/uInitrd-$version + + if [ -f $ubootDir/uImage-$version ] && [ -f $ubootDir/uInitrd-$version ]; then + cp -fp $ubootDir/uImage-$version $ubootDir/${ubootDefaultImage} + if [ $? -ne 0 ]; then + [ -n "$verbose" ] && echo "copy uImage-$version error, kernel not installed!" && exit + fi + cp -fp $ubootDir/uInitrd-$version $ubootDir/${ubootDefaultInitrd} + if [ $? -ne 0 ]; then + [ -n "$verbose" ] && echo "copy uInitrd-$version error, kernel not installed!" && exit + fi + echo $version >> $ubootDir/$ubootKList + [ -x /sbin/a-b-c ] && /sbin/a-b-c + else + [ -n "$verbose" ] && echo "cannot make $version the default" + fi + else + [ -n "$verbose" ] && echo "$ubootScript does not exist, not setting up $ubootDir" + fi + + if [ -n "$cfgExtlinux" ]; then + [ -n "$verbose" ] && echo "updating $version from $extlinuxConfig" + ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \ + $DEVTREE $DEVTREEDIR $INITRD ${kernargs:+--args=\"$kernargs\"} \ + ${removeargs:+--remove-args=\"$removeargs\"} \ + --title=\"$title\$debugtitle\"" + + rungrubby --debug ${ARGS} + rungrubby ${ARGS} + else + [ -n "$verbose" ] && echo "$extlinuxConfig does not exist, not running grubby" + fi +} + +doMkinitrd() { + if [ -n "$dracut" ]; then + tool="dracut $dracuthostonly -f $initrdfile $version" + else + tool="mkinitrd --allow-missing -f $initrdfile $version" + fi + [ -n "$verbose" ] && echo "creating initrd: $tool" + $tool + rc=$? + if [ $rc != 0 ]; then + echo "mkinitrd failed" >&2 + exit 1 + fi +} + +rminitrd() { + [ -n "$verbose" ] && echo "removing initrd $initrdfile" + [ -f $initrdfile ] && rm -f $initrdfile +} + +doDepmod() { + [ -n "$verbose" ] && echo "running depmod for $version" + depmod -ae -F /boot/System.map-$version $version +} + +doRmmoddep() { + [ -n "$verbose" ] && echo "removing modules.dep info for $version" + if [ -d /lib/modules/$version ]; then + rm -f /lib/modules/$version/modules.*.bin \ + /lib/modules/$version/modules.{alias,dep,devname,symbols,softdep} + fi +} + +# kernel image for 2.4 is vmlinux +if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then + if [ "$kernelmajor" == "2.4" ]; then + kernelName=vmlinux + fi +fi + +while [ $# -gt 0 ]; do + case $1 in + --mkinitrd) + initrd="make" + ;; + + --rminitrd) + initrd="remove" + ;; + + --devtree*) + if [[ $1 == --devtree\=* ]]; then + devtreefile=${1#--devtreefile=} + else + devtreefile=$2 + shift + fi + ;; + + --devtreedir*) + if [[ $1 == --devtreedir\=* ]]; then + devtreedir=${1#--devtreedir=} + else + devtreedir=$2 + shift + fi + ;; + + --dracut) + dracut=--dracut + ;; + + --host-only) + dracuthostonly=-H + ;; + + --initrdfile*) + if [[ $1 == --initrdfile\=* ]]; then + initrdfile=${1#--initrdfile=} + else + initrdfile=$2 + shift + fi + ;; + + --kernel-args*) + if [[ $1 == --kernel-args\=* ]]; then + kernargs=${1#--kernel-args=} + else + kernargs=$2 + shift + fi + ;; + + --remove-args*) + if [[ $1 == --remove-args\=* ]]; then + removeargs=${1#--remove-args=} + else + removeargs=$2 + shift + fi + ;; + + --banner*) + if [[ $1 == --banner\=* ]]; then + banner=${1#--banner=} + else + banner=$2 + shift + fi + ;; + + --multiboot*) + if [[ $1 == --multiboot\=* ]]; then + mbkernel=${1#--multiboot=} + else + # can't really support having an optional second arg here + # sorry! + mbkernel="/boot/xen.gz" + fi + ;; + + --mbargs*) + if [[ $1 == --mbargs\=* ]]; then + mbargs=${1#--mbargs=} + else + mbargs="$2" + shift + fi + ;; + + --depmod) + moddep="make" + ;; + + --rmmoddep) + moddep="remove" + ;; + + --make-default) + makedefault="--make-default" + ;; + + --package*) + if [[ $1 == --package\=* ]]; then + package=${1#--package=} + else + package=$2 + shift + fi + ;; + + --add-dracut-args) + adddracutargs=--add-dracut-args + ;; + + --add-plymouth-initrd) + addplymouthinitrd=--add-plymouth-initrd + ;; + + --kernel-image*) + if [[ $1 == --kernel-image\=* ]]; then + kernelImage=${1#--kernel-image=} + else + kernelImage="$2" + shift + fi + if ! [[ -f $kernelImage ]]; then + echo "Can't find kernel image '$kernelImage'" >&2 + usage + exit 1 + fi + ;; + + --kernel-name*) + if [[ $1 == --kernel-name\=* ]]; then + kernelName=${1#--kernel-name=} + else + kernelName="$2" + shift + fi + ;; + + -v) + verbose=-v + ;; + + *) + if [ -z "$mode" ]; then + mode=$1 + elif [ -z "$version" ]; then + version=$1 + else + usage + fi + ;; + esac + + shift +done + +# make sure the mode is valid +if [ "$mode" != "--install" -a "$mode" != "--remove" -a "$mode" != "--update" -a "$mode" != "--rpmposttrans" ] ; then + usage +fi + +if [ -z "$version" ]; then + usage +fi + +if [ "$mode" != "--install" -a "$makedefault" ]; then + usage +fi + +kernelmajor=`echo $kernel | cut -d . -f 1,2` + +[[ $kernelImage ]] || kernelImage="$bootPrefix/$kernelName-$version" + +# set the initrd file based on arch; ia64 is the only currently known oddball +if [ -z "$initrdfile" ]; then + INITRD_NAME_PREFIX="initrd" + if [ -n "$dracut" ]; then + INITRD_NAME_PREFIX="initramfs" + fi + + if [ `uname -m` = "ia64" ]; then + initrdfile="/boot/efi/EFI/redhat/$INITRD_NAME_PREFIX-$version.img" + else + initrdfile="/boot/$INITRD_NAME_PREFIX-$version.img" + fi + +fi +[ -n "$verbose" ] && echo "initrdfile is $initrdfile" + +if [[ ${ARCH} =~ armv[5|7].*l ]]; then + if [ -z "$SHIPSDTB" -o "$SHIPSDTB" != "yes" ]; then + if [ -n "$dtbfile" -a -f "$bootPrefix/dtb-$version/$dtbfile" ]; then + devtreefile="$bootPrefix/dtb-$version/$dtbfile" + [ -n "$verbose" ] && echo "devtreefile is $devtreefile" + elif [ -d "$bootPrefix/dtb-$version/" ]; then + devtreedir="$bootPrefix/dtb-$version/" + [ -n "$verbose" ] && echo "devtreedir is $devtreedir" + fi + fi +fi +[ -n "$verbose" ] && echo "devtreedir is $devtreedir" + +# add dracut i18n, keyboard and plymouth kernel args if requested +if [ -n "$dracut" -o -n "$adddracutargs" ]; then + if [ -r /etc/vconsole.conf ]; then + . /etc/vconsole.conf + elif [ -r /etc/sysconfig/keyboard ]; then + . /etc/sysconfig/keyboard + fi + + if [ -r /etc/locale.conf ]; then + . /etc/locale.conf + elif [ -r /etc/sysconfig/i18n ]; then + . /etc/sysconfig/i18n + fi + + for i in SYSFONT SYSFONTACM UNIMAP LANG KEYTABLE; do + val=$(eval echo \$$i) + [ -n "$val" ] && kernargs="$kernargs $i=$val" + done + + if [ -n "$KEYBOARDTYPE" -a "$KEYBOARDTYPE" != "pc" ]; then + kernargs="$kernargs KEYBOARDTYPE=$KEYBOARDTYPE" + fi +fi + +# set this as the default if we have the package and it matches +if [ "$mode" == "--install" -a "$UPDATEDEFAULT" == "yes" -a -n "$package" -a -n "$DEFAULTKERNEL" ]; then + if [ "$package" == "$DEFAULTKERNEL" -o "${package}-core" == "$DEFAULTKERNEL" ]; then + makedefault="--make-default" + [ -n "$verbose" ] && echo "making it the default based on config" + fi +fi + +if [ "$moddep" == "make" ]; then + doDepmod +elif [ "$moddep" == "remove" ]; then + doRmmoddep +fi + +if [ "$initrd" == "make" ]; then + doMkinitrd +elif [ "$initrd" == "remove" ]; then + rminitrd +fi + +if [ ! -x $grubby ] ; then + [ -n "$verbose" ] && echo "$grubby does not exist" + exit 0 +fi + + +[ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1; +[ -n "$grub2Config" ] && [ -f "$grub2Config" ] && cfgGrub2=1; +[ -n "$grub2EfiConfig" ] && [ -f "$grub2EfiConfig" ] && cfgGrub2Efi=1; +[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1; +[ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1; + +# if we have a U-Boot directory, but no boot script, check if the directory +# is mounted. If not, mount it, and then check if a boot script exists. +if [ -n "$ubootDir" ]; then + if [ -f "$ubootScript" ]; then + cfguBoot=1 + else + mountEntry=`mount | grep $ubootDir` + if [ -z "$mountEntry" ]; then + mount $ubootDevice $ubootDir + mounted=1 + fi + [ -f "$ubootScript" ] && cfguBoot=1; + fi +fi + +# if we're using U-Boot, check if the default load address should change +if [ -n "$cfguBoot" -a -z "$UBOOT_IMGADDR" ]; then + [[ $version =~ .([^.]*)$ ]] + platform=${BASH_REMATCH[1]} + # A few platforms use an alternate kernel load address + if [ "$platform" = "omap" ]; then + ubootAddress=0x80008000 + elif [ "$platform" = "imx" ]; then + ubootAddress=0x90008000 + fi +fi + +# if we have a lilo config on an x86 box, see if the default boot loader +# is lilo to determine if it should be run +if [ -n "$cfgLilo" -a -n "$isx86" ]; then + runLilo=$($grubby --bootloader-probe | grep lilo) +fi + +if [ "$mode" == "--install" ]; then + install +elif [ "$mode" == "--remove" ]; then + remove +elif [ "$mode" == "--update" ]; then + update +elif [ "$mode" == "--rpmposttrans" ]; then + rpmposttrans +fi + +# if we mounted the U-Boot directory, unmount it. +[ -n "$mounted" ] && umount $ubootDir + +exit 0 diff --git a/grubby-8.40-1/new-kernel-pkg.8 b/grubby-8.40-1/new-kernel-pkg.8 new file mode 100644 index 0000000..9868202 --- /dev/null +++ b/grubby-8.40-1/new-kernel-pkg.8 @@ -0,0 +1,115 @@ +.TH NEW-KERNEL-PKG 8 "Wed Apr 14 2010" +.SH NAME +new-kernel-pkg \- tool to script kernel installation + +.SH SYNOPSIS +\fBnew-kernel-pkg\fR [-v] [--mkinitrd] [--rminitrd] [--dracut] + [--initrdfile=\fIinitrd-image\fR] [--depmod] [--rmmoddep] + [--kernel-args=\fIargs\fR] [--remove-args=\fIargs\fR] + [--banner=\fIbanner\fR] [--multiboot=\fImultiboot\fR] + [--mbargs=\fImbargs\fR] [--make-default] [--add-dracut-args] + [--add-plymouth-initrd] [--host-only] [--devtree=\fIdevicetree.dtb\fR] + <--install | --remove | --update | --rpmposttrans> + +.SH DESCRIPTION +\fBnew-kernel-pkg\fR is a tool used in packaging to automate the installation +of a new kernel, including the creation of an initial ram filesystem image, +updating of bootloader configuration, and other associated tasks. + +.SH OPTIONS +.TP +\fB-v\fR +Be verbose. + +.TP +\fB-\-mkinitrd\fR +Create a new initial ram filesystem image. + +.TP +\fB-\-rminitrd\fR +Remove an initial ram filesystem image. + +.TP +\fB-\-devtree\fR=\fIdevicetree.dtb\fR +Use \fIdevicetree.dtb\fR as the device tree file in place of any devicetree +directive from the template stanza. + +.TP +\fB-\-dracut\fR +When creating a new initial ram filesystem image, use dracut(8) rather +than mkinitrd(8). Used in conjunction with -\-mkinitrd . + +.TP +\fB-\-initrdfile\fR=\fIinitrd-image\fR +Use the specified file as the initial ram filesystem image. + +.TP +\fB-\-depmod\fR +Create modules.dep and related files. + +.TP +\fB-\-rmmoddep\fR +Remove modules.dep and related files. + +.TP +\fB-\-kernel-args\fR=\fIargs\fR +Use \fIargs\fR as the boot command line for this kernel. + +.TP +\fB-\-remove-args\fR=\fIargs\fR +Remove specified kernel arguments for this kernel. + +.TP +\fB-\-banner\fR=\fIbanner\fR +Display \fIbanner\fR as the banner text in the bootloader. + +.TP +\fB-\-multiboot\fR=\fImultiboot-image\fR +Use \fImultiboot-image\fR as a multiboot image. + +.TP +\fB-\-mbargs\fR=\fImbargs\fR +Use \fImbargs\fR as arguments to the multiboot image. + +.TP +\fB-\-make-default\fR +Make this kernel the default boot option. + +.TP +\fB-\-add-dracut-args\fR +Automatically generate dracut options and add them to the kernel command line. + +.TP +\fB-\-add-plymouth-initrd\fR +Automatically add plymouth to the initial ram filesystem image. + +.TP +\fB-\-host-only\fR +Make an initial ram filesystem image that is specific to the running system. + +.TP +\fB-\-install\fR \fIkernel-version\fR +Install a new kernel. + +.TP +\fB-\-remove\fR \fIkernel-version\fR +Remove an installed kernel. + +.TP +\fB-\-update\fR \fIkernel-version\fR +Update the specified kernel. + +.TP +\fB-\-rpmposttrans\fR \fIkernel-version\fR +Run the rpmposttrans for the specified kernel. + +.SH "SEE ALSO" +.BR grubby(8) +.BR installkernel(8) + +.SH AUTHORS +.nf +Erik Troan +Jeremy Katz +Peter Jones +.fi diff --git a/grubby-8.40-1/test.sh b/grubby-8.40-1/test.sh new file mode 100755 index 0000000..6379698 --- /dev/null +++ b/grubby-8.40-1/test.sh @@ -0,0 +1,745 @@ +#!/bin/bash +# +# test.sh -- grubby regression tests +# +# Copyright 2007-2008 Red Hat, Inc. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +if [ -n "$TOPDIR" ]; then + LD_LIBRARY_PATH="$TOPDIR/nash:$TOPDIR/bdevid:/usr/lib:/lib" + export LD_LIBRARY_PATH +fi + +#---------------------------------------------------------------------- +# Global vars +#---------------------------------------------------------------------- + +cmd=${0##*/} +opt_bootloader=* +opt_verbose=false +read -d '' usage < /dev/null; then + (( pass++ )) + if $opt_verbose; then + echo ------------------------------------------------------------- + echo -n "PASS: " + printf "%q " "${runme[@]}"; echo + "${runme[@]}" | diff -U30 "$cfg" - + echo + fi + else + (( fail++ )) + echo ------------------------------------------------------------- + echo -n "FAIL: " + printf "%q " "${runme[@]}"; echo + "${runme[@]}" | diff -U30 "$correct" - + echo + fi +} + +# Test feature that display some information, checking that output instead of +# the generated configuration file +oneDisplayTest() { + typeset mode=$1 cfg=test/$2 correct=test/results/$3 + shift 3 + + local ENV_FILE="" + if [ "$mode" == "--grub2" ]; then + ENV_FILE="test/grub2-support_files/env_temp" + if [ "$1" == "--env" ]; then + cp "test/grub2-support_files/$2" "$ENV_FILE" + shift 2 + else + cp "test/grub2-support_files/grubenv.0" "$ENV_FILE" + fi + ENV_FILE="--env=$ENV_FILE" + fi + + local BIO="--bad-image-okay" + if [ "$1" == "--bad-image-bad" ]; then + BIO="" + shift + fi + + echo "$testing ... $mode $cfg $correct" + runme=( ./grubby "$mode" $BIO $ENV_FILE -c "$cfg" "$@" ) + if "${runme[@]}" 2>&1 | cmp "$correct" > /dev/null; then + (( pass++ )) + if $opt_verbose; then + echo ------------------------------------------------------------- + echo -n "PASS: " + printf "%q " "${runme[@]}"; echo + "${runme[@]}" 2>&1 | diff -U30 "$cfg" - + echo + fi + else + (( fail++ )) + echo ------------------------------------------------------------- + echo -n "FAIL: " + printf "%q " "${runme[@]}"; echo + "${runme[@]}" 2>&1 | diff -U30 "$correct" - + echo + fi +} + +commandTest() { + description=$1 + cmd0=$2 + text1=$3 + shift 3 + echo "$description" + output0=$(mktemp) + + $cmd0 > $output0 + + if echo $text1 | cmp $output0 - >/dev/null; then + (( pass++)) + if $opt_verbose; then + echo ------------------------------------------------------------- + echo -n "PASS: " + printf "%q " "\"$cmd0\""; echo + echo $text1 | diff -U30 $output0 - + echo + fi + else + (( fail++ )) + echo ------------------------------------------------------------- + echo -n "FAIL: " + printf "%q " "\"$cmd0\""; echo + echo $text1 | diff -U30 $output0 - + echo + fi +} + +# generate convenience functions +for b in $(./grubby --help | \ + sed -n 's/^.*--\([^ ]*\) *configure \1 bootloader.*/\1/p'); do + eval "${b}Test() { [[ \"$b\" == \$opt_bootloader ]] && oneTest --$b \"\$@\"; }" + eval "${b}DisplayTest() { [[ \"$b\" == \$opt_bootloader ]] && oneDisplayTest --$b \"\$@\"; }" +done + +#---------------------------------------------------------------------- +# Main +#---------------------------------------------------------------------- + +# Use /usr/bin/getopt which supports GNU-style long options +args=$(getopt -o b:hv --long bootloader,help,verbose -n "$cmd" -- "$@") || exit +eval set -- "$args" +while true; do + case $1 in + -b|--bootloader) opt_bootloader=$2; shift 2 ;; + -h|--help) echo "$usage"; exit 0 ;; + -v|--verbose) opt_verbose=true; shift ;; + --) shift; break ;; + *) echo "failed to process cmdline args" >&2; exit 1 ;; + esac +done + +export MALLOC_CHECK_=2 +if [ -n "${RANDOM}" ]; then + export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) +else + export MALLOC_PERTURB_=1 +fi + +testing="Parse/write comparison" +for n in test/*.[0-9]*; do + [ -d $n ] && continue + n=${n#*/} # remove test/ + b=${n%.*} # remove suffix + [[ $b == $opt_bootloader ]] || continue + ${b}Test $n ../$n --remove-kernel 1234 +done + +testing="Permission preservation" +unset b +for n in test/*.[0-9]*; do + n=${n#*/} # remove test/ + [[ ${n%.*} == "$b" ]] && continue + b=${n%.*} # remove suffix + [[ $b == $opt_bootloader ]] || continue + + echo "$testing ... --$b" + + cp test/$n ${b}-test + chmod 0614 ${b}-test + touch -t 200301010101.00 ${b}-test + time=$(ls -l ${b}-test | awk '{ print $6 " " $7 " "$8}') + perm=$(ls -l ${b}-test | awk '{print $1}') + ./grubby --${b} --add-kernel bar --title title -c ${b}-test + if [[ $? != 0 ]]; then + echo " FAIL (grubby returned non-zero)" + (( fail++ )) + elif newtime=$(ls -l ${b}-test | awk '{ print $6 " " $7 " "$8}') && \ + newperm=$(ls -l ${b}-test | awk '{print $1}') && \ + [[ $time == "$newtime" || $perm != "$newperm" ]] + then + echo " FAIL ($perm $newperm)"; + (( fail++ )) + else + (( pass++ )) + fi + rm -f ${b}-test +done + +testing="Following symlinks" +unset b +for n in test/*.[0-9]*; do + n=${n#*/} # remove test/ + [[ ${n%.*} == "$b" ]] && continue + b=${n%.*} # remove suffix + [[ $b == $opt_bootloader ]] || continue + + echo "$testing ... --$b" + + cp test/${b}.1 ${b}-test + ln -s ./${b}-test mytest + ./grubby --${b} --add-kernel bar --title title -c mytest + if [[ $? != 0 ]]; then + echo " failed (grubby returned non-zero)" + (( fail++ )) + elif [[ ! -L mytest ]]; then + echo " failed (not a symlink)" + (( fail++ )) + elif target=$(readlink mytest) && [[ $target != "./${b}-test" ]]; then + echo " failed (wrong target)" + (( fail++ )) + else + (( pass++ )) + fi + rm -f ${b}-test mytest +done + +testing="GRUB default directive" +grubTest grub.1 default/g1.1 --boot-filesystem=/boot --add-kernel /boot/new-kernel --title Some_Title +grubTest grub.1 default/g1.2 --boot-filesystem=/boot --add-kernel /boot/new-kernel --title Some_Title --make-default +grubTest grub.3 default/g3.1 --boot-filesystem=/boot --set-default=/boot/vmlinuz-2.4.7-2 +grubTest grub.3 default/g3.2 --boot-filesystem=/boot --set-default=/boot/vmlinuz-2.4.7-2smp +grubTest grub.4 default/g4.1 --boot-filesystem=/ --set-default=/boot/vmlinuz-2.4.7-ac3 --remove-kernel /boot/vmlinuz-2.4.7-2.5 +grubTest grub.4 default/g4.2 --boot-filesystem=/ --set-default=/boot/vmlinuz-2.4.7-ac3 --remove-kernel /boot/vmlinuz-2.4.7-2.5 --add-kernel=/boot/new-kernel --copy-default --title New_Title +grubTest grub.6 default/g6.1 --remove-kernel=/boot/vmlinuz-2.4.7-2.9 --boot-filesystem=/ + +testing="GRUB default index directive" +grubTest grub.13 setdefaultindex/g.13.0 --set-default-index=0 +grubTest grub.13 setdefaultindex/g.13.1 --set-default-index=1 +grubTest grub.13 setdefaultindex/g.13.9 --set-default-index=9 + +testing="GRUB add initrd" +grubTest grub.14 add/g1.7 --boot-filesystem=/ --update-kernel=/vmlinuz-4.0.0-0.rc4.git1.4.fc23.x86_64 --initrd /initramfs-4.0.0-0.rc4.git1.4.fc23.x86_64.img '--args= LANG=en_US.UTF-8' '--title=Fedora (4.0.0-0.rc4.git1.4.fc23.x86_64) 23 (Rawhide)' + +testing="GRUB display default index" +grubDisplayTest grub.1 defaultindex/0 --default-index +grubDisplayTest grub.2 defaultindex/0 --default-index +grubDisplayTest grub.3 defaultindex/0 --default-index +grubDisplayTest grub.4 defaultindex/0 --default-index +grubDisplayTest grub.5 defaultindex/0 --default-index +grubDisplayTest grub.6 defaultindex/2 --default-index +grubDisplayTest grub.7 defaultindex/2 --default-index +grubDisplayTest grub.8 defaultindex/0 --default-index +grubDisplayTest grub.9 defaultindex/0 --default-index +grubDisplayTest grub.10 defaultindex/0 --default-index +grubDisplayTest grub.10 defaultindex/0 --default-index + +testing="GRUB display default title" +grubDisplayTest grub.1 defaulttitle/g.1 --default-title +grubDisplayTest grub.2 defaulttitle/g.2 --default-title +grubDisplayTest grub.3 defaulttitle/g.3 --default-title +grubDisplayTest grub.4 defaulttitle/g.4 --default-title +grubDisplayTest grub.5 defaulttitle/g.5 --default-title +grubDisplayTest grub.6 defaulttitle/g.6 --default-title +grubDisplayTest grub.7 defaulttitle/g.7 --default-title +grubDisplayTest grub.8 defaulttitle/g.8 --default-title +grubDisplayTest grub.9 defaulttitle/g.9 --default-title +grubDisplayTest grub.10 defaulttitle/g.10 --default-title +grubDisplayTest grub.11 defaulttitle/g.11 --default-title + +testing="LILO default directive" +liloTest lilo.1 default/l1.1 --set-default=/boot/vmlinuz-2.4.18-4 +liloTest lilo.1 default/l1.2 --remove-kernel=/boot/vmlinuz-2.4.18-4smp +liloTest lilo.1 default/l1.3 --add-kernel /boot/kernel --title label \ + --copy-default +liloTest lilo.1 default/l1.4 --add-kernel /boot/kernel --title label \ + --copy-default --make-default + +testing="Z/IPL default directive" +ziplTest zipl.1 default/z1.1 --add-kernel /boot/new-kernel --title test +ziplTest zipl.1 default/z1.2 --add-kernel /boot/new-kernel --title test --make-default + +testing="GRUB fallback directive" +grubTest grub.5 fallback/g5.1 --remove-kernel=/boot/vmlinuz-2.4.7-ac3 \ + --boot-filesystem=/ +grubTest grub.5 fallback/g5.2 --remove-kernel=/boot/vmlinuz-2.4.7-2.5 \ + --boot-filesystem=/ +grubTest grub.5 fallback/g5.3 --remove-kernel=/boot/vmlinuz-2.4.7-2.5 \ + --boot-filesystem=/ --copy-default --add-kernel=/boot/new-kernel \ + --title="Some_Title" + +testing="Extlinux default directive" +extlinuxTest extlinux.1 default/extlinux1.1 --boot-filesystem=/boot --add-kernel /boot/new-kernel --title Some_Title +extlinuxTest extlinux.1 default/extlinux1.2 --boot-filesystem=/boot --add-kernel /boot/new-kernel --title Some_Title --make-default +extlinuxTest extlinux.3 default/extlinux3.1 --boot-filesystem=/boot --set-default=/boot/vmlinuz-3.12.0-2.fc21.i686 +extlinuxTest extlinux.3 default/extlinux3.2 --boot-filesystem=/boot --set-default=/boot/vmlinuz-3.12.0-2.fc21.i686+PAE + +testing="GRUB new kernel argument handling" +grubTest grub.1 args/g1.1 --boot-filesystem=/boot \ + --add-kernel=/boot/foo --title=some_title --args="1234" --copy-default +grubTest grub.1 args/g1.2 --boot-filesystem=/boot \ + --add-kernel=/boot/foo --title=some_title --args="1234" + +testing="Extlinux new kernel argument handling" +extlinuxTest extlinux.1 args/extlinux1.1 --boot-filesystem=/boot \ + --add-kernel=/boot/foo --title=some_title --args="1234" --copy-default +extlinuxTest extlinux.1 args/extlinux1.2 --boot-filesystem=/boot \ + --add-kernel=/boot/foo --title=some_title --args="1234" + +testing="GRUB remove kernel" +grubTest grub.7 remove/g7.1 --boot-filesystem=/ \ + --remove-kernel=/boot/vmlinuz-2.4.7-2.5 +grubTest grub.3 remove/g3.1 --boot-filesystem=/ \ + --remove-kernel=DEFAULT +grubTest grub.9 remove/g9.1 --boot-filesystem=/boot \ + --remove-kernel=/boot/vmlinuz-2.4.7-2 + +testing="YABOOT remove kernel" +yabootTest yaboot.1 remove/y1.1 --boot-filesystem=/ --remove-kernel=DEFAULT +yabootTest yaboot.1 remove/y1.2 --boot-filesystem=/ --remove-kernel=/boot/vmlinuz-2.5.50-eepro +yabootTest yaboot.2 remove/y2.1 --boot-filesystem=/ --remove-kernel=/boot/vmlinux-2.5.50 + +testing="Z/IPL remove kernel" +ziplTest zipl.1 remove/z1.1 --remove-kernel=/boot/vmlinuz-2.4.9-38 +ziplTest zipl.1 remove/z1.2 --remove-kernel=DEFAULT + +testing="Extlinux remove kernel" +extlinuxTest extlinux.4 remove/extlinux4.1 --boot-filesystem=/ \ + --remove-kernel=/boot/vmlinuz-3.11.7-301.fc20.i686 +extlinuxTest extlinux.3 remove/extlinux3.1 --boot-filesystem=/ \ + --remove-kernel=DEFAULT + +testing="GRUB update kernel argument handling" +grubTest grub.1 updargs/g1.1 --update-kernel=DEFAULT --args="root=/dev/hda1" +grubTest grub.1 updargs/g1.2 --update-kernel=DEFAULT \ + --args="root=/dev/hda1 hda=ide-scsi root=/dev/hda2" +grubTest grub.3 updargs/g3.1 --update-kernel=DEFAULT --args "hdd=notide-scsi" +grubTest grub.3 updargs/g3.2 --update-kernel=DEFAULT \ + --args "hdd=notide-scsi root=/dev/hdd1" +grubTest grub.3 updargs/g3.2 --update-kernel=DEFAULT \ + --args "root=/dev/hdd1 hdd=notide-scsi" +grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd" +grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=ide-scsi" +grubTest grub.3 updargs/g3.4 --update-kernel=ALL --remove-args="hdd=foobar" +grubTest grub.3 updargs/g3.7 --update-kernel=ALL \ + --remove-args="hdd root ro" +grubTest grub.7 updargs/g7.2 --boot-filesystem=/ \ + --update-kernel=ALL --args "hde=ide-scsi" +grubTest grub.7 updargs/g7.3 --boot-filesystem=/ \ + --update-kernel=DEFAULT --args "hde=ide-scsi" +grubTest grub.7 updargs/g7.4 --boot-filesystem=/ \ + --update-kernel=/vmlinuz-2.4.7-2 \ + --args "ro root=LABEL=/ console=tty0 console=ttyS1,9600n81 single" +grubTest grub.7 updargs/g7.5 --boot-filesystem=/ \ + --update-kernel=ALL --args "root=/dev/hda2" +grubTest grub.11 updargs/g11.1 --boot-filesystem=/ \ + --update-kernel=/vmlinuz-2.4.7-2smp \ + --args "ro root=LABEL=/ console=tty0 console=ttyS1,9600n81 single" +grubTest grub.11 updargs/g11.2 --boot-filesystem=/ \ + --update-kernel=/vmlinuz-2.4.7-2smp \ + --args "ro root=LABEL=/ single" + +testing="GRUB lba and root information on SuSE systems" +GRUBBY_SUSE_RELEASE=test/grub.12-support_files/etc/SuSE-release \ + GRUBBY_SUSE_GRUB_CONF=test/grub.12-support_files/etc/grub.conf \ + GRUBBY_GRUB_DEVICE_MAP=test/grub.12-support_files/boot/grub/device.map \ + grubTest grub.12 info/g12.1 --info=0 + +testing="LILO update kernel argument handling" +liloTest lilo.1 updargs/l1.1 --update-kernel=/boot/vmlinuz-2.4.18-4 \ + --args="root=/dev/md1" +liloTest lilo.1 updargs/l1.2 --update-kernel=/boot/vmlinuz-2.4.18-4smp \ + --args="root=LABEL=foo" +liloTest lilo.1 updargs/l1.3 --update-kernel=DEFAULT --args="foo" +liloTest lilo.1 updargs/l1.4 --update-kernel=ALL --args="foo bar root=/dev/md1" +liloTest lilo.1 updargs/l1.4 --update-kernel=ALL --args="foo root=/dev/md1 bar" +liloTest lilo.1 updargs/l1.6 --update-kernel=ALL --args="foo root=LABEL=/ bar" +liloTest lilo.3 updargs/l3.1 --update-kernel=/boot/vmlinuz-2.4.18-4 \ + --remove-args="hda" +liloTest lilo.3 updargs/l3.2 --update-kernel=ALL \ + --remove-args="single" --args "root=/dev/hda2" + +testing="Extlinux update kernel argument handling" +extlinuxTest extlinux.1 updargs/extlinux1.1 --update-kernel=DEFAULT --args="root=/dev/hda1" +extlinuxTest extlinux.1 updargs/extlinux1.2 --update-kernel=DEFAULT \ + --args="root=/dev/hda1 hda=ide-scsi root=/dev/hda2" +extlinuxTest extlinux.3 updargs/extlinux3.1 --update-kernel=DEFAULT --args "hdd=notide-scsi" +extlinuxTest extlinux.3 updargs/extlinux3.2 --update-kernel=DEFAULT \ + --args "hdd=notide-scsi root=/dev/hdd1" +extlinuxTest extlinux.3 updargs/extlinux3.2 --update-kernel=DEFAULT \ + --args "root=/dev/hdd1 hdd=notide-scsi" +extlinuxTest extlinux.3 updargs/extlinux3.4 --update-kernel=ALL --remove-args="hdd" +extlinuxTest extlinux.3 updargs/extlinux3.4 --update-kernel=ALL --remove-args="hdd=ide-scsi" +extlinuxTest extlinux.3 updargs/extlinux3.4 --update-kernel=ALL --remove-args="hdd=foobar" +extlinuxTest extlinux.3 updargs/extlinux3.7 --update-kernel=ALL \ + --remove-args="hdd root ro" +extlinuxTest extlinux.4 updargs/extlinux4.2 --boot-filesystem=/ \ + --update-kernel=ALL --args "hde=ide-scsi" +extlinuxTest extlinux.4 updargs/extlinux4.3 --boot-filesystem=/ \ + --update-kernel=DEFAULT --args "hde=ide-scsi" +extlinuxTest extlinux.4 updargs/extlinux4.4 --boot-filesystem=/ \ + --update-kernel=/vmlinuz-3.12.0-2.fc21.i686 \ + --args "ro root=LABEL=/ console=tty0 console=ttyS1,9600n81 single" +extlinuxTest extlinux.4 updargs/extlinux4.5 --boot-filesystem=/ \ + --update-kernel=ALL --args "root=/dev/hda2" + +testing="LILO add kernel" +liloTest lilo.4 add/l4.1 --add-kernel=/boot/new-kernel.img --title="title" \ + --copy-default --boot-filesystem=/boot +liloTest lilo.4 add/l4.2 --add-kernel=/boot/new-kernel.img --title="linux" \ + --copy-default --boot-filesystem=/boot --remove-kernel "TITLE=linux" +liloTest lilo.5 add/l5.1 --add-kernel=/boot/new-kernel.img --title="title" \ + --copy-default --boot-filesystem=/boot +liloTest lilo.5 add/l5.2 --add-kernel=/boot/new-kernel.img --title="linux" \ + --copy-default --boot-filesystem=/boot --remove-kernel "TITLE=linux" +liloTest lilo.6 add/l6.1 --add-kernel=/boot/new-kernel.img --title="title" \ + --initrd=/boot/new-initrd --copy-default --boot-filesystem=/boot +liloTest lilo.6 add/l6.2 --add-kernel=/boot/new-kernel.img --title="linux" \ + --initrd=/boot/new-initrd --copy-default --boot-filesystem=/boot --remove-kernel "TITLE=linux" + + +testing="GRUB add kernel" +grubTest grub.1 add/g1.1 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/ +grubTest grub.1 add/g1.2 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot +grubTest grub.1 add/g1.3 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/ --copy-default +grubTest grub.1 add/g1.4 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default +grubTest grub.1 add/g1.5 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --extra-initrd=/boot/extra-initrd --boot-filesystem=/ +grubTest grub.1 add/g1.6 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --extra-initrd=/boot/extra-initrd --boot-filesystem=/boot +grubTest grub.2 add/g2.1 --add-kernel=/boot/vmlinuz-2.4.7-2 \ + --initrd=/boot/initrd-2.4.7-new.img --boot-filesystem=/boot --copy-default \ + --title="Red Hat Linux (2.4.7-2)" \ + --remove-kernel="TITLE=Red Hat Linux (2.4.7-2)" +grubTest grub.8 add/g8.1 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default +grubTest grub.8 add/g8.2 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default \ + --args='console=tty0 console=ttyS1,9600n81 single' +grubTest grub.11 add/g11.1 --add-kernel=/boot/new-kernel.img --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default \ + --args='console=tty0 console=ttyS1,9600n81 single' + +testgrub2=n +ARCH=$(uname -m | sed s,i[3456789]86,ia32,) +case $ARCH in + aarch64|ppc|ppc64|ia32|x86_64) testgrub2=y ;; +esac + +if [ "$testgrub2" == "y" ]; then + testing="GRUB2 add kernel" + grub2Test grub2.1 add/g2-1.1 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default + case $ARCH in + aarch64) + grub2Test grub2.1 add/g2-1.1 --add-kernel=/boot/new-kernel.img \ + --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default --efi + ;; + *) + grub2Test grub2.1 add/g2-1.6 --add-kernel=/boot/new-kernel.img \ + --title='title' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default --efi + ;; + esac + grub2Test grub2.6 add/g2-1.7 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default --efi + grub2Test grub2.1 add/g2-1.2 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default --make-default + grub2Test grub2.1 add/g2-1.3 --add-kernel=/boot/new-kernel.img \ + --title='title' --boot-filesystem=/boot/ --copy-default --make-default + grub2Test grub2.1 remove/g2-1.4 \ + --remove-kernel=/boot/vmlinuz-2.6.38.2-9.fc15.x86_64 \ + --boot-filesystem=/boot/ + grub2Test grub2.5 add/g2-1.5 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default + grub2Test grub2.12 add/g2-1.12 \ + --add-kernel=/boot/vmlinuz-2.6.38.8-32.fc15.x86_64 \ + --title='Linux, with Fedora 2.6.38.8-32.fc15.x86_64' \ + --devtree='/boot/dtb-2.6.38.8-32.fc15.x86_64/foobarbaz.dtb' \ + --initrd=/boot/initramfs-2.6.38.8-32.fc15.x86_64.img \ + --boot-filesystem=/boot/ --copy-default --efi + grub2Test grub2.13 add/g2-1.13 \ + --add-kernel=/boot/vmlinuz-2.6.38.8-32.fc15.x86_64 \ + --title='Linux, with Fedora 2.6.38.8-32.fc15.x86_64' \ + --devtree='/boot/dtb-2.6.38.8-32.fc15.x86_64/foobarbaz.dtb' \ + --initrd=/boot/initramfs-2.6.38.8-32.fc15.x86_64.img \ + --boot-filesystem=/boot/ --copy-default --efi + grub2Test grub2.15 add/g2-1.15 \ + --add-kernel=/boot/vmlinuz-0-rescue-5a94251776a14678911d4ae0949500f5 \ + --initrd /boot/initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img \ + --copy-default --title "Fedora 21 Rescue" --args=root=/fooooo \ + --remove-kernel=wtf --boot-filesystem=/boot/ --efi + + testing="GRUB2 add initrd" + grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \ + --initrd=/boot/new-initrd --boot-filesystem=/boot/ + + testing="GRUB2 display default index" + grub2DisplayTest grub2.1 defaultindex/0 --default-index + grub2DisplayTest grub2.2 defaultindex/0 --default-index + + testing="GRUB2 display default title" + grub2DisplayTest grub2.1 defaulttitle/g2.1 --default-title + grub2DisplayTest grub2.2 defaulttitle/g2.2 --default-title + + testing="GRUB2 display debug failure" + grub2DisplayTest grub2.1 debug/g2.1 --bad-image-bad \ + --boot-filesystem=/boot --default-kernel --debug + testing="GRUB2 display debug success" + grub2DisplayTest grub2.1 debug/g2.1.2 --boot-filesystem=/boot \ + --default-kernel --debug + + testing="GRUB2 remove kernel via index" + grub2Test grub2.3 remove/g2-1.1 --remove-kernel=1 + + testing="GRUB2 remove kernel via title" + grub2Test grub2.3 remove/g2-1.1 --remove-kernel="TITLE=title2" + + testing="GRUB2 (submenu) remove kernel via index" + grub2Test grub2.4 remove/g2-1.2 --remove-kernel=2 + + testing="GRUB2 (submenu) remove kernel via title" + grub2Test grub2.4 remove/g2-1.2 --remove-kernel="TITLE=title2" + + testing="GRUB2 default index directive" + grub2Test grub2.1 setdefaultindex/g2.1.0 --set-default-index=0 + grub2Test grub2.1 setdefaultindex/g2.1.1 --set-default-index=1 + grub2Test grub2.1 setdefaultindex/g2.1.9 --set-default-index=9 + + testing="GRUB2 add kernel with default=saved_entry" + grub2Test grub2.7 add/g2-1.8 --env grubenv.1 \ + --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default + commandTest "saved_default output" \ + "grub2-editenv test/grub2-support_files/env_temp list" \ + "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64" + + testing="GRUB2 add kernel with default=saved_entry and a terrible title" + grub2Test grub2.7 add/g2-1.9 --env grubenv.1 \ + --add-kernel=/boot/new-kernel.img \ + --title='Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)' \ + --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default + + testing="GRUB2 set default with default=saved_entry and a terrible name" + grub2Test grub2.9 add/g2-1.9 --env grubenv.1 --set-default-index=0 + commandTest "saved_default output" \ + "grub2-editenv test/grub2-support_files/env_temp list" \ + 'saved_entry=Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)' + + testing="GRUB2 set default with default=saved_entry" + grub2Test grub2.8 add/g2-1.8 --env grubenv.1 --set-default-index=0 + commandTest "saved_default output" \ + "grub2-editenv test/grub2-support_files/env_temp list" \ + "saved_entry=title" + + testing="GRUB2 --default-index with default=saved_entry" + grub2DisplayTest grub2.8 defaultindex/1 --env grubenv.1 --default-index + + testing="GRUB2 --default-index with default=saved_entry" + grub2DisplayTest grub2.8 defaultindex/0 --env grubenv.2 --default-index + + testing="GRUB2 --default-title with default=saved_entry" + grub2DisplayTest grub2.8 defaulttitle/g2.1 --env grubenv.1 --default-title + + testing="GRUB2 --default-index with default=saved_entry and empty grubenv" + grub2DisplayTest grub2.8 defaultindex/0 --env grubenv.0 --default-index + + testlinux16=n + case $ARCH in + ia32|x86_64) testlinux16=y ;; + esac + + if [ "$testlinux16" == "y" ]; then + testing="GRUB2 add kernel with linux16" + grub2Test grub2.10 add/g2-1.10 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ + --copy-default + + testing="GRUB2 add initrd with linux16" + grub2Test grub2.11 add/g2-1.11 --update-kernel=/boot/new-kernel.img \ + --initrd=/boot/new-initrd --boot-filesystem=/boot/ + + testing="GRUB2 add rescue with linux16" + grub2Test grub2.14 add/g2-1.14 \ + --add-kernel=/boot/vmlinuz-0-rescue-5a94251776a14678911d4ae0949500f5 \ + --initrd /boot/initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img \ + --copy-default --title "Fedora 21 Rescue" --args=root=/fooooo \ + --remove-kernel=wtf --boot-filesystem=/boot/ + fi +fi + +testing="YABOOT add kernel" +yabootTest yaboot.1 add/y1.1 --copy-default --boot-filesystem=/ --add-kernel=/boot/new-kernel \ + --title=newtitle +yabootTest yaboot.1 add/y1.2 --add-kernel=/boot/new-kernel --boot-filesystem=/ --title=newtitle + +testing="YABOOT empty label" +yabootTest yaboot.3 add/y3.1 --add-kernel=/boot/new-kernel --boot-filesystem=/ --title=newtitle + +testing="Z/IPL add kernel" +ziplTest zipl.1 add/z1.1 --add-kernel=/boot/new-kernel.img --title test +ziplTest zipl.1 add/z1.2 --add-kernel=/boot/new-kernel.img --title test --copy-default + +testing="Extlinux add kernel" +extlinuxTest extlinux.1 add/extlinux1.1 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/ +extlinuxTest extlinux.1 add/extlinux1.2 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot +extlinuxTest extlinux.1 add/extlinux1.3 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/ \ + --copy-default +extlinuxTest extlinux.1 add/extlinux1.4 --add-kernel=/boot/new-kernel.img \ + --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot \ + --copy-default +extlinuxTest extlinux.2 add/extlinux2.1 \ + --add-kernel=/boot/vmlinuz-3.12.0-2.fc21.i686 \ + --initrd=/boot/initrd-3.12.0-2.fc21.i686-new.img \ + --boot-filesystem=/boot --copy-default \ + --title="Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug)" \ + --remove-kernel="TITLE=Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug)" +extlinuxTest extlinux.5 add/extlinux5.1 \ + --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl \ + --devtree='/boot/dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/imx6q-cubox-i.dtb' \ + --initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img \ + --boot-filesystem=/boot --copy-default \ + --title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \ + --remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)" +extlinuxTest extlinux.6 add/extlinux6.1 \ + --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl \ + --devtreedir='/boot/dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/' \ + --initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img \ + --boot-filesystem=/boot --copy-default \ + --title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \ + --remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)" + +testing="LILO long titles" +liloTest lilo.1 longtitle/l1.1 --add-kernel=/boot/new-kernel.img \ + --title="linux-longtitle" --copy-default --boot-filesystem=/boot +liloTest lilo.1 longtitle/l1.2 --add-kernel=/boot/new-kernel.img \ + --title="linux-toolongtitle" --copy-default --boot-filesystem=/boot +liloTest lilo.7 longtitle/l7.1 --add-kernel=/boot/new-kernel.img \ + --title="linux-longtitle-fix" --copy-default --boot-filesystem=/boot + +testing="ELILO long titles" +eliloTest lilo.7 longtitle/e7.1 --add-kernel=/boot/new-kernel.img \ + --title="linux-longtitle-fix" --copy-default --boot-filesystem=/boot + +testing="GRUB add multiboot" +grubTest grub.1 multiboot/g1.1 --add-multiboot=/boot/xen.gz \ + --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 --boot-filesystem=/boot \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --mbargs="dom0_mem=130000" +grubTest grub.1 multiboot/g1.2 --add-multiboot=/boot/xen.gz \ + --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 --boot-filesystem=/boot \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --mbargs="dom0_mem=130000" --copy-default +grubTest grub.10 multiboot/g10.1 --add-multiboot=/boot/xen.gz \ + --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 --boot-filesystem=/boot \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --mbargs="dom0_mem=130000" +grubTest grub.10 multiboot/g10.2 --add-multiboot=/boot/xen.gz \ + --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 --boot-filesystem=/boot \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --mbargs="dom0_mem=130000" --copy-default +grubTest grub.10 multiboot/g10.3 --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --copy-default --boot-filesystem=/boot +grubTest grub.10 multiboot/g10.4 --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --boot-filesystem=/boot + +testing="GRUB remove multiboot" +grubTest grub.10 multiboot/g10.5 --boot-filesystem=/boot \ + --remove-kernel=/boot/vmlinuz-2.6.10-1.1076_FC4 +grubTest grub.10 multiboot/g10.6 --boot-filesystem=/boot \ + --remove-kernel=/boot/vmlinuz-2.6.10-1.1082_FC4 +grubTest grub.10 multiboot/g10.7 --boot-filesystem=/boot \ + --remove-multiboot=/boot/xen.gz + +testing="ELILO add multiboot" +eliloTest elilo.1 multiboot/e1.1 --add-multiboot=/boot/xen.gz \ + --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 --boot-filesystem=/boot \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --mbargs="dom0_mem=130000" +eliloTest elilo.1 multiboot/e1.2 --add-multiboot=/boot/xen.gz \ + --add-kernel=/boot/vmlinuz-2.6.10-1.1088_FC4 --boot-filesystem=/boot \ + --initrd=/boot/initrd-2.6.10-1.1088_FC4.img --title foo \ + --mbargs="dom0_mem=130000" --copy-default + +testing="ELILO remove multiboot" +eliloTest elilo.2 multiboot/e2.1 --boot-filesystem=/boot \ + --remove-kernel=/boot/vmlinuz-2.6.10-1.1076_FC4 +eliloTest elilo.2 multiboot/e2.2 --boot-filesystem=/boot \ + --remove-kernel=/boot/vmlinuz-2.6.10-1.1082_FC4 +eliloTest elilo.2 multiboot/e2.3 --boot-filesystem=/boot \ + --remove-multiboot=/boot/xen.gz + +printf "\n%d (%d%%) tests passed, %d (%d%%) tests failed\n" \ + $pass $(((100*pass)/(pass+fail))) \ + $fail $(((100*fail)/(pass+fail))) + +exit $(( !!fail )) diff --git a/grubby-8.40-1/test/elilo.1 b/grubby-8.40-1/test/elilo.1 new file mode 100644 index 0000000..799ecf9 --- /dev/null +++ b/grubby-8.40-1/test/elilo.1 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/elilo.2 b/grubby-8.40-1/test/elilo.2 new file mode 100644 index 0000000..f500df5 --- /dev/null +++ b/grubby-8.40-1/test/elilo.2 @@ -0,0 +1,30 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/vmlinuz-2.6.10-1.1076_FC4 + label=foo + initrd=/initrd-2.6.10-1.1088_FC4.img + append="dom0_mem=130000 --" +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + vmm=/xen.gz + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/vmlinuz-2.6.10-1.1082_FC4 + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/extlinux.1 b/grubby-8.40-1/test/extlinux.1 new file mode 100644 index 0000000..85c9272 --- /dev/null +++ b/grubby-8.40-1/test/extlinux.1 @@ -0,0 +1,17 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/extlinux.2 b/grubby-8.40-1/test/extlinux.2 new file mode 100644 index 0000000..eae4aa7 --- /dev/null +++ b/grubby-8.40-1/test/extlinux.2 @@ -0,0 +1,21 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/hda5 hdd=ide-scsi +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/extlinux.3 b/grubby-8.40-1/test/extlinux.3 new file mode 100644 index 0000000..63f97bf --- /dev/null +++ b/grubby-8.40-1/test/extlinux.3 @@ -0,0 +1,15 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/extlinux.4 b/grubby-8.40-1/test/extlinux.4 new file mode 100644 index 0000000..14b795c --- /dev/null +++ b/grubby-8.40-1/test/extlinux.4 @@ -0,0 +1,32 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) + +label Fedora (3.11.7-300.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-300.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-300.fc20.i686.img + +label Fedora (3.11.7-301.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-301.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-301.fc20.i686.img + +label Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.13.0-0.rc0.git5.1.fc21.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.13.0-0.rc0.git5.1.fc21.i686.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/extlinux.5 b/grubby-8.40-1/test/extlinux.5 new file mode 100644 index 0000000..30e7572 --- /dev/null +++ b/grubby-8.40-1/test/extlinux.5 @@ -0,0 +1,21 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide) + +label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl +fdt /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/imx6q-cubox-i.dtb +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img + +label Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.12.0-0.fc21.armv7hl +fdt /dtb-3.12.0-0.fc21.armv7hl/imx6q-cubox-i.dtb +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.12.0-0.fc21.armv7hl.img + diff --git a/grubby-8.40-1/test/extlinux.6 b/grubby-8.40-1/test/extlinux.6 new file mode 100644 index 0000000..c28a4a8 --- /dev/null +++ b/grubby-8.40-1/test/extlinux.6 @@ -0,0 +1,21 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide) + +label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl +fdtdir /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/ +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img + +label Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.12.0-0.fc21.armv7hl +fdtdir /dtb-3.12.0-0.fc21.armv7hl/ +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.12.0-0.fc21.armv7hl.img + diff --git a/grubby-8.40-1/test/grub.1 b/grubby-8.40-1/test/grub.1 new file mode 100644 index 0000000..ed042e3 --- /dev/null +++ b/grubby-8.40-1/test/grub.1 @@ -0,0 +1,16 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/grub.10 b/grubby-8.40-1/test/grub.10 new file mode 100644 index 0000000..6271061 --- /dev/null +++ b/grubby-8.40-1/test/grub.10 @@ -0,0 +1,10 @@ +default=0 +title xen + root (hd0,1) + kernel /xen.gz + module /vmlinuz-2.6.10-1.1082_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1082_FC4 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/grub.11 b/grubby-8.40-1/test/grub.11 new file mode 100644 index 0000000..ee870e8 --- /dev/null +++ b/grubby-8.40-1/test/grub.11 @@ -0,0 +1,10 @@ +#boot=/dev/hda +timeout=10 +default=0 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + kernel (hd0,1)/vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi console=tty0 console=ttyS0,9600n81 + initrd (hd0,1)/initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + kernel (hd0,1)/vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/grub.12 b/grubby-8.40-1/test/grub.12 new file mode 100644 index 0000000..3cd2819 --- /dev/null +++ b/grubby-8.40-1/test/grub.12 @@ -0,0 +1,32 @@ +# Modified by YaST2. Last modification on Thu Mar 8 16:06:03 BRT 2012 +# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader +# For the new kernel it try to figure out old parameters. In case we are not able to recognize it (e.g. change of flavor or strange install order ) it it use as fallback installation parameters from /etc/sysconfig/bootloader + +default 0 +timeout 8 +##YaST - generic_mbr +##YaST - activate + +###Don't change this comment - YaST2 identifier: Original name: linux### +title Desktop -- openSUSE 12.1 - 3.1.9-1.4 + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-desktop root=/dev/vda2 resume=/dev/vda1 splash=silent quiet showopts vga=0x314 + initrd /boot/initrd-3.1.9-1.4-desktop + +###Don't change this comment - YaST2 identifier: Original name: failsafe### +title Failsafe -- openSUSE 12.1 - 3.1.9-1.4 (desktop) + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-desktop root=/dev/vda2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x314 + initrd /boot/initrd-3.1.9-1.4-desktop + +###Don't change this comment - YaST2 identifier: Original name: linux### +title openSUSE 12.1 - 3.1.9-1.4 + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-default root=/dev/vda2 resume=/dev/vda1 splash=silent quiet showopts vga=0x314 + initrd /boot/initrd-3.1.9-1.4-default + +###Don't change this comment - YaST2 identifier: Original name: failsafe### +title Failsafe -- openSUSE 12.1 - 3.1.9-1.4 (default) + root (hd0,1) + kernel /boot/vmlinuz-3.1.9-1.4-default root=/dev/vda2 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x314 + initrd /boot/initrd-3.1.9-1.4-default diff --git a/grubby-8.40-1/test/grub.12-support_files/boot/grub/device.map b/grubby-8.40-1/test/grub.12-support_files/boot/grub/device.map new file mode 100644 index 0000000..e2b208c --- /dev/null +++ b/grubby-8.40-1/test/grub.12-support_files/boot/grub/device.map @@ -0,0 +1 @@ +(hd0) /dev/vda diff --git a/grubby-8.40-1/test/grub.12-support_files/etc/SuSE-release b/grubby-8.40-1/test/grub.12-support_files/etc/SuSE-release new file mode 100644 index 0000000..ddd0acd --- /dev/null +++ b/grubby-8.40-1/test/grub.12-support_files/etc/SuSE-release @@ -0,0 +1,3 @@ +openSUSE 12.1 (x86_64) +VERSION = 12.1 +CODENAME = Asparagus diff --git a/grubby-8.40-1/test/grub.12-support_files/etc/grub.conf b/grubby-8.40-1/test/grub.12-support_files/etc/grub.conf new file mode 100644 index 0000000..9af4c20 --- /dev/null +++ b/grubby-8.40-1/test/grub.12-support_files/etc/grub.conf @@ -0,0 +1,2 @@ +setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1) +quit diff --git a/grubby-8.40-1/test/grub.13 b/grubby-8.40-1/test/grub.13 new file mode 100644 index 0000000..1ae82a8 --- /dev/null +++ b/grubby-8.40-1/test/grub.13 @@ -0,0 +1,21 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 +# initrd /initrd-version.img +#boot=/dev/vda +default=0 +timeout=5 +splashimage=(hd0,0)/grub/splash.xpm.gz +hiddenmenu +title Red Hat Enterprise Linux Server (2.6.18-308.1.1.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-308.1.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-308.1.1.el5.img +title Red Hat Enterprise Linux Server (2.6.18-238.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-238.el5.img diff --git a/grubby-8.40-1/test/grub.14 b/grubby-8.40-1/test/grub.14 new file mode 100644 index 0000000..5c0b9b3 --- /dev/null +++ b/grubby-8.40-1/test/grub.14 @@ -0,0 +1,96 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a partition. This means that +# all kernel and initrd paths are relative to /, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/d2/root +# initrd /initrd-version.img +#boot=/dev/hda +timeout=5 +splashimage=(hd0,0)/grub/splash.xpm.gz +default=0 +hiddenmenu +title Fedora (4.0.0-0.rc4.git1.4.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc4.git1.4.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge +title Fedora (4.0.0-0.rc4.git0.1.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc4.git0.1.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc4.git0.1.fc23.x86_64.img +title Fedora (4.0.0-0.rc1.git1.2.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc1.git1.2.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc1.git1.2.fc23.x86_64.img +title Fedora (4.0.0-0.rc1.git0.1.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc1.git0.1.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc1.git0.1.fc23.x86_64.img +title Fedora (3.20.0-0.rc0.git9.2.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.20.0-0.rc0.git9.2.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.20.0-0.rc0.git9.2.fc23.x86_64.img +title Fedora (3.20.0-0.rc0.git6.2.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.20.0-0.rc0.git6.2.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.20.0-0.rc0.git6.2.fc23.x86_64.img +title Fedora (3.19.0-1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-1.fc22.x86_64.img +title Fedora (3.19.0-0.rc7.git1.2.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc7.git1.2.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc7.git1.2.fc22.x86_64.img +title Fedora (3.19.0-0.rc7.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc7.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc7.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc6.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc6.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc6.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc5.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc5.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc5.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc4.git2.2.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc4.git2.2.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc4.git2.2.fc22.x86_64.img +title Fedora (3.19.0-0.rc4.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc4.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc4.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc3.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc3.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc3.git0.1.fc22.x86_64.img +title Fedora (3.18.1-2.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.18.1-2.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.18.1-2.fc22.x86_64.img +title Fedora (3.17.1-302.fc21.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.17.1-302.fc21.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.17.1-302.fc21.x86_64.img +title Fedora 20 Rescue 4b741960432e833443a6bc004563501d (3.10.0-0.rc4.git0.1.fc20.x86_64) + root (hd0,0) + kernel /vmlinuz-0-rescue-4b741960432e833443a6bc004563501d ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-0-rescue-4b741960432e833443a6bc004563501d.img +title Fedora 20 Rescue 4b741960432e833443a6bc004563501d (3.9.0-0.rc4.git0.1.fc20.x86_64) + root (hd0,0) + kernel /vmlinuz-0-rescue-4b741960432e833443a6bc004563501d ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-0-rescue-4b741960432e833443a6bc004563501d.img +title Memtest86+ (4.20) + root (hd0,0) + kernel /elf-memtest86+-4.20 +title Fedora (2.6.29.5-191.fc11.x86_64) + root (hd0,0) + kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/d2/rescue64 + initrd /initrd-2.6.29.5-191.fc11.x86_64.img +title install + kernel /f10vz + initrd /f10ird.img +title gittest + kernel /gittest diff --git a/grubby-8.40-1/test/grub.2 b/grubby-8.40-1/test/grub.2 new file mode 100644 index 0000000..d894006 --- /dev/null +++ b/grubby-8.40-1/test/grub.2 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/hda5 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,1) + chainloader +1 diff --git a/grubby-8.40-1/test/grub.3 b/grubby-8.40-1/test/grub.3 new file mode 100644 index 0000000..7d50bb8 --- /dev/null +++ b/grubby-8.40-1/test/grub.3 @@ -0,0 +1,16 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/grub.4 b/grubby-8.40-1/test/grub.4 new file mode 100644 index 0000000..759382a --- /dev/null +++ b/grubby-8.40-1/test/grub.4 @@ -0,0 +1,25 @@ +default=0 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.9 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.9.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/grub.5 b/grubby-8.40-1/test/grub.5 new file mode 100644 index 0000000..c5f5b3e --- /dev/null +++ b/grubby-8.40-1/test/grub.5 @@ -0,0 +1,21 @@ +default=0 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz +fallback=1 + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/grub.6 b/grubby-8.40-1/test/grub.6 new file mode 100644 index 0000000..e754f93 --- /dev/null +++ b/grubby-8.40-1/test/grub.6 @@ -0,0 +1,25 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.9 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.9.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/grub.7 b/grubby-8.40-1/test/grub.7 new file mode 100644 index 0000000..f5023d3 --- /dev/null +++ b/grubby-8.40-1/test/grub.7 @@ -0,0 +1,30 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/grub.8 b/grubby-8.40-1/test/grub.8 new file mode 100644 index 0000000..9264f04 --- /dev/null +++ b/grubby-8.40-1/test/grub.8 @@ -0,0 +1,16 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2) + root (hd0,7) + kernel (hd0,0)/vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd (hd0,0)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/grub.9 b/grubby-8.40-1/test/grub.9 new file mode 100644 index 0000000..0fad5b0 --- /dev/null +++ b/grubby-8.40-1/test/grub.9 @@ -0,0 +1,9 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + kernel (hd0,1)/vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + kernel (hd0,1)/vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/grub2-support_files/.gitignore b/grubby-8.40-1/test/grub2-support_files/.gitignore new file mode 100644 index 0000000..d2f9f58 --- /dev/null +++ b/grubby-8.40-1/test/grub2-support_files/.gitignore @@ -0,0 +1 @@ +env_temp diff --git a/grubby-8.40-1/test/grub2-support_files/grubenv.0 b/grubby-8.40-1/test/grub2-support_files/grubenv.0 new file mode 100644 index 0000000..f93ccbf --- /dev/null +++ b/grubby-8.40-1/test/grub2-support_files/grubenv.0 @@ -0,0 +1,2 @@ +# GRUB Environment Block +####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### \ No newline at end of file diff --git a/grubby-8.40-1/test/grub2-support_files/grubenv.1 b/grubby-8.40-1/test/grub2-support_files/grubenv.1 new file mode 100644 index 0000000..88129e2 --- /dev/null +++ b/grubby-8.40-1/test/grub2-support_files/grubenv.1 @@ -0,0 +1,3 @@ +# GRUB Environment Block +saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64 +################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ \ No newline at end of file diff --git a/grubby-8.40-1/test/grub2-support_files/grubenv.2 b/grubby-8.40-1/test/grub2-support_files/grubenv.2 new file mode 100644 index 0000000..5c5e61f --- /dev/null +++ b/grubby-8.40-1/test/grub2-support_files/grubenv.2 @@ -0,0 +1,3 @@ +# GRUB Environment Block +saved_entry=title +##################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################### \ No newline at end of file diff --git a/grubby-8.40-1/test/grub2.1 b/grubby-8.40-1/test/grub2.1 new file mode 100644 index 0000000..fcf053a --- /dev/null +++ b/grubby-8.40-1/test/grub2.1 @@ -0,0 +1,84 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.10 b/grubby-8.40-1/test/grub2.10 new file mode 100644 index 0000000..d010783 --- /dev/null +++ b/grubby-8.40-1/test/grub2.10 @@ -0,0 +1,84 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.11 b/grubby-8.40-1/test/grub2.11 new file mode 100644 index 0000000..820880a --- /dev/null +++ b/grubby-8.40-1/test/grub2.11 @@ -0,0 +1,97 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +set superusers="foo bar baz" + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux16 /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.12 b/grubby-8.40-1/test/grub2.12 new file mode 100644 index 0000000..95a416e --- /dev/null +++ b/grubby-8.40-1/test/grub2.12 @@ -0,0 +1,73 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.2-9.fc15.x86_64.img + devicetree /dtb-2.6.38.2-9.fc15.x86_64/foobarbaz.dtb +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.13 b/grubby-8.40-1/test/grub2.13 new file mode 100644 index 0000000..26ab0a5 --- /dev/null +++ b/grubby-8.40-1/test/grub2.13 @@ -0,0 +1,72 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.14 b/grubby-8.40-1/test/grub2.14 new file mode 100644 index 0000000..cb0304e --- /dev/null +++ b/grubby-8.40-1/test/grub2.14 @@ -0,0 +1,111 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +set pager=1 + +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +terminal_output console +if [ x$feature_timeout_style = xy ] ; then + set timeout_style=menu + set timeout=5 +# Fallback normal timeout code in case the timeout_style feature is +# unavailable. +else + set timeout=5 +fi +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora, with Linux 3.15.0-0.rc5.git2.10.fc21.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 6169b46f-0257-4319-b2e4-caaed2a8e06b + else + search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b + fi + linux16 /vmlinuz-3.15.0-0.rc5.git2.10.fc21.x86_64 root=/dev/mapper/fedora_uefi-root ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/20_ppc_terminfo ### +### END /etc/grub.d/20_ppc_terminfo ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f ${config_directory}/custom.cfg ]; then + source ${config_directory}/custom.cfg +elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### diff --git a/grubby-8.40-1/test/grub2.15 b/grubby-8.40-1/test/grub2.15 new file mode 100644 index 0000000..ab0c2f8 --- /dev/null +++ b/grubby-8.40-1/test/grub2.15 @@ -0,0 +1,111 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +set pager=1 + +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +terminal_output console +if [ x$feature_timeout_style = xy ] ; then + set timeout_style=menu + set timeout=5 +# Fallback normal timeout code in case the timeout_style feature is +# unavailable. +else + set timeout=5 +fi +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora, with Linux 3.15.0-0.rc5.git2.10.fc21.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 6169b46f-0257-4319-b2e4-caaed2a8e06b + else + search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b + fi + linuxefi /vmlinuz-3.15.0-0.rc5.git2.10.fc21.x86_64 root=/dev/mapper/fedora_uefi-root ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/20_ppc_terminfo ### +### END /etc/grub.d/20_ppc_terminfo ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f ${config_directory}/custom.cfg ]; then + source ${config_directory}/custom.cfg +elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### diff --git a/grubby-8.40-1/test/grub2.2 b/grubby-8.40-1/test/grub2.2 new file mode 100644 index 0000000..132664f --- /dev/null +++ b/grubby-8.40-1/test/grub2.2 @@ -0,0 +1,97 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +set superusers="foo bar baz" + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.3 b/grubby-8.40-1/test/grub2.3 new file mode 100644 index 0000000..cd5f611 --- /dev/null +++ b/grubby-8.40-1/test/grub2.3 @@ -0,0 +1,106 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'title2' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.4 b/grubby-8.40-1/test/grub2.4 new file mode 100644 index 0000000..b5d7663 --- /dev/null +++ b/grubby-8.40-1/test/grub2.4 @@ -0,0 +1,108 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +submenu { +menuentry 'title2' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.5 b/grubby-8.40-1/test/grub2.5 new file mode 100644 index 0000000..2d2d749 --- /dev/null +++ b/grubby-8.40-1/test/grub2.5 @@ -0,0 +1,161 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="${saved_entry}" + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if loadfont unicode ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora Linux' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.3.0-0.rc4.git1.4.fc17.x86_64 ...' + linux /vmlinuz-3.3.0-0.rc4.git1.4.fc17.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.3.0-0.rc4.git1.4.fc17.x86_64.img +} +submenu 'Advanced options for Fedora Linux' $menuentry_id_option 'gnulinux-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + menuentry 'Fedora Linux, with Linux 3.3.0-0.rc4.git1.4.fc17.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.3.0-0.rc4.git1.4.fc17.x86_64-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.3.0-0.rc4.git1.4.fc17.x86_64 ...' + linux /vmlinuz-3.3.0-0.rc4.git1.4.fc17.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.3.0-0.rc4.git1.4.fc17.x86_64.img + } + menuentry 'Fedora Linux, with Linux 3.2.9-1.fc16.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.2.9-1.fc16.x86_64-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.2.9-1.fc16.x86_64 ...' + linux /vmlinuz-3.2.9-1.fc16.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.2.9-1.fc16.x86_64.img + } + menuentry 'Fedora Linux, with Linux 3.2.7-1.fc16.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.2.7-1.fc16.x86_64-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.2.7-1.fc16.x86_64 ...' + linux /vmlinuz-3.2.7-1.fc16.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.2.7-1.fc16.x86_64.img + } +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.6 b/grubby-8.40-1/test/grub2.6 new file mode 100644 index 0000000..a8432b1 --- /dev/null +++ b/grubby-8.40-1/test/grub2.6 @@ -0,0 +1,84 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.7 b/grubby-8.40-1/test/grub2.7 new file mode 100644 index 0000000..ee63575 --- /dev/null +++ b/grubby-8.40-1/test/grub2.7 @@ -0,0 +1,130 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if [ x$feature_default_font_path = xy ] ; then + font=unicode +else +insmod part_gpt +insmod btrfs +set root='hd0,gpt4' +if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +else + search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +fi + font="/root/usr/share/grub/unicode.pf2" +fi + +if loadfont $font ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.8 b/grubby-8.40-1/test/grub2.8 new file mode 100644 index 0000000..fd67556 --- /dev/null +++ b/grubby-8.40-1/test/grub2.8 @@ -0,0 +1,142 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if [ x$feature_default_font_path = xy ] ; then + font=unicode +else +insmod part_gpt +insmod btrfs +set root='hd0,gpt4' +if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +else + search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +fi + font="/root/usr/share/grub/unicode.pf2" +fi + +if loadfont $font ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/grub2.9 b/grubby-8.40-1/test/grub2.9 new file mode 100644 index 0000000..d2b7f82 --- /dev/null +++ b/grubby-8.40-1/test/grub2.9 @@ -0,0 +1,142 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if [ x$feature_default_font_path = xy ] ; then + font=unicode +else +insmod part_gpt +insmod btrfs +set root='hd0,gpt4' +if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +else + search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +fi + font="/root/usr/share/grub/unicode.pf2" +fi + +if loadfont $font ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/lilo.1 b/grubby-8.40-1/test/lilo.1 new file mode 100644 index 0000000..799ecf9 --- /dev/null +++ b/grubby-8.40-1/test/lilo.1 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/lilo.2 b/grubby-8.40-1/test/lilo.2 new file mode 100644 index 0000000..4c6cb5a --- /dev/null +++ b/grubby-8.40-1/test/lilo.2 @@ -0,0 +1,27 @@ +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +prompt +timeout=50 +linear +compact +default=linux +message=/boot/message + +image=/boot/vmlinuz-2.4.9-31smp + label=linux + initrd=/boot/initrd-2.4.9-31smp.img + read-only + root=/dev/md3 + +image=/boot/vmlinuz-2.4.9-21 + label=linux-up + initrd=/boot/initrd-2.4.9-21.img + read-only + root=/dev/md3 + +image=/boot/vmlinuz-2.4.7-10 + label=linux-up-old + initrd=/boot/initrd-2.4.7-10.img + read-only + root=/dev/md3 diff --git a/grubby-8.40-1/test/lilo.3 b/grubby-8.40-1/test/lilo.3 new file mode 100644 index 0000000..1c2a5e6 --- /dev/null +++ b/grubby-8.40-1/test/lilo.3 @@ -0,0 +1,34 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/hda1 + read-only + initrd=/boot/initrd-2.4.18-4.img + append="hda=ide-scsi" + +image=/boot/vmlinuz-2.4.18-4 + label=single + root=/dev/hda1 + read-only + append="single hda=ide-scsi" + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/hda2 + read-only + initrd=/boot/initrd-2.4.18-4smp.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/hda2 + read-only + append = " single hda=ide-scsi " + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/lilo.4 b/grubby-8.40-1/test/lilo.4 new file mode 100644 index 0000000..24dfa4e --- /dev/null +++ b/grubby-8.40-1/test/lilo.4 @@ -0,0 +1,18 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +image=/boot/vmlinuz-2.4.18-4 + label=linux + root=/dev/hda1 + read-only + initrd=/boot/initrd-2.4.18-4.img + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/lilo.5 b/grubby-8.40-1/test/lilo.5 new file mode 100644 index 0000000..b52a8b3 --- /dev/null +++ b/grubby-8.40-1/test/lilo.5 @@ -0,0 +1,19 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear +default=DOS + +image=/boot/vmlinuz-2.4.18-4 + label=linux + root=/dev/hda1 + read-only + initrd=/boot/initrd-2.4.18-4.img + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/lilo.6 b/grubby-8.40-1/test/lilo.6 new file mode 100644 index 0000000..b809a26 --- /dev/null +++ b/grubby-8.40-1/test/lilo.6 @@ -0,0 +1,18 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +image=/boot/vmlinuz-2.4.18-4 + label=linux + read-only + initrd=/boot/initrd-2.4.18-4.img + append="root=LABEL=/" + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/lilo.7 b/grubby-8.40-1/test/lilo.7 new file mode 100644 index 0000000..35c1f75 --- /dev/null +++ b/grubby-8.40-1/test/lilo.7 @@ -0,0 +1,31 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-longtitl1 + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4 + label=linux-longtitle + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/add/extlinux1.1 b/grubby-8.40-1/test/results/add/extlinux1.1 new file mode 100644 index 0000000..f81a7ed --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux1.1 @@ -0,0 +1,20 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label title +kernel /boot/new-kernel.img +initrd /boot/new-initrd +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/add/extlinux1.2 b/grubby-8.40-1/test/results/add/extlinux1.2 new file mode 100644 index 0000000..71e0437 --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux1.2 @@ -0,0 +1,20 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label title +kernel /new-kernel.img +initrd /new-initrd +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/add/extlinux1.3 b/grubby-8.40-1/test/results/add/extlinux1.3 new file mode 100644 index 0000000..9634025 --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux1.3 @@ -0,0 +1,21 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label title +kernel /boot/new-kernel.img +append ro root=/dev/sda1 +initrd /boot/new-initrd +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/add/extlinux1.4 b/grubby-8.40-1/test/results/add/extlinux1.4 new file mode 100644 index 0000000..aa1ce63 --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux1.4 @@ -0,0 +1,21 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label title +kernel /new-kernel.img +append ro root=/dev/sda1 +initrd /new-initrd +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/add/extlinux2.1 b/grubby-8.40-1/test/results/add/extlinux2.1 new file mode 100644 index 0000000..13a4179 --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux2.1 @@ -0,0 +1,21 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/hda5 hdd=ide-scsi +initrd /initrd-3.12.0-2.fc21.i686-new.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/add/extlinux5.1 b/grubby-8.40-1/test/results/add/extlinux5.1 new file mode 100644 index 0000000..5e97883 --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux5.1 @@ -0,0 +1,21 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide) + +label Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl +fdt /dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/imx6q-cubox-i.dtb +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img + +label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl +fdt /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/imx6q-cubox-i.dtb +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img + diff --git a/grubby-8.40-1/test/results/add/extlinux6.1 b/grubby-8.40-1/test/results/add/extlinux6.1 new file mode 100644 index 0000000..ec2a2ea --- /dev/null +++ b/grubby-8.40-1/test/results/add/extlinux6.1 @@ -0,0 +1,21 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide) + +label Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl +fdtdir /dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/ +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img + +label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide) +kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl +fdtdir /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/ +append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8 +initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img + diff --git a/grubby-8.40-1/test/results/add/g1.1 b/grubby-8.40-1/test/results/add/g1.1 new file mode 100644 index 0000000..1604591 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.1 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + kernel /boot/new-kernel.img + initrd /boot/new-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g1.2 b/grubby-8.40-1/test/results/add/g1.2 new file mode 100644 index 0000000..d175476 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.2 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + kernel /new-kernel.img + initrd /new-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g1.3 b/grubby-8.40-1/test/results/add/g1.3 new file mode 100644 index 0000000..8fd487f --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.3 @@ -0,0 +1,20 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + root (hd0,0) + kernel /boot/new-kernel.img ro root=/dev/sda1 + initrd /boot/new-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g1.4 b/grubby-8.40-1/test/results/add/g1.4 new file mode 100644 index 0000000..b62b154 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.4 @@ -0,0 +1,20 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + root (hd0,0) + kernel /new-kernel.img ro root=/dev/sda1 + initrd /new-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g1.5 b/grubby-8.40-1/test/results/add/g1.5 new file mode 100644 index 0000000..6301338 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.5 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + kernel /boot/new-kernel.img + initrd /boot/new-initrd /boot/extra-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g1.6 b/grubby-8.40-1/test/results/add/g1.6 new file mode 100644 index 0000000..69189f5 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.6 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + kernel /new-kernel.img + initrd /new-initrd /extra-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g1.7 b/grubby-8.40-1/test/results/add/g1.7 new file mode 100644 index 0000000..dc77c0f --- /dev/null +++ b/grubby-8.40-1/test/results/add/g1.7 @@ -0,0 +1,97 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a partition. This means that +# all kernel and initrd paths are relative to /, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/d2/root +# initrd /initrd-version.img +#boot=/dev/hda +timeout=5 +splashimage=(hd0,0)/grub/splash.xpm.gz +default=0 +hiddenmenu +title Fedora (4.0.0-0.rc4.git1.4.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc4.git1.4.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc4.git1.4.fc23.x86_64.img +title Fedora (4.0.0-0.rc4.git0.1.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc4.git0.1.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc4.git0.1.fc23.x86_64.img +title Fedora (4.0.0-0.rc1.git1.2.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc1.git1.2.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc1.git1.2.fc23.x86_64.img +title Fedora (4.0.0-0.rc1.git0.1.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-4.0.0-0.rc1.git0.1.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-4.0.0-0.rc1.git0.1.fc23.x86_64.img +title Fedora (3.20.0-0.rc0.git9.2.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.20.0-0.rc0.git9.2.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.20.0-0.rc0.git9.2.fc23.x86_64.img +title Fedora (3.20.0-0.rc0.git6.2.fc23.x86_64) 23 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.20.0-0.rc0.git6.2.fc23.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.20.0-0.rc0.git6.2.fc23.x86_64.img +title Fedora (3.19.0-1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-1.fc22.x86_64.img +title Fedora (3.19.0-0.rc7.git1.2.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc7.git1.2.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc7.git1.2.fc22.x86_64.img +title Fedora (3.19.0-0.rc7.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc7.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc7.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc6.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc6.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc6.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc5.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc5.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc5.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc4.git2.2.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc4.git2.2.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc4.git2.2.fc22.x86_64.img +title Fedora (3.19.0-0.rc4.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc4.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc4.git0.1.fc22.x86_64.img +title Fedora (3.19.0-0.rc3.git0.1.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.19.0-0.rc3.git0.1.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.19.0-0.rc3.git0.1.fc22.x86_64.img +title Fedora (3.18.1-2.fc22.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.18.1-2.fc22.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.18.1-2.fc22.x86_64.img +title Fedora (3.17.1-302.fc21.x86_64) 22 (Rawhide) + root (hd0,0) + kernel /vmlinuz-3.17.1-302.fc21.x86_64 ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-3.17.1-302.fc21.x86_64.img +title Fedora 20 Rescue 4b741960432e833443a6bc004563501d (3.10.0-0.rc4.git0.1.fc20.x86_64) + root (hd0,0) + kernel /vmlinuz-0-rescue-4b741960432e833443a6bc004563501d ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-0-rescue-4b741960432e833443a6bc004563501d.img +title Fedora 20 Rescue 4b741960432e833443a6bc004563501d (3.9.0-0.rc4.git0.1.fc20.x86_64) + root (hd0,0) + kernel /vmlinuz-0-rescue-4b741960432e833443a6bc004563501d ro root=/dev/sda1 SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us rd_plytheme=charge + initrd /initramfs-0-rescue-4b741960432e833443a6bc004563501d.img +title Memtest86+ (4.20) + root (hd0,0) + kernel /elf-memtest86+-4.20 +title Fedora (2.6.29.5-191.fc11.x86_64) + root (hd0,0) + kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/d2/rescue64 + initrd /initrd-2.6.29.5-191.fc11.x86_64.img +title install + kernel /f10vz + initrd /f10ird.img +title gittest + kernel /gittest diff --git a/grubby-8.40-1/test/results/add/g11.1 b/grubby-8.40-1/test/results/add/g11.1 new file mode 100644 index 0000000..042e96e --- /dev/null +++ b/grubby-8.40-1/test/results/add/g11.1 @@ -0,0 +1,13 @@ +#boot=/dev/hda +timeout=10 +default=1 +splashimage=(hd0,1)/grub/splash.xpm.gz +title title + kernel (hd0,1)/new-kernel.img ro root=/dev/hda5 hdd=ide-scsi console=tty0 console=ttyS1,9600n81 single + initrd (hd0,1)/new-initrd +title Red Hat Linux (2.4.7-2smp) + kernel (hd0,1)/vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi console=tty0 console=ttyS0,9600n81 + initrd (hd0,1)/initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + kernel (hd0,1)/vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g2-1.1 b/grubby-8.40-1/test/results/add/g2-1.1 new file mode 100644 index 0000000..ea17971 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.1 @@ -0,0 +1,96 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.10 b/grubby-8.40-1/test/results/add/g2-1.10 new file mode 100644 index 0000000..bb2c71c --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.10 @@ -0,0 +1,96 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux16 /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.11 b/grubby-8.40-1/test/results/add/g2-1.11 new file mode 100644 index 0000000..a11cb41 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.11 @@ -0,0 +1,98 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +set superusers="foo bar baz" + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux16 /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /new-initrd +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux16 /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd16 /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.12 b/grubby-8.40-1/test/results/add/g2-1.12 new file mode 100644 index 0000000..85bfb7b --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.12 @@ -0,0 +1,86 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux, with Fedora 2.6.38.8-32.fc15.x86_64' + linuxefi /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.8-32.fc15.x86_64.img + devicetree /dtb-2.6.38.8-32.fc15.x86_64/foobarbaz.dtb +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.2-9.fc15.x86_64.img + devicetree /dtb-2.6.38.2-9.fc15.x86_64/foobarbaz.dtb +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.13 b/grubby-8.40-1/test/results/add/g2-1.13 new file mode 100644 index 0000000..b4e62b5 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.13 @@ -0,0 +1,85 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux, with Fedora 2.6.38.8-32.fc15.x86_64' + linuxefi /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.8-32.fc15.x86_64.img + devicetree /dtb-2.6.38.8-32.fc15.x86_64/foobarbaz.dtb +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.14 b/grubby-8.40-1/test/results/add/g2-1.14 new file mode 100644 index 0000000..0865bbc --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.14 @@ -0,0 +1,126 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +set pager=1 + +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +terminal_output console +if [ x$feature_timeout_style = xy ] ; then + set timeout_style=menu + set timeout=5 +# Fallback normal timeout code in case the timeout_style feature is +# unavailable. +else + set timeout=5 +fi +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora 21 Rescue' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 6169b46f-0257-4319-b2e4-caaed2a8e06b + else + search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b + fi + linux16 /vmlinuz-0-rescue-5a94251776a14678911d4ae0949500f5 root=/fooooo ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet + initrd16 /initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img +} +menuentry 'Fedora, with Linux 3.15.0-0.rc5.git2.10.fc21.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 6169b46f-0257-4319-b2e4-caaed2a8e06b + else + search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b + fi + linux16 /vmlinuz-3.15.0-0.rc5.git2.10.fc21.x86_64 root=/dev/mapper/fedora_uefi-root ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/20_ppc_terminfo ### +### END /etc/grub.d/20_ppc_terminfo ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f ${config_directory}/custom.cfg ]; then + source ${config_directory}/custom.cfg +elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### diff --git a/grubby-8.40-1/test/results/add/g2-1.15 b/grubby-8.40-1/test/results/add/g2-1.15 new file mode 100644 index 0000000..b67c373 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.15 @@ -0,0 +1,126 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +set pager=1 + +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +terminal_output console +if [ x$feature_timeout_style = xy ] ; then + set timeout_style=menu + set timeout=5 +# Fallback normal timeout code in case the timeout_style feature is +# unavailable. +else + set timeout=5 +fi +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora 21 Rescue' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 6169b46f-0257-4319-b2e4-caaed2a8e06b + else + search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b + fi + linuxefi /vmlinuz-0-rescue-5a94251776a14678911d4ae0949500f5 root=/fooooo ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet + initrdefi /initramfs-0-rescue-5a94251776a14678911d4ae0949500f5.img +} +menuentry 'Fedora, with Linux 3.15.0-0.rc5.git2.10.fc21.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.15.0-0.rc5.git2.10.fc21.x86_64-advanced-a14e3dcb-ade3-42f7-832f-d9f66b5ae6a3' { + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 6169b46f-0257-4319-b2e4-caaed2a8e06b + else + search --no-floppy --fs-uuid --set=root 6169b46f-0257-4319-b2e4-caaed2a8e06b + fi + linuxefi /vmlinuz-3.15.0-0.rc5.git2.10.fc21.x86_64 root=/dev/mapper/fedora_uefi-root ro rd.lvm.lv=fedora_uefi/root rd.lvm.lv=fedora_uefi/swap rhgb quiet +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/20_ppc_terminfo ### +### END /etc/grub.d/20_ppc_terminfo ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f ${config_directory}/custom.cfg ]; then + source ${config_directory}/custom.cfg +elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### diff --git a/grubby-8.40-1/test/results/add/g2-1.2 b/grubby-8.40-1/test/results/add/g2-1.2 new file mode 100644 index 0000000..b1e96c6 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.2 @@ -0,0 +1,96 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.3 b/grubby-8.40-1/test/results/add/g2-1.3 new file mode 100644 index 0000000..8c3a2f6 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.3 @@ -0,0 +1,95 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.4 b/grubby-8.40-1/test/results/add/g2-1.4 new file mode 100644 index 0000000..c67a044 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.4 @@ -0,0 +1,98 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +set superusers="foo bar baz" + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.5 b/grubby-8.40-1/test/results/add/g2-1.5 new file mode 100644 index 0000000..ae48f8e --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.5 @@ -0,0 +1,179 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="${saved_entry}" + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if loadfont unicode ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Fedora Linux' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.3.0-0.rc4.git1.4.fc17.x86_64 ...' + linux /vmlinuz-3.3.0-0.rc4.git1.4.fc17.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.3.0-0.rc4.git1.4.fc17.x86_64.img +} +submenu 'Advanced options for Fedora Linux' $menuentry_id_option 'gnulinux-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + menuentry 'Fedora Linux, with Linux 3.3.0-0.rc4.git1.4.fc17.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.3.0-0.rc4.git1.4.fc17.x86_64-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.3.0-0.rc4.git1.4.fc17.x86_64 ...' + linux /vmlinuz-3.3.0-0.rc4.git1.4.fc17.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.3.0-0.rc4.git1.4.fc17.x86_64.img + } + menuentry 'Fedora Linux, with Linux 3.2.9-1.fc16.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.2.9-1.fc16.x86_64-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.2.9-1.fc16.x86_64 ...' + linux /vmlinuz-3.2.9-1.fc16.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.2.9-1.fc16.x86_64.img + } + menuentry 'Fedora Linux, with Linux 3.2.7-1.fc16.x86_64' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.2.7-1.fc16.x86_64-advanced-fe7b6773-70ed-4eac-b323-16ed459c7f86' { + savedefault + load_video + set gfxpayload=keep + insmod gzio + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' df0170c9-7d05-415c-bbd1-d4d503ba0eed + else + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + fi + echo 'Loading Linux 3.2.7-1.fc16.x86_64 ...' + linux /vmlinuz-3.2.7-1.fc16.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-3.2.7-1.fc16.x86_64.img + } +} + +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### + +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.6 b/grubby-8.40-1/test/results/add/g2-1.6 new file mode 100644 index 0000000..35fbacc --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.6 @@ -0,0 +1,96 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linuxefi /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.7 b/grubby-8.40-1/test/results/add/g2-1.7 new file mode 100644 index 0000000..0d73b92 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.7 @@ -0,0 +1,96 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linuxefi /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linuxefi /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrdefi /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.8 b/grubby-8.40-1/test/results/add/g2-1.8 new file mode 100644 index 0000000..fd67556 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.8 @@ -0,0 +1,142 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if [ x$feature_default_font_path = xy ] ; then + font=unicode +else +insmod part_gpt +insmod btrfs +set root='hd0,gpt4' +if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +else + search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +fi + font="/root/usr/share/grub/unicode.pf2" +fi + +if loadfont $font ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2-1.9 b/grubby-8.40-1/test/results/add/g2-1.9 new file mode 100644 index 0000000..d2b7f82 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2-1.9 @@ -0,0 +1,142 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="${saved_entry}" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + if [ x$feature_all_video_module = xy ]; then + insmod all_video + else + insmod efi_gop + insmod efi_uga + insmod ieee1275_fb + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus + fi +} + +if [ x$feature_default_font_path = xy ] ; then + font=unicode +else +insmod part_gpt +insmod btrfs +set root='hd0,gpt4' +if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +else + search --no-floppy --fs-uuid --set=root 5a2ca487-30f7-4fa5-96bd-abe38b68ceb3 +fi + font="/root/usr/share/grub/unicode.pf2" +fi + +if loadfont $font ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_US + insmod gettext +fi +terminal_output gfxterm +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora (3.10.3-300.fc19.x86_64) 19 (Schrödinger’s Cat)' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /new-initrd +} +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/add/g2.1 b/grubby-8.40-1/test/results/add/g2.1 new file mode 100644 index 0000000..6cb3659 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g2.1 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/hda5 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-new.img +title DOS + rootnoverify (hd0,1) + chainloader +1 diff --git a/grubby-8.40-1/test/results/add/g8.1 b/grubby-8.40-1/test/results/add/g8.1 new file mode 100644 index 0000000..a1c3352 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g8.1 @@ -0,0 +1,20 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + root (hd0,7) + kernel (hd0,0)/new-kernel.img ro root=/dev/sda1 + initrd (hd0,0)/new-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,7) + kernel (hd0,0)/vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd (hd0,0)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/g8.2 b/grubby-8.40-1/test/results/add/g8.2 new file mode 100644 index 0000000..c998899 --- /dev/null +++ b/grubby-8.40-1/test/results/add/g8.2 @@ -0,0 +1,20 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title title + root (hd0,7) + kernel (hd0,0)/new-kernel.img ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 single + initrd (hd0,0)/new-initrd +title Red Hat Linux (2.4.7-2) + root (hd0,7) + kernel (hd0,0)/vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd (hd0,0)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/add/l4.1 b/grubby-8.40-1/test/results/add/l4.1 new file mode 100644 index 0000000..f460072 --- /dev/null +++ b/grubby-8.40-1/test/results/add/l4.1 @@ -0,0 +1,24 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +default=linux +image=/boot/new-kernel.img + label=title + root=/dev/hda1 + read-only + +image=/boot/vmlinuz-2.4.18-4 + label=linux + root=/dev/hda1 + read-only + initrd=/boot/initrd-2.4.18-4.img + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/results/add/l4.2 b/grubby-8.40-1/test/results/add/l4.2 new file mode 100644 index 0000000..caf5034 --- /dev/null +++ b/grubby-8.40-1/test/results/add/l4.2 @@ -0,0 +1,17 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +image=/boot/new-kernel.img + label=linux + root=/dev/hda1 + read-only + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/results/add/l5.1 b/grubby-8.40-1/test/results/add/l5.1 new file mode 100644 index 0000000..1c52040 --- /dev/null +++ b/grubby-8.40-1/test/results/add/l5.1 @@ -0,0 +1,24 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear +default=DOS + +image=/boot/new-kernel.img + label=title + root=/dev/hda1 + read-only + +image=/boot/vmlinuz-2.4.18-4 + label=linux + root=/dev/hda1 + read-only + initrd=/boot/initrd-2.4.18-4.img + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/results/add/l5.2 b/grubby-8.40-1/test/results/add/l5.2 new file mode 100644 index 0000000..8489bba --- /dev/null +++ b/grubby-8.40-1/test/results/add/l5.2 @@ -0,0 +1,18 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear +default=DOS + +image=/boot/new-kernel.img + label=linux + root=/dev/hda1 + read-only + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/results/add/l6.1 b/grubby-8.40-1/test/results/add/l6.1 new file mode 100644 index 0000000..2465cc2 --- /dev/null +++ b/grubby-8.40-1/test/results/add/l6.1 @@ -0,0 +1,25 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +default=linux +image=/boot/new-kernel.img + label=title + read-only + initrd=/boot/new-initrd + append="root=LABEL=/" + +image=/boot/vmlinuz-2.4.18-4 + label=linux + read-only + initrd=/boot/initrd-2.4.18-4.img + append="root=LABEL=/" + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/results/add/l6.2 b/grubby-8.40-1/test/results/add/l6.2 new file mode 100644 index 0000000..89a14cf --- /dev/null +++ b/grubby-8.40-1/test/results/add/l6.2 @@ -0,0 +1,18 @@ +prompt +timeout=50 +boot=/dev/hda +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +image=/boot/new-kernel.img + label=linux + read-only + initrd=/boot/new-initrd + append="root=LABEL=/" + +other=/dev/hda2 + label=DOS + optional + diff --git a/grubby-8.40-1/test/results/add/y1.1 b/grubby-8.40-1/test/results/add/y1.1 new file mode 100644 index 0000000..6b68977 --- /dev/null +++ b/grubby-8.40-1/test/results/add/y1.1 @@ -0,0 +1,37 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 +macosx=path-to-macos + +image=/boot/new-kernel + label=newtitle + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/zImage-2.4.20 + label=test + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinux-2.5.50 + label=25 + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" + +image=/boot/vmlinuz-2.5.50-eepro + label=25eepro + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" diff --git a/grubby-8.40-1/test/results/add/y1.2 b/grubby-8.40-1/test/results/add/y1.2 new file mode 100644 index 0000000..9700f00 --- /dev/null +++ b/grubby-8.40-1/test/results/add/y1.2 @@ -0,0 +1,33 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 +macosx=path-to-macos + +image=/boot/new-kernel + label=newtitle +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/zImage-2.4.20 + label=test + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinux-2.5.50 + label=25 + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" + +image=/boot/vmlinuz-2.5.50-eepro + label=25eepro + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" diff --git a/grubby-8.40-1/test/results/add/y3.1 b/grubby-8.40-1/test/results/add/y3.1 new file mode 100644 index 0000000..764f782 --- /dev/null +++ b/grubby-8.40-1/test/results/add/y3.1 @@ -0,0 +1,14 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 + +image=/boot/new-kernel + label=newtitle +image=/boot/vmlinux-2.4.9-23.19.8 + label=test + read-only + root=/dev/sda2 diff --git a/grubby-8.40-1/test/results/add/z1.1 b/grubby-8.40-1/test/results/add/z1.1 new file mode 100644 index 0000000..5e14958 --- /dev/null +++ b/grubby-8.40-1/test/results/add/z1.1 @@ -0,0 +1,14 @@ +[defaultboot] +default=linux +[test] + image=/boot/new-kernel.img +[linux] + target=/boot/ + image=/boot/vmlinuz-2.4.9-37 + ramdisk=/boot/initrd-2.4.9-37.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" +[linux2] + target=/boot/ + image=/boot/vmlinuz-2.4.9-38 + ramdisk=/boot/initrd-2.4.9-38.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/test/results/add/z1.2 b/grubby-8.40-1/test/results/add/z1.2 new file mode 100644 index 0000000..d532823 --- /dev/null +++ b/grubby-8.40-1/test/results/add/z1.2 @@ -0,0 +1,16 @@ +[defaultboot] +default=linux +[test] + target=/boot/ + image=/boot/new-kernel.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" +[linux] + target=/boot/ + image=/boot/vmlinuz-2.4.9-37 + ramdisk=/boot/initrd-2.4.9-37.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" +[linux2] + target=/boot/ + image=/boot/vmlinuz-2.4.9-38 + ramdisk=/boot/initrd-2.4.9-38.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/test/results/args/extlinux1.1 b/grubby-8.40-1/test/results/args/extlinux1.1 new file mode 100644 index 0000000..2d8c800 --- /dev/null +++ b/grubby-8.40-1/test/results/args/extlinux1.1 @@ -0,0 +1,20 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label some_title +kernel /foo +append ro root=/dev/sda1 1234 +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/args/extlinux1.2 b/grubby-8.40-1/test/results/args/extlinux1.2 new file mode 100644 index 0000000..41cc324 --- /dev/null +++ b/grubby-8.40-1/test/results/args/extlinux1.2 @@ -0,0 +1,20 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label some_title +kernel /foo +append 1234 +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/args/g1.1 b/grubby-8.40-1/test/results/args/g1.1 new file mode 100644 index 0000000..54c1f5d --- /dev/null +++ b/grubby-8.40-1/test/results/args/g1.1 @@ -0,0 +1,19 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title some_title + root (hd0,0) + kernel /foo ro root=/dev/sda1 1234 +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/args/g1.2 b/grubby-8.40-1/test/results/args/g1.2 new file mode 100644 index 0000000..e9cc9fa --- /dev/null +++ b/grubby-8.40-1/test/results/args/g1.2 @@ -0,0 +1,18 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title some_title + kernel /foo 1234 +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/debug/g2.1 b/grubby-8.40-1/test/results/debug/g2.1 new file mode 100644 index 0000000..f5187f5 --- /dev/null +++ b/grubby-8.40-1/test/results/debug/g2.1 @@ -0,0 +1,14 @@ +DBG: command line: --grub2 --env=test/grub2-support_files/env_temp -c test/grub2.1 --boot-filesystem=/boot --default-kernel --debug +DBG: Image entry failed: access to /boot/vmlinuz-2.6.38.8-32.fc15.x86_64 failed +DBG: menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { +DBG: load_video +DBG: set gfxpayload=keep +DBG: insmod part_msdos +DBG: insmod ext2 +DBG: set root='(hd0,msdos1)' +DBG: search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed +DBG: echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' +DBG: linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb +DBG: echo 'Loading initial ramdisk ...' +DBG: initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +DBG: } diff --git a/grubby-8.40-1/test/results/debug/g2.1.2 b/grubby-8.40-1/test/results/debug/g2.1.2 new file mode 100644 index 0000000..75f2970 --- /dev/null +++ b/grubby-8.40-1/test/results/debug/g2.1.2 @@ -0,0 +1 @@ +/boot/vmlinuz-2.6.38.8-32.fc15.x86_64 diff --git a/grubby-8.40-1/test/results/default/extlinux1.1 b/grubby-8.40-1/test/results/default/extlinux1.1 new file mode 100644 index 0000000..5d7f73d --- /dev/null +++ b/grubby-8.40-1/test/results/default/extlinux1.1 @@ -0,0 +1,19 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label Some_Title +kernel /new-kernel +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/default/extlinux1.2 b/grubby-8.40-1/test/results/default/extlinux1.2 new file mode 100644 index 0000000..e98ff12 --- /dev/null +++ b/grubby-8.40-1/test/results/default/extlinux1.2 @@ -0,0 +1,19 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Some_Title + +label Some_Title +kernel /new-kernel +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/default/extlinux3.1 b/grubby-8.40-1/test/results/default/extlinux3.1 new file mode 100644 index 0000000..5a5495d --- /dev/null +++ b/grubby-8.40-1/test/results/default/extlinux3.1 @@ -0,0 +1,16 @@ +prompt 0 + +default=Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/default/extlinux3.2 b/grubby-8.40-1/test/results/default/extlinux3.2 new file mode 100644 index 0000000..63f97bf --- /dev/null +++ b/grubby-8.40-1/test/results/default/extlinux3.2 @@ -0,0 +1,15 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/default/g1.1 b/grubby-8.40-1/test/results/default/g1.1 new file mode 100644 index 0000000..527bfd3 --- /dev/null +++ b/grubby-8.40-1/test/results/default/g1.1 @@ -0,0 +1,18 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Some_Title + kernel /new-kernel +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/default/g1.2 b/grubby-8.40-1/test/results/default/g1.2 new file mode 100644 index 0000000..993c7d3 --- /dev/null +++ b/grubby-8.40-1/test/results/default/g1.2 @@ -0,0 +1,18 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Some_Title + kernel /new-kernel +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/default/g3.1 b/grubby-8.40-1/test/results/default/g3.1 new file mode 100644 index 0000000..e7e17be --- /dev/null +++ b/grubby-8.40-1/test/results/default/g3.1 @@ -0,0 +1,17 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +default=1 +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/default/g3.2 b/grubby-8.40-1/test/results/default/g3.2 new file mode 100644 index 0000000..7d50bb8 --- /dev/null +++ b/grubby-8.40-1/test/results/default/g3.2 @@ -0,0 +1,16 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/default/g4.1 b/grubby-8.40-1/test/results/default/g4.1 new file mode 100644 index 0000000..7942bf2 --- /dev/null +++ b/grubby-8.40-1/test/results/default/g4.1 @@ -0,0 +1,20 @@ +default=1 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.9 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.9.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/default/g4.2 b/grubby-8.40-1/test/results/default/g4.2 new file mode 100644 index 0000000..ecdbc4c --- /dev/null +++ b/grubby-8.40-1/test/results/default/g4.2 @@ -0,0 +1,24 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title New_Title + root (hd0,5) + kernel /boot/new-kernel ro root=/dev/hda6 + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.9 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.9.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/default/g6.1 b/grubby-8.40-1/test/results/default/g6.1 new file mode 100644 index 0000000..3da34f1 --- /dev/null +++ b/grubby-8.40-1/test/results/default/g6.1 @@ -0,0 +1,20 @@ +default=1 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/default/l1.1 b/grubby-8.40-1/test/results/default/l1.1 new file mode 100644 index 0000000..f6401db --- /dev/null +++ b/grubby-8.40-1/test/results/default/l1.1 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=linux-up +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/default/l1.2 b/grubby-8.40-1/test/results/default/l1.2 new file mode 100644 index 0000000..6458bd5 --- /dev/null +++ b/grubby-8.40-1/test/results/default/l1.2 @@ -0,0 +1,20 @@ +prompt +timeout=50 +default=linux-up +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + diff --git a/grubby-8.40-1/test/results/default/l1.3 b/grubby-8.40-1/test/results/default/l1.3 new file mode 100644 index 0000000..7339686 --- /dev/null +++ b/grubby-8.40-1/test/results/default/l1.3 @@ -0,0 +1,29 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/kernel + label=label + root=/dev/md0 + read-only +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/default/l1.4 b/grubby-8.40-1/test/results/default/l1.4 new file mode 100644 index 0000000..ce725cd --- /dev/null +++ b/grubby-8.40-1/test/results/default/l1.4 @@ -0,0 +1,29 @@ +prompt +timeout=50 +default=label +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/kernel + label=label + root=/dev/md0 + read-only +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/default/z1.1 b/grubby-8.40-1/test/results/default/z1.1 new file mode 100644 index 0000000..e0afa86 --- /dev/null +++ b/grubby-8.40-1/test/results/default/z1.1 @@ -0,0 +1,14 @@ +[defaultboot] +default=linux +[test] + image=/boot/new-kernel +[linux] + target=/boot/ + image=/boot/vmlinuz-2.4.9-37 + ramdisk=/boot/initrd-2.4.9-37.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" +[linux2] + target=/boot/ + image=/boot/vmlinuz-2.4.9-38 + ramdisk=/boot/initrd-2.4.9-38.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/test/results/default/z1.2 b/grubby-8.40-1/test/results/default/z1.2 new file mode 100644 index 0000000..4c7dbad --- /dev/null +++ b/grubby-8.40-1/test/results/default/z1.2 @@ -0,0 +1,14 @@ +[defaultboot] +default=test +[test] + image=/boot/new-kernel +[linux] + target=/boot/ + image=/boot/vmlinuz-2.4.9-37 + ramdisk=/boot/initrd-2.4.9-37.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" +[linux2] + target=/boot/ + image=/boot/vmlinuz-2.4.9-38 + ramdisk=/boot/initrd-2.4.9-38.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/test/results/defaultindex/0 b/grubby-8.40-1/test/results/defaultindex/0 new file mode 100644 index 0000000..573541a --- /dev/null +++ b/grubby-8.40-1/test/results/defaultindex/0 @@ -0,0 +1 @@ +0 diff --git a/grubby-8.40-1/test/results/defaultindex/1 b/grubby-8.40-1/test/results/defaultindex/1 new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/grubby-8.40-1/test/results/defaultindex/1 @@ -0,0 +1 @@ +1 diff --git a/grubby-8.40-1/test/results/defaultindex/2 b/grubby-8.40-1/test/results/defaultindex/2 new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/grubby-8.40-1/test/results/defaultindex/2 @@ -0,0 +1 @@ +2 diff --git a/grubby-8.40-1/test/results/defaulttitle/g.1 b/grubby-8.40-1/test/results/defaulttitle/g.1 new file mode 100644 index 0000000..1ae63f2 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.1 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.10 b/grubby-8.40-1/test/results/defaulttitle/g.10 new file mode 100644 index 0000000..1be72f4 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.10 @@ -0,0 +1 @@ +xen diff --git a/grubby-8.40-1/test/results/defaulttitle/g.11 b/grubby-8.40-1/test/results/defaulttitle/g.11 new file mode 100644 index 0000000..ed80cb1 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.11 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2smp) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.2 b/grubby-8.40-1/test/results/defaulttitle/g.2 new file mode 100644 index 0000000..1ae63f2 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.2 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.3 b/grubby-8.40-1/test/results/defaulttitle/g.3 new file mode 100644 index 0000000..ed80cb1 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.3 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2smp) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.4 b/grubby-8.40-1/test/results/defaulttitle/g.4 new file mode 100644 index 0000000..7efb93f --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.4 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2.9) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.5 b/grubby-8.40-1/test/results/defaulttitle/g.5 new file mode 100644 index 0000000..5c69edc --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.5 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2.5) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.6 b/grubby-8.40-1/test/results/defaulttitle/g.6 new file mode 100644 index 0000000..3a71c0a --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.6 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-ac3) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.7 b/grubby-8.40-1/test/results/defaulttitle/g.7 new file mode 100644 index 0000000..3a71c0a --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.7 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-ac3) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.8 b/grubby-8.40-1/test/results/defaulttitle/g.8 new file mode 100644 index 0000000..1ae63f2 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.8 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2) diff --git a/grubby-8.40-1/test/results/defaulttitle/g.9 b/grubby-8.40-1/test/results/defaulttitle/g.9 new file mode 100644 index 0000000..ed80cb1 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g.9 @@ -0,0 +1 @@ +Red Hat Linux (2.4.7-2smp) diff --git a/grubby-8.40-1/test/results/defaulttitle/g2.1 b/grubby-8.40-1/test/results/defaulttitle/g2.1 new file mode 100644 index 0000000..e8bece2 --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g2.1 @@ -0,0 +1 @@ +Linux, with Fedora 2.6.38.8-32.fc15.x86_64 diff --git a/grubby-8.40-1/test/results/defaulttitle/g2.2 b/grubby-8.40-1/test/results/defaulttitle/g2.2 new file mode 100644 index 0000000..787215d --- /dev/null +++ b/grubby-8.40-1/test/results/defaulttitle/g2.2 @@ -0,0 +1 @@ +title diff --git a/grubby-8.40-1/test/results/fallback/g5.1 b/grubby-8.40-1/test/results/fallback/g5.1 new file mode 100644 index 0000000..a7d4892 --- /dev/null +++ b/grubby-8.40-1/test/results/fallback/g5.1 @@ -0,0 +1,15 @@ +default=0 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/fallback/g5.2 b/grubby-8.40-1/test/results/fallback/g5.2 new file mode 100644 index 0000000..d62eb9d --- /dev/null +++ b/grubby-8.40-1/test/results/fallback/g5.2 @@ -0,0 +1,16 @@ +default=0 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz +fallback=0 + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/fallback/g5.3 b/grubby-8.40-1/test/results/fallback/g5.3 new file mode 100644 index 0000000..9dc3896 --- /dev/null +++ b/grubby-8.40-1/test/results/fallback/g5.3 @@ -0,0 +1,20 @@ +default=0 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz +fallback=1 + +title Some_Title + root (hd0,5) + kernel /boot/new-kernel ro root=/dev/hda6 + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/info/g12.1 b/grubby-8.40-1/test/results/info/g12.1 new file mode 100644 index 0000000..25d7ab6 --- /dev/null +++ b/grubby-8.40-1/test/results/info/g12.1 @@ -0,0 +1,8 @@ +lba +boot=/dev/vda +index=0 +kernel=/boot/vmlinuz-3.1.9-1.4-desktop +args="resume=/dev/vda1 splash=silent quiet showopts vga=0x314" +root=/dev/vda2 +initrd=/boot/initrd-3.1.9-1.4-desktop +title=Desktop -- openSUSE 12.1 - 3.1.9-1.4 diff --git a/grubby-8.40-1/test/results/longtitle/e7.1 b/grubby-8.40-1/test/results/longtitle/e7.1 new file mode 100644 index 0000000..61390b4 --- /dev/null +++ b/grubby-8.40-1/test/results/longtitle/e7.1 @@ -0,0 +1,35 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/new-kernel.img + label=linux-longtitle-fix + root=/dev/md0 + read-only +image=/boot/vmlinuz-2.4.18-4 + label=linux-longtitl1 + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4 + label=linux-longtitle + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/longtitle/l1.1 b/grubby-8.40-1/test/results/longtitle/l1.1 new file mode 100644 index 0000000..074be13 --- /dev/null +++ b/grubby-8.40-1/test/results/longtitle/l1.1 @@ -0,0 +1,29 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/new-kernel.img + label=linux-longtitle + root=/dev/md0 + read-only +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/longtitle/l1.2 b/grubby-8.40-1/test/results/longtitle/l1.2 new file mode 100644 index 0000000..47e6c98 --- /dev/null +++ b/grubby-8.40-1/test/results/longtitle/l1.2 @@ -0,0 +1,29 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/new-kernel.img + label=linux-toolongti + root=/dev/md0 + read-only +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/longtitle/l7.1 b/grubby-8.40-1/test/results/longtitle/l7.1 new file mode 100644 index 0000000..8746042 --- /dev/null +++ b/grubby-8.40-1/test/results/longtitle/l7.1 @@ -0,0 +1,35 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/new-kernel.img + label=linux-longtitl2 + root=/dev/md0 + read-only +image=/boot/vmlinuz-2.4.18-4 + label=linux-longtitl1 + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4 + label=linux-longtitle + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/multiboot/e1.1 b/grubby-8.40-1/test/results/multiboot/e1.1 new file mode 100644 index 0000000..e347ebf --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/e1.1 @@ -0,0 +1,30 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/vmlinuz-2.6.10-1.1088_FC4 + label=foo + vmm=/xen.gz + initrd=/initrd-2.6.10-1.1088_FC4.img + append="dom0_mem=130000 --" +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/multiboot/e1.2 b/grubby-8.40-1/test/results/multiboot/e1.2 new file mode 100644 index 0000000..8d06aa0 --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/e1.2 @@ -0,0 +1,32 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/vmlinuz-2.6.10-1.1088_FC4 + vmm=/xen.gz + label=foo + root=/dev/md0 + read-only + initrd=/initrd-2.6.10-1.1088_FC4.img + append="dom0_mem=130000 --" +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/multiboot/e2.1 b/grubby-8.40-1/test/results/multiboot/e2.1 new file mode 100644 index 0000000..fbf33ca --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/e2.1 @@ -0,0 +1,26 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + vmm=/xen.gz + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/vmlinuz-2.6.10-1.1082_FC4 + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/multiboot/e2.2 b/grubby-8.40-1/test/results/multiboot/e2.2 new file mode 100644 index 0000000..0083089 --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/e2.2 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=foo +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/vmlinuz-2.6.10-1.1076_FC4 + label=foo + initrd=/initrd-2.6.10-1.1088_FC4.img + append="dom0_mem=130000 --" +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + vmm=/xen.gz + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + diff --git a/grubby-8.40-1/test/results/multiboot/e2.3 b/grubby-8.40-1/test/results/multiboot/e2.3 new file mode 100644 index 0000000..523efcf --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/e2.3 @@ -0,0 +1,23 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/vmlinuz-2.6.10-1.1076_FC4 + label=foo + initrd=/initrd-2.6.10-1.1088_FC4.img + append="dom0_mem=130000 --" +image=/vmlinuz-2.6.10-1.1082_FC4 + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/multiboot/g1.1 b/grubby-8.40-1/test/results/multiboot/g1.1 new file mode 100644 index 0000000..9a7edfe --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g1.1 @@ -0,0 +1,20 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title foo + kernel /xen.gz dom0_mem=130000 + module /vmlinuz-2.6.10-1.1088_FC4 + module /initrd-2.6.10-1.1088_FC4.img +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/multiboot/g1.2 b/grubby-8.40-1/test/results/multiboot/g1.2 new file mode 100644 index 0000000..dfe6cdb --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g1.2 @@ -0,0 +1,21 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=1 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title foo + root (hd0,0) + kernel /xen.gz dom0_mem=130000 + module /vmlinuz-2.6.10-1.1088_FC4 ro root=/dev/sda1 + module /initrd-2.6.10-1.1088_FC4.img +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/multiboot/g10.1 b/grubby-8.40-1/test/results/multiboot/g10.1 new file mode 100644 index 0000000..5ad26f5 --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.1 @@ -0,0 +1,14 @@ +default=1 +title foo + kernel /xen.gz dom0_mem=130000 + module /vmlinuz-2.6.10-1.1088_FC4 + module /initrd-2.6.10-1.1088_FC4.img +title xen + root (hd0,1) + kernel /xen.gz + module /vmlinuz-2.6.10-1.1082_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1082_FC4 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/results/multiboot/g10.2 b/grubby-8.40-1/test/results/multiboot/g10.2 new file mode 100644 index 0000000..6a2f7c9 --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.2 @@ -0,0 +1,15 @@ +default=1 +title foo + root (hd0,1) + kernel /xen.gz dom0_mem=130000 + module /vmlinuz-2.6.10-1.1088_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1088_FC4.img +title xen + root (hd0,1) + kernel /xen.gz + module /vmlinuz-2.6.10-1.1082_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1082_FC4 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/results/multiboot/g10.3 b/grubby-8.40-1/test/results/multiboot/g10.3 new file mode 100644 index 0000000..79bd5bb --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.3 @@ -0,0 +1,14 @@ +default=1 +title foo + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1088_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1088_FC4.img +title xen + root (hd0,1) + kernel /xen.gz + module /vmlinuz-2.6.10-1.1082_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1082_FC4 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/results/multiboot/g10.4 b/grubby-8.40-1/test/results/multiboot/g10.4 new file mode 100644 index 0000000..8f636cb --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.4 @@ -0,0 +1,13 @@ +default=1 +title foo + kernel /vmlinuz-2.6.10-1.1088_FC4 + initrd /initrd-2.6.10-1.1088_FC4.img +title xen + root (hd0,1) + kernel /xen.gz + module /vmlinuz-2.6.10-1.1082_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1082_FC4 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/results/multiboot/g10.5 b/grubby-8.40-1/test/results/multiboot/g10.5 new file mode 100644 index 0000000..9602cbe --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.5 @@ -0,0 +1,6 @@ +default=0 +title xen + root (hd0,1) + kernel /xen.gz + module /vmlinuz-2.6.10-1.1082_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + module /initrd-2.6.10-1.1082_FC4 diff --git a/grubby-8.40-1/test/results/multiboot/g10.6 b/grubby-8.40-1/test/results/multiboot/g10.6 new file mode 100644 index 0000000..3f13ece --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.6 @@ -0,0 +1,5 @@ +default=0 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/results/multiboot/g10.7 b/grubby-8.40-1/test/results/multiboot/g10.7 new file mode 100644 index 0000000..3f13ece --- /dev/null +++ b/grubby-8.40-1/test/results/multiboot/g10.7 @@ -0,0 +1,5 @@ +default=0 +title Fedora Core (2.6.10-1.1076_FC4) + root (hd0,1) + kernel /vmlinuz-2.6.10-1.1076_FC4 ro root=/dev/hda3 rhgb quiet acpi=off + initrd /initrd-2.6.10-1.1076_FC4.img diff --git a/grubby-8.40-1/test/results/remove/extlinux3.1 b/grubby-8.40-1/test/results/remove/extlinux3.1 new file mode 100644 index 0000000..12b4ef5 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/extlinux3.1 @@ -0,0 +1,10 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/remove/extlinux4.1 b/grubby-8.40-1/test/results/remove/extlinux4.1 new file mode 100644 index 0000000..5e1824e --- /dev/null +++ b/grubby-8.40-1/test/results/remove/extlinux4.1 @@ -0,0 +1,27 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) + +label Fedora (3.11.7-300.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-300.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-300.fc20.i686.img + +label Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.13.0-0.rc0.git5.1.fc21.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.13.0-0.rc0.git5.1.fc21.i686.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/remove/g2-1.1 b/grubby-8.40-1/test/results/remove/g2-1.1 new file mode 100644 index 0000000..89f01ee --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g2-1.1 @@ -0,0 +1,95 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/remove/g2-1.2 b/grubby-8.40-1/test/results/remove/g2-1.2 new file mode 100644 index 0000000..13832c4 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g2-1.2 @@ -0,0 +1,97 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'title' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading title' + linux /new-kernel.img root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' +} +submenu { +menuentry 'Linux, with Linux 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/remove/g2-1.4 b/grubby-8.40-1/test/results/remove/g2-1.4 new file mode 100644 index 0000000..3972717 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g2-1.4 @@ -0,0 +1,72 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/remove/g2.1 b/grubby-8.40-1/test/results/remove/g2.1 new file mode 100644 index 0000000..f312838 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g2.1 @@ -0,0 +1,14 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/hda5 +# initrd /initrd-version.img +#boot=/dev/hda +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title DOS + rootnoverify (hd0,1) + chainloader +1 diff --git a/grubby-8.40-1/test/results/remove/g3.1 b/grubby-8.40-1/test/results/remove/g3.1 new file mode 100644 index 0000000..c0eb61f --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g3.1 @@ -0,0 +1,12 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/remove/g7.1 b/grubby-8.40-1/test/results/remove/g7.1 new file mode 100644 index 0000000..ea1a6fb --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g7.1 @@ -0,0 +1,20 @@ +default=1 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/remove/g9.1 b/grubby-8.40-1/test/results/remove/g9.1 new file mode 100644 index 0000000..5b54fc4 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/g9.1 @@ -0,0 +1,6 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + kernel (hd0,1)/vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2smp.img diff --git a/grubby-8.40-1/test/results/remove/y1.1 b/grubby-8.40-1/test/results/remove/y1.1 new file mode 100644 index 0000000..9c8fc8e --- /dev/null +++ b/grubby-8.40-1/test/results/remove/y1.1 @@ -0,0 +1,25 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=linux +timeout=100 +macosx=path-to-macos + +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/vmlinux-2.5.50 + label=25 + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" + +image=/boot/vmlinuz-2.5.50-eepro + label=25eepro + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" diff --git a/grubby-8.40-1/test/results/remove/y1.2 b/grubby-8.40-1/test/results/remove/y1.2 new file mode 100644 index 0000000..11aefe9 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/y1.2 @@ -0,0 +1,26 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 +macosx=path-to-macos + +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/zImage-2.4.20 + label=test + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinux-2.5.50 + label=25 + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" + diff --git a/grubby-8.40-1/test/results/remove/y2.1 b/grubby-8.40-1/test/results/remove/y2.1 new file mode 100644 index 0000000..f757d92 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/y2.1 @@ -0,0 +1,25 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 +darwin=foo + +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/zImage-2.4.20 + label=test + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinuz-2.5.50-eepro + label=25eepro + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" diff --git a/grubby-8.40-1/test/results/remove/z1.1 b/grubby-8.40-1/test/results/remove/z1.1 new file mode 100644 index 0000000..1ebf554 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/z1.1 @@ -0,0 +1,7 @@ +[defaultboot] +default=linux +[linux] + target=/boot/ + image=/boot/vmlinuz-2.4.9-37 + ramdisk=/boot/initrd-2.4.9-37.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/test/results/remove/z1.2 b/grubby-8.40-1/test/results/remove/z1.2 new file mode 100644 index 0000000..af644e8 --- /dev/null +++ b/grubby-8.40-1/test/results/remove/z1.2 @@ -0,0 +1,7 @@ +[defaultboot] +default=linux2 +[linux2] + target=/boot/ + image=/boot/vmlinuz-2.4.9-38 + ramdisk=/boot/initrd-2.4.9-38.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/test/results/setdefaultindex/g.13.0 b/grubby-8.40-1/test/results/setdefaultindex/g.13.0 new file mode 100644 index 0000000..1ae82a8 --- /dev/null +++ b/grubby-8.40-1/test/results/setdefaultindex/g.13.0 @@ -0,0 +1,21 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 +# initrd /initrd-version.img +#boot=/dev/vda +default=0 +timeout=5 +splashimage=(hd0,0)/grub/splash.xpm.gz +hiddenmenu +title Red Hat Enterprise Linux Server (2.6.18-308.1.1.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-308.1.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-308.1.1.el5.img +title Red Hat Enterprise Linux Server (2.6.18-238.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-238.el5.img diff --git a/grubby-8.40-1/test/results/setdefaultindex/g.13.1 b/grubby-8.40-1/test/results/setdefaultindex/g.13.1 new file mode 100644 index 0000000..c0db036 --- /dev/null +++ b/grubby-8.40-1/test/results/setdefaultindex/g.13.1 @@ -0,0 +1,21 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 +# initrd /initrd-version.img +#boot=/dev/vda +default=1 +timeout=5 +splashimage=(hd0,0)/grub/splash.xpm.gz +hiddenmenu +title Red Hat Enterprise Linux Server (2.6.18-308.1.1.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-308.1.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-308.1.1.el5.img +title Red Hat Enterprise Linux Server (2.6.18-238.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-238.el5.img diff --git a/grubby-8.40-1/test/results/setdefaultindex/g.13.9 b/grubby-8.40-1/test/results/setdefaultindex/g.13.9 new file mode 100644 index 0000000..74299b6 --- /dev/null +++ b/grubby-8.40-1/test/results/setdefaultindex/g.13.9 @@ -0,0 +1,20 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 +# initrd /initrd-version.img +#boot=/dev/vda +timeout=5 +splashimage=(hd0,0)/grub/splash.xpm.gz +hiddenmenu +title Red Hat Enterprise Linux Server (2.6.18-308.1.1.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-308.1.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-308.1.1.el5.img +title Red Hat Enterprise Linux Server (2.6.18-238.el5) + root (hd0,0) + kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet + initrd /initrd-2.6.18-238.el5.img diff --git a/grubby-8.40-1/test/results/setdefaultindex/g2.1.0 b/grubby-8.40-1/test/results/setdefaultindex/g2.1.0 new file mode 100644 index 0000000..fcf053a --- /dev/null +++ b/grubby-8.40-1/test/results/setdefaultindex/g2.1.0 @@ -0,0 +1,84 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="0" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/setdefaultindex/g2.1.1 b/grubby-8.40-1/test/results/setdefaultindex/g2.1.1 new file mode 100644 index 0000000..aaa8e77 --- /dev/null +++ b/grubby-8.40-1/test/results/setdefaultindex/g2.1.1 @@ -0,0 +1,84 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +set default="1" +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/setdefaultindex/g2.1.9 b/grubby-8.40-1/test/results/setdefaultindex/g2.1.9 new file mode 100644 index 0000000..5b68102 --- /dev/null +++ b/grubby-8.40-1/test/results/setdefaultindex/g2.1.9 @@ -0,0 +1,83 @@ +# +# DO NOT EDIT THIS FILE +# +# It is automatically generated by grub2-mkconfig using templates +# from /etc/grub.d and settings from /etc/default/grub +# + +### BEGIN /etc/grub.d/00_header ### +if [ -s $prefix/grubenv ]; then + load_env +fi +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function load_video { + insmod vbe + insmod vga + insmod video_bochs + insmod video_cirrus +} + +set timeout=5 +### END /etc/grub.d/00_header ### + +### BEGIN /etc/grub.d/10_linux ### +menuentry 'Linux, with Fedora 2.6.38.8-32.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Fedora 2.6.38.8-32.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.8-32.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.8-32.fc15.x86_64.img +} +menuentry 'Linux, with Linux 2.6.38.2-9.fc15.x86_64' --class gnu-linux --class gnu --class os { + load_video + set gfxpayload=keep + insmod part_msdos + insmod ext2 + set root='(hd0,msdos1)' + search --no-floppy --fs-uuid --set=root df0170c9-7d05-415c-bbd1-d4d503ba0eed + echo 'Loading Linux 2.6.38.2-9.fc15.x86_64 ...' + linux /vmlinuz-2.6.38.2-9.fc15.x86_64 root=/dev/mapper/vg_pjones5-lv_root ro quiet rhgb + echo 'Loading initial ramdisk ...' + initrd /initramfs-2.6.38.2-9.fc15.x86_64.img +} +### END /etc/grub.d/10_linux ### + +### BEGIN /etc/grub.d/20_linux_xen ### +### END /etc/grub.d/20_linux_xen ### + +### BEGIN /etc/grub.d/30_os-prober ### +### END /etc/grub.d/30_os-prober ### + +### BEGIN /etc/grub.d/40_custom ### +# This file provides an easy way to add custom menu entries. Simply type the +# menu entries you want to add after this comment. Be careful not to change +# the 'exec tail' line above. +### END /etc/grub.d/40_custom ### + +### BEGIN /etc/grub.d/41_custom ### +if [ -f $prefix/custom.cfg ]; then + source $prefix/custom.cfg; +fi +### END /etc/grub.d/41_custom ### + +### BEGIN /etc/grub.d/90_persistent ### +### END /etc/grub.d/90_persistent ### diff --git a/grubby-8.40-1/test/results/updargs/extlinux1.1 b/grubby-8.40-1/test/results/updargs/extlinux1.1 new file mode 100644 index 0000000..1e2a709 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux1.1 @@ -0,0 +1,17 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/hda1 +initrd /initrd-3.12.0-2.fc21.i686.img diff --git a/grubby-8.40-1/test/results/updargs/extlinux1.2 b/grubby-8.40-1/test/results/updargs/extlinux1.2 new file mode 100644 index 0000000..764655a --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux1.2 @@ -0,0 +1,18 @@ +# extlinux.conf generated by anaconda + +ui menu.c32 + +menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options. +menu title Fedora Boot Options. +menu hidden + +timeout 50 +totaltimeout 9000 + +default Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/hda1 hda=ide-scsi +initrd /initrd-3.12.0-2.fc21.i686.img +root /dev/hda2 diff --git a/grubby-8.40-1/test/results/updargs/extlinux3.1 b/grubby-8.40-1/test/results/updargs/extlinux3.1 new file mode 100644 index 0000000..ef9fa86 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux3.1 @@ -0,0 +1,15 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +append ro root=/dev/sda1 hdd=notide-scsi +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/updargs/extlinux3.2 b/grubby-8.40-1/test/results/updargs/extlinux3.2 new file mode 100644 index 0000000..c85b6bf --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux3.2 @@ -0,0 +1,15 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +append ro root=/dev/hdd1 hdd=notide-scsi +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/updargs/extlinux3.4 b/grubby-8.40-1/test/results/updargs/extlinux3.4 new file mode 100644 index 0000000..63f97bf --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux3.4 @@ -0,0 +1,15 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/updargs/extlinux3.7 b/grubby-8.40-1/test/results/updargs/extlinux3.7 new file mode 100644 index 0000000..b542ad3 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux3.7 @@ -0,0 +1,13 @@ +prompt 0 + +label Fedora (3.12.0-2.fc21.i686+PAE) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686+PAE +initrd /initrd-3.12.0-2.fc21.i686+PAE.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/updargs/extlinux4.2 b/grubby-8.40-1/test/results/updargs/extlinux4.2 new file mode 100644 index 0000000..9bf16b7 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux4.2 @@ -0,0 +1,32 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) + +label Fedora (3.11.7-300.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-300.fc20.i686 +append ro root=/dev/hda6 hde=ide-scsi +initrd /boot/initrd-3.11.7-300.fc20.i686.img + +label Fedora (3.11.7-301.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-301.fc20.i686 +append ro root=/dev/hda6 hde=ide-scsi +initrd /boot/initrd-3.11.7-301.fc20.i686.img + +label Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.13.0-0.rc0.git5.1.fc21.i686 +append ro root=/dev/hda6 hde=ide-scsi +initrd /boot/initrd-3.13.0-0.rc0.git5.1.fc21.i686.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 hde=ide-scsi +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 hde=ide-scsi diff --git a/grubby-8.40-1/test/results/updargs/extlinux4.3 b/grubby-8.40-1/test/results/updargs/extlinux4.3 new file mode 100644 index 0000000..218711d --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux4.3 @@ -0,0 +1,32 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) + +label Fedora (3.11.7-300.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-300.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-300.fc20.i686.img + +label Fedora (3.11.7-301.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-301.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-301.fc20.i686.img + +label Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.13.0-0.rc0.git5.1.fc21.i686 +append ro root=/dev/hda6 hde=ide-scsi +initrd /boot/initrd-3.13.0-0.rc0.git5.1.fc21.i686.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/updargs/extlinux4.4 b/grubby-8.40-1/test/results/updargs/extlinux4.4 new file mode 100644 index 0000000..dc298fb --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux4.4 @@ -0,0 +1,32 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) + +label Fedora (3.11.7-300.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-300.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-300.fc20.i686.img + +label Fedora (3.11.7-301.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-301.fc20.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.11.7-301.fc20.i686.img + +label Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.13.0-0.rc0.git5.1.fc21.i686 +append ro root=/dev/hda6 +initrd /boot/initrd-3.13.0-0.rc0.git5.1.fc21.i686.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=LABEL=/ console=tty0 console=ttyS1,9600n81 single +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 diff --git a/grubby-8.40-1/test/results/updargs/extlinux4.5 b/grubby-8.40-1/test/results/updargs/extlinux4.5 new file mode 100644 index 0000000..6418a48 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/extlinux4.5 @@ -0,0 +1,33 @@ +ui menu.c32 + +menu hidden +timeout 50 +totaltimeout 9000 + +prompt 10 +default Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) + +label Fedora (3.11.7-300.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-300.fc20.i686 +append ro root=/dev/hda2 +initrd /boot/initrd-3.11.7-300.fc20.i686.img + +label Fedora (3.11.7-301.fc20.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.11.7-301.fc20.i686 +append ro root=/dev/hda2 +initrd /boot/initrd-3.11.7-301.fc20.i686.img + +label Fedora (3.13.0-0.rc0.git5.1.fc21.i686) 20 (Heisenbug) +kernel /boot/vmlinuz-3.13.0-0.rc0.git5.1.fc21.i686 +append ro root=/dev/hda2 +initrd /boot/initrd-3.13.0-0.rc0.git5.1.fc21.i686.img + +label Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug) +kernel /vmlinuz-3.12.0-2.fc21.i686 +append ro root=/dev/hda2 console=tty0 console=ttyS1,9600n81 +initrd /initrd-3.12.0-2.fc21.i686.img + +label DOS +com32 chain.c32 +append hd0 1 +root /dev/hda2 diff --git a/grubby-8.40-1/test/results/updargs/g1.1 b/grubby-8.40-1/test/results/updargs/g1.1 new file mode 100644 index 0000000..b9c17f2 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g1.1 @@ -0,0 +1,16 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda1 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/updargs/g1.2 b/grubby-8.40-1/test/results/updargs/g1.2 new file mode 100644 index 0000000..afb40f3 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g1.2 @@ -0,0 +1,16 @@ +# grub.conf generated by anaconda +# +# Note that you do not have to rerun grub after making changes to this file +# NOTICE: You have a /boot partition. This means that +# all kernel and initrd paths are relative to /boot/, eg. +# root (hd0,0) +# kernel /vmlinuz-version ro root=/dev/sda1 +# initrd /initrd-version.img +#boot=/dev/hda +default=0 +timeout=10 +splashimage=(hd0,0)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda1 hda=ide-scsi root=/dev/hda2 + initrd /initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/updargs/g11.1 b/grubby-8.40-1/test/results/updargs/g11.1 new file mode 100644 index 0000000..de71877 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g11.1 @@ -0,0 +1,10 @@ +#boot=/dev/hda +timeout=10 +default=0 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + kernel (hd0,1)/vmlinuz-2.4.7-2smp ro root=LABEL=/ hdd=ide-scsi console=tty0 console=ttyS1,9600n81 single + initrd (hd0,1)/initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + kernel (hd0,1)/vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/updargs/g11.2 b/grubby-8.40-1/test/results/updargs/g11.2 new file mode 100644 index 0000000..473ce52 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g11.2 @@ -0,0 +1,10 @@ +#boot=/dev/hda +timeout=10 +default=0 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + kernel (hd0,1)/vmlinuz-2.4.7-2smp ro root=LABEL=/ hdd=ide-scsi console=tty0 console=ttyS0,9600n81 single + initrd (hd0,1)/initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + kernel (hd0,1)/vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd (hd0,1)/initrd-2.4.7-2.img diff --git a/grubby-8.40-1/test/results/updargs/g3.1 b/grubby-8.40-1/test/results/updargs/g3.1 new file mode 100644 index 0000000..2f3e9ae --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g3.1 @@ -0,0 +1,16 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 hdd=notide-scsi + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/updargs/g3.2 b/grubby-8.40-1/test/results/updargs/g3.2 new file mode 100644 index 0000000..ee41fd2 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g3.2 @@ -0,0 +1,16 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp ro root=/dev/hdd1 hdd=notide-scsi + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 hdd=ide-scsi + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/updargs/g3.4 b/grubby-8.40-1/test/results/updargs/g3.4 new file mode 100644 index 0000000..53b3301 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g3.4 @@ -0,0 +1,16 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp ro root=/dev/hda5 + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda5 + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/updargs/g3.7 b/grubby-8.40-1/test/results/updargs/g3.7 new file mode 100644 index 0000000..602beb2 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g3.7 @@ -0,0 +1,16 @@ +#boot=/dev/hda +timeout=10 +splashimage=(hd0,1)/grub/splash.xpm.gz +title Red Hat Linux (2.4.7-2smp) + root (hd0,1) + kernel /vmlinuz-2.4.7-2smp + initrd /initrd-2.4.7-2smp.img +title Red Hat Linux-up (2.4.7-2) + root (hd0,1) + kernel /vmlinuz-2.4.7-2 + initrd /initrd-2.4.7-2.img +title DOS + rootnoverify (hd0,0) + chainloader +1 + + diff --git a/grubby-8.40-1/test/results/updargs/g7.1 b/grubby-8.40-1/test/results/updargs/g7.1 new file mode 100644 index 0000000..5d2ae71 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g7.1 @@ -0,0 +1,30 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 hde=ide-scsi + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 hde=ide-scsi + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/updargs/g7.2 b/grubby-8.40-1/test/results/updargs/g7.2 new file mode 100644 index 0000000..71a8aab --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g7.2 @@ -0,0 +1,30 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 hde=ide-scsi + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 hde=ide-scsi + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 hde=ide-scsi + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 hde=ide-scsi + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/updargs/g7.3 b/grubby-8.40-1/test/results/updargs/g7.3 new file mode 100644 index 0000000..bd2315d --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g7.3 @@ -0,0 +1,30 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 hde=ide-scsi + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/sda1 console=tty0 console=ttyS1,9600n81 + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/updargs/g7.4 b/grubby-8.40-1/test/results/updargs/g7.4 new file mode 100644 index 0000000..d471781 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g7.4 @@ -0,0 +1,30 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda6 + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=LABEL=/ console=tty0 console=ttyS1,9600n81 single + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/updargs/g7.5 b/grubby-8.40-1/test/results/updargs/g7.5 new file mode 100644 index 0000000..e61c10d --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/g7.5 @@ -0,0 +1,30 @@ +default=2 +timeout=10 +splashimage=(hd0,5)/boot/grub/splash.xpm.gz + +title Red Hat Linux (2.4.7-2.9) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda2 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-2.5) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-2.5 ro root=/dev/hda2 + initrd /boot/initrd-2.4.7-2.5.img + +title Red Hat Linux (2.4.7-ac3) + root (hd0,5) + kernel /boot/vmlinuz-2.4.7-ac3 ro root=/dev/hda2 + initrd /boot/initrd-2.4.7-ac3.img + +title Red Hat Linux (2.4.7-2) + root (hd0,0) + kernel /vmlinuz-2.4.7-2 ro root=/dev/hda2 console=tty0 console=ttyS1,9600n81 + initrd /initrd-2.4.7-2.img + +title dos + root (hd0,0) + chainloader +1 + + + diff --git a/grubby-8.40-1/test/results/updargs/l1.1 b/grubby-8.40-1/test/results/updargs/l1.1 new file mode 100644 index 0000000..b74aaa6 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l1.1 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md1 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/updargs/l1.2 b/grubby-8.40-1/test/results/updargs/l1.2 new file mode 100644 index 0000000..9794d37 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l1.2 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + read-only + initrd=/boot/initrd-2.4.18-4smp.img + append="root=LABEL=foo" diff --git a/grubby-8.40-1/test/results/updargs/l1.3 b/grubby-8.40-1/test/results/updargs/l1.3 new file mode 100644 index 0000000..646f3fd --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l1.3 @@ -0,0 +1,26 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md0 + read-only + initrd=/boot/initrd-2.4.18-4smp.img + append="foo" diff --git a/grubby-8.40-1/test/results/updargs/l1.4 b/grubby-8.40-1/test/results/updargs/l1.4 new file mode 100644 index 0000000..bcd4f0a --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l1.4 @@ -0,0 +1,27 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/md1 + read-only + initrd=/boot/initrd-2.4.18-4.img + append="foo bar" + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/md1 + read-only + initrd=/boot/initrd-2.4.18-4smp.img + append="foo bar" diff --git a/grubby-8.40-1/test/results/updargs/l1.6 b/grubby-8.40-1/test/results/updargs/l1.6 new file mode 100644 index 0000000..61f5de2 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l1.6 @@ -0,0 +1,25 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message +linear + +disk=/dev/sdm + bios=0x80 +disk=/dev/sdn + bios=0x81 + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + read-only + initrd=/boot/initrd-2.4.18-4.img + append="foo root=LABEL=/ bar" + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + read-only + initrd=/boot/initrd-2.4.18-4smp.img + append="foo root=LABEL=/ bar" diff --git a/grubby-8.40-1/test/results/updargs/l3.1 b/grubby-8.40-1/test/results/updargs/l3.1 new file mode 100644 index 0000000..872019a --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l3.1 @@ -0,0 +1,33 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/hda1 + read-only + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4 + label=single + root=/dev/hda1 + read-only + append="single" + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/hda2 + read-only + initrd=/boot/initrd-2.4.18-4smp.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/hda2 + read-only + append = " single hda=ide-scsi " + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/results/updargs/l3.2 b/grubby-8.40-1/test/results/updargs/l3.2 new file mode 100644 index 0000000..84fe587 --- /dev/null +++ b/grubby-8.40-1/test/results/updargs/l3.2 @@ -0,0 +1,34 @@ +prompt +timeout=50 +default=linux +boot=/dev/md1 +map=/boot/map +install=/boot/boot.b +message=/boot/message + +image=/boot/vmlinuz-2.4.18-4 + label=linux-up + root=/dev/hda2 + read-only + initrd=/boot/initrd-2.4.18-4.img + append="hda=ide-scsi" + +image=/boot/vmlinuz-2.4.18-4 + label=single + root=/dev/hda2 + read-only + append="hda=ide-scsi" + initrd=/boot/initrd-2.4.18-4.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/hda2 + read-only + initrd=/boot/initrd-2.4.18-4smp.img + +image=/boot/vmlinuz-2.4.18-4smp + label=linux + root=/dev/hda2 + read-only + append = " hda=ide-scsi " + initrd=/boot/initrd-2.4.18-4smp.img diff --git a/grubby-8.40-1/test/yaboot.1 b/grubby-8.40-1/test/yaboot.1 new file mode 100644 index 0000000..04c6d7e --- /dev/null +++ b/grubby-8.40-1/test/yaboot.1 @@ -0,0 +1,31 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 +macosx=path-to-macos + +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/zImage-2.4.20 + label=test + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinux-2.5.50 + label=25 + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" + +image=/boot/vmlinuz-2.5.50-eepro + label=25eepro + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" diff --git a/grubby-8.40-1/test/yaboot.2 b/grubby-8.40-1/test/yaboot.2 new file mode 100644 index 0000000..979a0b1 --- /dev/null +++ b/grubby-8.40-1/test/yaboot.2 @@ -0,0 +1,31 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 +darwin=foo + +image=/boot/vmlinux-2.4.9-23.19.8 + label=linux + read-only + root=/dev/sda2 + +image=/boot/zImage-2.4.20 + label=test + read-only + root=/dev/sda2 + append="eeh-force-off console=ttyS0 console=tty" + +image=/boot/vmlinux-2.5.50 + label=25 + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" + +image=/boot/vmlinuz-2.5.50-eepro + label=25eepro + read-only + root=/dev/sda2 + append="console=ttyS0 console=tty" diff --git a/grubby-8.40-1/test/yaboot.3 b/grubby-8.40-1/test/yaboot.3 new file mode 100644 index 0000000..9985680 --- /dev/null +++ b/grubby-8.40-1/test/yaboot.3 @@ -0,0 +1,12 @@ +boot=/dev/sda1 +partition=sda2 +init-message="\nWelcome to Red Hat Linux!\nHit for boot options.\n\n" +install=/usr/lib/yaboot/yaboot +nonvram +default=test +timeout=100 + +image=/boot/vmlinux-2.4.9-23.19.8 + label=test + read-only + root=/dev/sda2 diff --git a/grubby-8.40-1/test/zipl.1 b/grubby-8.40-1/test/zipl.1 new file mode 100644 index 0000000..531dc36 --- /dev/null +++ b/grubby-8.40-1/test/zipl.1 @@ -0,0 +1,12 @@ +[defaultboot] +default=linux +[linux] + target=/boot/ + image=/boot/vmlinuz-2.4.9-37 + ramdisk=/boot/initrd-2.4.9-37.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" +[linux2] + target=/boot/ + image=/boot/vmlinuz-2.4.9-38 + ramdisk=/boot/initrd-2.4.9-38.img + parameters="root=/dev/dasda1 dasd=0200,0201,0202,0203" diff --git a/grubby-8.40-1/uboot b/grubby-8.40-1/uboot new file mode 100644 index 0000000..07d8671 --- /dev/null +++ b/grubby-8.40-1/uboot @@ -0,0 +1,43 @@ +# Settings for uBoot setup in /sbin/new-kernel-pkg +# +# Default values are provided below (as comments) +# +# WARNING: These values affect where grubby installs and removes +# uBoot kernel images. Changing these _after_ kernels have +# been installed may cause removing a kernel image to fail. + +# directory where uBoot images and scripts are found +#UBOOT_DIR=/boot + +# Override the load address when running mkimage on the kernel. +# OMAP such as Beagleboard and Pandaboard: Use 0x80008000 +# Tegra such as Trimslice: Use 0x00008000 +# IMX such as Efika mx51 smarttop: Use 0x90008000 +# Kirkwood such as Dreamplug, Guruplug, Sheevaplug: Use 0x00008000 +# If left undefined grubby will use defults for Tegra or OMAP depending +# upon the contents of /proc/cpuinfo. +#UBOOT_IMGADDR=0x0x00008000 + +# name of the text file containing the list of installed kernel versions +# NOTE: The versions are in order of installation. The last entry should +# always be the default boot kernel version. +#UBOOT_KLIST=klist.txt + +# device partition where uBoot images reside; mounted on $UBOOT_DIR +#UBOOT_DEVICE=mmcblk0p1 + + +# NOTE: Both of the following files are automatically overwritte +# when a kernel package is installed or removed. + +# default kernel uImage file name +#UBOOT_UIMAGE=uImage + +# default initrd uInitrd file name +#UBOOT_UINITRD=uInitrd + +# defualt for platform shipping an onboard dtb. +#SHIPSDTB=no + +# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf +#dtbfile=foo.dtb -- Gitee From 57ed983710f3f38195fb46593d1826037aa51100 Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Mon, 28 Mar 2022 09:58:58 +0800 Subject: [PATCH 2/3] grubby support anolis Signed-off-by: Chunmei Xu --- grubby-8.40-1/new-kernel-pkg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grubby-8.40-1/new-kernel-pkg b/grubby-8.40-1/new-kernel-pkg index b634388..5dd777f 100755 --- a/grubby-8.40-1/new-kernel-pkg +++ b/grubby-8.40-1/new-kernel-pkg @@ -167,6 +167,8 @@ set_title() { title="$NAME ($version) $VERSION" elif [ -f /etc/redhat-release ]; then title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)" + elif [ -f /etc/anolis-release ]; then + title="$(sed 's/ release.*$//' < /etc/anolis-release) ($version)" else title="Red Hat Linux ($version)" fi -- Gitee From ab3be85b9a4fe5faeedad611295d4fe8a8f53b67 Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Mon, 28 Mar 2022 10:01:46 +0800 Subject: [PATCH 3/3] grubby support anolis Signed-off-by: Chunmei Xu --- 1000-grubby-support-anolis.patch | 26 ++++++++++++++++++++++++++ grubby.spec | 9 ++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 1000-grubby-support-anolis.patch diff --git a/1000-grubby-support-anolis.patch b/1000-grubby-support-anolis.patch new file mode 100644 index 0000000..e9145fb --- /dev/null +++ b/1000-grubby-support-anolis.patch @@ -0,0 +1,26 @@ +From 57ed983710f3f38195fb46593d1826037aa51100 Mon Sep 17 00:00:00 2001 +From: Chunmei Xu +Date: Mon, 28 Mar 2022 09:58:58 +0800 +Subject: [PATCH] grubby support anolis + +Signed-off-by: Chunmei Xu +--- + new-kernel-pkg | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/new-kernel-pkg b/new-kernel-pkg +index b634388..5dd777f 100755 +--- a/new-kernel-pkg ++++ b/new-kernel-pkg +@@ -167,6 +167,8 @@ set_title() { + title="$NAME ($version) $VERSION" + elif [ -f /etc/redhat-release ]; then + title="$(sed 's/ release.*$//' < /etc/redhat-release) ($version)" ++ elif [ -f /etc/anolis-release ]; then ++ title="$(sed 's/ release.*$//' < /etc/anolis-release) ($version)" + else + title="Red Hat Linux ($version)" + fi +-- +2.19.1.6.gb485710b + diff --git a/grubby.spec b/grubby.spec index 0cabd60..c499094 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 Name: grubby Version: 8.40 Release: %{anolis_release}%{?dist} @@ -11,14 +11,14 @@ Patch0001: 0001-Fix-GCC-warnings-about-possible-string-truncations-a.patch Patch0002: 0002-Fix-stringop-overflow-warning.patch Patch0003: 0003-Fix-maybe-uninitialized-warning.patch +Patch1000: 1000-grubby-support-anolis.patch + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: pkgconfig glib2-devel popt-devel BuildRequires: libblkid-devel git # for make test / getopt: BuildRequires: util-linux-ng -%ifarch aarch64 x86_64 BuildRequires: /usr/bin/grub2-editenv -%endif %description grubby is a command line tool for updating and displaying information about @@ -64,5 +64,8 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man8/*.8* %changelog +* Mon Mar 28 2022 Chunmei Xu - 8.40-2 +- grubby support anolis + * Wed Mar 9 2022 Liwei Ge - 8.40-1 - Init version from upstream v8.40 -- Gitee