xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [OSSTEST PATCH 1/7] target_editfile_kvp_replace: Support changing multiple keys
@ 2021-01-22 15:55 Ian Jackson
  2021-01-22 15:55 ` [OSSTEST PATCH 2/7] target_editfile_kvp_replace: Add a bit of logging Ian Jackson
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Ian Jackson @ 2021-01-22 15:55 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson

No functional change with existing callers.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 Osstest/TestSupport.pm | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 9362a865..d2558f31 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -769,25 +769,32 @@ sub teditfileex {
 	if $install;
 }
 
-# Replace a Key=Value style line in a config file.
+# Replace Key=Value style line(s) in a config file.
 #
 # To be used as 3rd argument to target_editfile(_root) as:
 #    target_editfile_root($ho, "/path/to/a/file",
 #			 sub { target_editfile_kvp_replace($key, $value) });
-sub target_editfile_kvp_replace ($$)
+sub target_editfile_kvp_replace
 {
-    my ($key,$value) = @_;
-    my $prnow;
-    $prnow= sub {
+    my (%kv) = @_;
+    my $prnow= sub {
+	my ($key) = @_;
+	my $value = $kv{$key};
+	return unless defined $value;
 	print ::EO "$key=$value\n" or die $!;
-	$prnow= sub { };
+	delete $kv{$key};
     };
     while (<::EI>) {
-	print ::EO or die $! unless m/^$key\b/;
-	$prnow->() if m/^#$key/;
+	if (m/^\S+\b/ && exists $kv{$&}) {
+	    $prnow->($&);
+	} else {
+	    print ::EO or die $!;
+	}
     }
     print ::EO "\n" or die $!;
-    $prnow->();
+    foreach my $key (sort keys %kv) {
+	$prnow->($key);
+    }
 };
 
 sub target_editfile_root ($$$;$$) { teditfileex('root',@_); }
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-01-28 14:27 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 15:55 [OSSTEST PATCH 1/7] target_editfile_kvp_replace: Support changing multiple keys Ian Jackson
2021-01-22 15:55 ` [OSSTEST PATCH 2/7] target_editfile_kvp_replace: Add a bit of logging Ian Jackson
2021-01-22 15:55 ` [OSSTEST PATCH 3/7] ts-xen-install: Rename $commons_config_file Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 4/7] ts-xen-install: Break out @commons_config Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 5/7] ts-xen-install: Honour xenstored target var Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 6/7] mfi-common: Provide stripy_rand Ian Jackson
2021-01-22 15:56 ` [OSSTEST PATCH 7/7] make-flight: Stripy xenstored Ian Jackson
2021-01-22 16:07   ` Andrew Cooper
2021-01-22 16:22     ` Ian Jackson
2021-01-22 16:24       ` Jürgen Groß
2021-01-22 16:26         ` Ian Jackson
2021-01-22 16:29           ` Jürgen Groß
2021-01-22 16:29       ` Andrew Cooper
2021-01-22 17:37         ` [OSSTEST PATCH 7/7] make-flight: Stripy xenstored [and 2 more messages] Ian Jackson
2021-01-22 17:52           ` Andrew Cooper
2021-01-28 14:26             ` Ian Jackson
2021-01-22 16:11   ` [OSSTEST PATCH 7/7] make-flight: Stripy xenstored Christian Lindig
2021-01-22 16:36   ` Andrew Cooper
2021-01-22 16:40   ` Edwin Torok

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).