From: Ian Jackson Date: Wed, 17 May 2017 20:45:37 +0000 (+0100) Subject: host examination: bootloader: Do not use ed X-Git-Tag: openstack-v11~41 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2d5df7ac42d68d628b9b5ea93cfd45c6dc352fd1;p=people%2Faperard%2Fosstest.git host examination: bootloader: Do not use ed These ed runes are what I used to develop this approach, but they are rather opaque to those very few programmers who are not proficient users of ed, the standard text editor. Also, using target_editfile_root means we keep a record of the bootloader config in the logs, which is desirable. The regexps used to edit the grub2 confiug are slightly more sophisticated than the ed ones were. Signed-off-by: Ian Jackson --- diff --git a/ts-examine-serial-pre b/ts-examine-serial-pre index 26fbc565..86f332f6 100755 --- a/ts-examine-serial-pre +++ b/ts-examine-serial-pre @@ -61,35 +61,34 @@ END sub bootloader () { my $c = get_cookie('bootloader'); - my $ed = sub { - my ($file,$script) = @_; - my $cmd = <{Flags}{'need-uboot-bootscr'}) { - $ed->('/boot/boot.xen',<('/boot/boot.xen', sub { + my $done; + while (<::EI>) { + if (m/^echo Loaded/ && !$done++) { + print ::EO "echo osstest uboot $c\n"; + } + print ::EO; + } + }); } else { - $ed->('/boot/grub/grub.cfg',<('/boot/grub/grub.cfg', sub { + my %done; + while (<::EI>) { + s{^(\s* ( menuentry | submenu ) \s+ + (['"]) )( [^'"]+ \3) }{ + $done{$2}++ ? $& : "$1$c $4" + }xe; + print ::EO; + } + }); } }