← Back to team overview

curtin-dev team mailing list archive

[Merge] ~raharper/curtin:fix/centos-grub into curtin:master

 

Ryan Harper has proposed merging ~raharper/curtin:fix/centos-grub into curtin:master.

Commit message:
vmtest/centos: handle different paths to grub config

Centos images used to always have grub installed at
/boot/grub/grub.conf. The most recent build of centos70,
centos70/amd64/20210210_01/root-tgz, now has grub conf located at
/boot/grub2/grub.cfg.  This patch checks for either path before
running the sed fixup command.



Requested reviews:
  curtin developers (curtin-dev)

For more details, see:
https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/399028
-- 
Your team curtin developers is requested to review the proposed merge of ~raharper/curtin:fix/centos-grub into curtin:master.
diff --git a/examples/tests/centos_defaults.yaml b/examples/tests/centos_defaults.yaml
index 85e1c03..94e2ae8 100644
--- a/examples/tests/centos_defaults.yaml
+++ b/examples/tests/centos_defaults.yaml
@@ -27,7 +27,7 @@ write_files:
           [ -e "$ofile" ] || return 0
           cp "$ofile" "$bk" || rerror "failed backup ($ofile -> $bk):" "$@";
       }
-      
+
       update_grub1() {
           local cfg="$1" r=""
           [ -e "$cfg" ] ||
@@ -48,7 +48,7 @@ write_files:
               { rerror "failed to update grub1 cfg '$cfg'."; return; }
           info "updated grub1 cfg '$cfg'."
       }
-      
+
       update_grub2() {
           local cfg="$1" defgrub="$2"
           [ -e "$cfg" ] || { info "no grub2 config '$cfg'"; return 0; }
@@ -56,8 +56,8 @@ write_files:
           sed -i -e '/kernel/n' -e '/console=/n' \
             -e "s/root=\([^ ]*\)/root=\1 ${CONPARM}/" "$cfg" ||
             { rerror "failed to update grub2 '$cfg'"; return; }
-      
-          # update /etc/default/grub. any GRUB_CMDLINE_LINUX remove 
+
+          # update /etc/default/grub. any GRUB_CMDLINE_LINUX remove
           # any console= and add conparm at the beginning.
           local var="GRUB_CMDLINE_LINUX" msg="updated grub2 '$cfg'."
           if [ ! -e "$defgrub" ]; then
@@ -77,15 +77,21 @@ write_files:
       update_grub1 "$grub1conf" || fail "failed update grub1"
       update_grub2 "$grub2conf" "$grub2def" || fail "failed update grub2"
 
+
+# centos66 images include grub 0.97 which will detect vmtests' ephemeral disk
+# and the install disk which leaves grub configured with two disks.  When
+# vmtest reboots into installed disk, there is only one disk and the grub
+# map is no longer valid.  Here in 00_grub, we switch hd1 to hd0.  MAAS
+# is not affected as their ephemeral image (iscsi or http) is not discovered
+# by grub and therefor the device.map doesn't contain a second device. Cent7
+# has grub2 which uses root by UUID.
+_update_grub_conf:
+ - &update_grub |
+   CONF="/boot/grub2/grub.cfg"
+   [ -f "${CONF}" ] || CONF="/boot/grub/grub.conf"
+   sed -i.curtin -e 's|(hd1,0)|(hd0,0)|g' ${CONF}
+
 late_commands:
- # centos66 images include grub 0.97 which will detect vmtests' ephemeral disk
- # and the install disk which leaves grub configured with two disks.  When
- # vmtest reboots into installed disk, there is only one disk and the grub
- # map is no longer valid.  Here in 00_grub, we switch hd1 to hd0.  MAAS
- # is not affected as their ephemeral image (iscsi or http) is not discovered
- # by grub and therefor the device.map doesn't contain a second device. Cent7
- # has grub2 which uses root by UUID
- 00_grub1_boot: [curtin, in-target, --, sed, -i.curtin, -e,
-                 's|(hd1,0)|(hd0,0)|g', /boot/grub/grub.conf]
+ 00_grub1_boot: [curtin, in-target, --, 'sh', '-c', *update_grub]
  # vmtest wants output to go to serial console so we update grub inside.
  00_grub_serial: [curtin, in-target, --, '/root/curtin-send-console-to-serial']

Follow ups