xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 22/24] host examination: bootloader: Do not use ed
Date: Thu, 18 May 2017 12:01:32 +0100	[thread overview]
Message-ID: <1495105294-25989-22-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1495105294-25989-1-git-send-email-ian.jackson@eu.citrix.com>

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 <ian.jackson@eu.citrix.com>
---
 ts-examine-serial-pre | 49 ++++++++++++++++++++++++-------------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/ts-examine-serial-pre b/ts-examine-serial-pre
index 26fbc56..86f332f 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 = <<END;
-            ed $file <<EOF
-$script
-w
-q
-EOF
-END
-	$cmd .= setupboot_bootloader_edited_rune($ho);
-	target_cmd_root($ho, $cmd, 200);
+    my $edit = sub {
+	my ($file,$editor) = @_;
+	target_editfile_root($ho,$file,$editor);
+	target_cmd_root($ho, setupboot_bootloader_edited_rune($ho), 200);
     };
     my $edscript;
     if ($ho->{Flags}{'need-uboot-bootscr'}) {
-	$ed->('/boot/boot.xen',<<END)
-/^echo Loaded
-i
-echo osstest uboot $c
-.
-END
+	$edit->('/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',<<END); # no support for grub1
-1 
-/^ *menuentry  *
-s/'\([^']*\)'/'$c \1'
-1
-/^ *submenu  *
-s
-END
+	# no support for grub1
+	$edit->('/boot/grub/grub.cfg', sub {
+            my %done;
+            while (<::EI>) {
+		s{^(\s* ( menuentry | submenu ) \s+
+		      (['"]) )( [^'"]+ \3) }{
+                    $done{$2}++ ? $& : "$1$c $4"
+                }xe;
+		print ::EO;
+	    }
+	});
     }
 }
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-05-18 11:02 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 11:01 [OSSTEST PATCH 01/24] README: Advise using `play' for playground flights Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 02/24] sg-report-flight: Do not report <none executed> unless it's true Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 03/24] cs-flight-create: Fix usage error message Ian Jackson
2017-05-23 13:58   ` Roger Pau Monné
2017-05-18 11:01 ` [OSSTEST PATCH 04/24] ts-hosts-allocate-Executive: tolerate lack of hostflags Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 05/24] tcmd: Work around ssh bug with `ssh host ""' Ian Jackson
2017-05-23 13:16   ` Roger Pau Monné
2017-05-23 13:53     ` Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 06/24] cs-hosts-list: New utility Ian Jackson
2017-05-23 13:23   ` Roger Pau Monné
2017-05-23 13:54     ` Ian Jackson
2017-05-23 14:12       ` Roger Pau Monné
2017-05-18 11:01 ` [OSSTEST PATCH 07/24] cs-hosts-list: Support --arches and --kernels Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 08/24] cs-hosts-list: Support --suites Ian Jackson
2017-05-23 14:25   ` Roger Pau Monné
2017-05-23 17:11     ` Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 09/24] cs-hosts-list, standalone-generate-dump-flight-runvars: make compatible Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 10/24] sg-run-job: new run-ts iffail syntax - Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 11/24] host examination: Initial skeleton Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 12/24] Debian.pm: Break out setupboot_bootloader_edited_rune Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 13/24] TestSupport, Executive: Provide intended_blessing Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 14/24] host examination: Check that serial output is working Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 15/24] host examination: Permanently save the logs Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 16/24] ts-hosts-allocate-Executive: Honour hostalloc_maxwait_max Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 17/24] make-hosts-flight: Impose a timeout Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 18/24] cr-daily-branch: Move harness_rev definition Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 19/24] host examination: Add a check to many flights Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 20/24] host examination: Run a regular exam flight Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 21/24] host examination: serial, grub2: put cookie in menu lines Ian Jackson
2017-05-18 11:01 ` Ian Jackson [this message]
2017-05-18 11:01 ` [OSSTEST PATCH 23/24] host examination: bootloader: edit all grub2 menu entries Ian Jackson
2017-05-18 11:01 ` [OSSTEST PATCH 24/24] host examination: bootloader: better handling of multiple runs Ian Jackson
2017-05-23 13:24 ` [OSSTEST PATCH 01/24] README: Advise using `play' for playground flights Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495105294-25989-22-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).