[libvirt] [PATCH v3 01/48] build: make augeas-gentest.pl write to stdout

Daniel P. Berrangé berrange at redhat.com
Mon Jul 29 17:10:43 UTC 2019


The augeas-gentest.pl program merges a config file into a augeas
file, saving the output to a new file. It is going to be useful
to further process the output file, and it would be easier if this can
be done with a pipeline, so change augeas-gentest.pl to write to stdout
instead of a file.

Reviewed-by: Andrea Bolognani <abologna at redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 build-aux/augeas-gentest.pl | 20 ++++++--------------
 src/bhyve/Makefile.inc.am   |  2 +-
 src/libxl/Makefile.inc.am   |  2 +-
 src/locking/Makefile.inc.am |  6 +++---
 src/logging/Makefile.inc.am |  2 +-
 src/lxc/Makefile.inc.am     |  2 +-
 src/qemu/Makefile.inc.am    |  2 +-
 src/remote/Makefile.inc.am  |  2 +-
 8 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/build-aux/augeas-gentest.pl b/build-aux/augeas-gentest.pl
index 567fc651f3..faf2fd593e 100755
--- a/build-aux/augeas-gentest.pl
+++ b/build-aux/augeas-gentest.pl
@@ -20,17 +20,10 @@
 use strict;
 use warnings;
 
-die "syntax: $0 CONFIG TEMPLATE AUGTEST\n" unless @ARGV == 3;
+die "syntax: $0 CONFIG TEMPLATE\n" unless @ARGV == 2;
 
 my $config = shift @ARGV;
 my $template = shift @ARGV;
-my $augtest = shift @ARGV;
-
-open AUGTEST, ">", $augtest or die "cannot create $augtest: $!";
-
-$SIG{__DIE__} = sub {
-    unlink $augtest;
-};
 
 open CONFIG, "<", $config or die "cannot read $config: $!";
 open TEMPLATE, "<", $template or die "cannot read $template: $!";
@@ -39,12 +32,12 @@ my $group = 0;
 while (<TEMPLATE>) {
     if (/::CONFIG::/) {
         my $group = 0;
-        print AUGTEST "  let conf = \"";
+        print "  let conf = \"";
         while (<CONFIG>) {
             if (/^#\w/) {
                 s/^#//;
                 s/\"/\\\"/g;
-                print AUGTEST $_;
+                print $_;
                 $group = /\[\s$/;
             } elsif ($group) {
                 s/\"/\\\"/g;
@@ -53,16 +46,15 @@ while (<TEMPLATE>) {
                 }
                 if (/^#/) {
                     s/^#//;
-                    print AUGTEST $_;
+                    print $_;
                 }
             }
         }
-        print AUGTEST "\"\n";
+        print "\"\n";
     } else {
-        print AUGTEST $_;
+        print $_;
     }
 }
 
 close TEMPLATE;
 close CONFIG;
-close AUGTEST or die "cannot save $augtest: $!";
diff --git a/src/bhyve/Makefile.inc.am b/src/bhyve/Makefile.inc.am
index 36af5d7504..6e8e6ad5d8 100644
--- a/src/bhyve/Makefile.inc.am
+++ b/src/bhyve/Makefile.inc.am
@@ -55,7 +55,7 @@ AUGEAS_DIRS += bhyve
 
 test_libvirtd_bhyve.aug: bhyve/test_libvirtd_bhyve.aug.in \
 		$(srcdir)/bhyve/bhyve.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/bhyve/bhyve.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/bhyve/bhyve.conf $< > $@
 
 check-augeas-bhyve: test_libvirtd_bhyve.aug
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
diff --git a/src/libxl/Makefile.inc.am b/src/libxl/Makefile.inc.am
index 7f60b449d8..abc65ede2c 100644
--- a/src/libxl/Makefile.inc.am
+++ b/src/libxl/Makefile.inc.am
@@ -74,7 +74,7 @@ AUGEAS_DIRS += libxl
 
 test_libvirtd_libxl.aug: libxl/test_libvirtd_libxl.aug.in \
 		$(srcdir)/libxl/libxl.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/libxl/libxl.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/libxl/libxl.conf $< > $@
 
 check-augeas-libxl: test_libvirtd_libxl.aug
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am
index 46ab11c2a9..c44f74a529 100644
--- a/src/locking/Makefile.inc.am
+++ b/src/locking/Makefile.inc.am
@@ -228,7 +228,7 @@ if WITH_SANLOCK
 if WITH_QEMU
 test_libvirt_sanlock.aug: locking/test_libvirt_sanlock.aug.in \
 		locking/qemu-sanlock.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-sanlock.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-sanlock.conf $< > $@
 
 check-augeas-sanlock: test_libvirt_sanlock.aug
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
@@ -244,14 +244,14 @@ endif ! WITH_SANLOCK
 if WITH_QEMU
 test_libvirt_lockd.aug: locking/test_libvirt_lockd.aug.in \
 		locking/qemu-lockd.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-lockd.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-lockd.conf $< > $@
 else ! WITH_QEMU
 test_libvirt_lockd.aug:
 endif ! WITH_QEMU
 
 test_virtlockd.aug: locking/test_virtlockd.aug.in \
 		locking/virtlockd.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/locking/virtlockd.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/locking/virtlockd.conf $< > $@
 
 if WITH_QEMU
 check-augeas-lockd: test_libvirt_lockd.aug
diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am
index d57394cbde..8527890eb0 100644
--- a/src/logging/Makefile.inc.am
+++ b/src/logging/Makefile.inc.am
@@ -101,7 +101,7 @@ augeastest_DATA += test_virtlogd.aug
 
 test_virtlogd.aug: logging/test_virtlogd.aug.in \
 		logging/virtlogd.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/logging/virtlogd.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/logging/virtlogd.conf $< > $@
 
 AUGEAS_DIRS += logging
 
diff --git a/src/lxc/Makefile.inc.am b/src/lxc/Makefile.inc.am
index f27827c1e9..1c0b715a2f 100644
--- a/src/lxc/Makefile.inc.am
+++ b/src/lxc/Makefile.inc.am
@@ -163,7 +163,7 @@ AUGEAS_DIRS += lxc
 
 test_libvirtd_lxc.aug: lxc/test_libvirtd_lxc.aug.in \
 		$(srcdir)/lxc/lxc.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/lxc/lxc.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/lxc/lxc.conf $< > $@
 
 check-augeas-lxc: test_libvirtd_lxc.aug
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
index 254ba07dc0..e8c7d4b5b1 100644
--- a/src/qemu/Makefile.inc.am
+++ b/src/qemu/Makefile.inc.am
@@ -122,7 +122,7 @@ AUGEAS_DIRS += qemu
 
 test_libvirtd_qemu.aug: qemu/test_libvirtd_qemu.aug.in \
 		$(srcdir)/qemu/qemu.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/qemu/qemu.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/qemu/qemu.conf $< > $@
 
 check-augeas-qemu: test_libvirtd_qemu.aug
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 0cf00cb902..4f706f9743 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -190,7 +190,7 @@ AUGEAS_DIRS += remote
 
 test_libvirtd.aug: remote/test_libvirtd.aug.in \
 		remote/libvirtd.conf $(AUG_GENTEST)
-	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/remote/libvirtd.conf $< $@
+	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/remote/libvirtd.conf $< > $@
 
 check-augeas-remote: test_libvirtd.aug
 	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
-- 
2.21.0




More information about the libvir-list mailing list