diff mbox series

[OSSTEST,2/2] ts-xen-build: Pass --enable if --disable found in usage, and v.v.

Message ID 20211027170256.18223-3-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series ts-xen-build: explicitly enable/disable configure features | expand

Commit Message

Ian Jackson Oct. 27, 2021, 5:02 p.m. UTC
The existing code works in practice if the usage message always lists
the non-default, since the unlisted-in-usage options that would be
supported, but are elided, are in any case the default.

But configure might *compute* its defaults.  In which case it will
list only one of them in the usage message.  If the computed default
is not the same as the usual default (the one implied by listing the
opposite in the usage message) we would wrongly not pass the option.

So grep for both enable and disable.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
CC: Juergen Gross <jgross@suse.com>
---
 ts-xen-build | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ts-xen-build b/ts-xen-build
index d6f6bfacb..c294a51ea 100755
--- a/ts-xen-build
+++ b/ts-xen-build
@@ -142,12 +142,20 @@  END
 }
 
 sub build () {
+    # We want to explicitly enable and disable some things.  But not
+    # all versions of Xen support all configuration options.  We
+    # detect presence of an option by grepping configure.  That finds
+    # them in the usage message.  The usage message has only one of
+    # the two, depending on the usual default.  (Presence of --enable
+    # in the usage output means --disable is supported, and vice
+    # versa.)  So we search for both enable and disable, and if either
+    # is found, we use the one we want.
     my $enable_opts = ''; # shell script to set "enable_opts" shell var
     my $enable_disable = sub {
 	my ($subdir, $feat, $enable) = @_;
 	my $opt = "--".($enable ? 'enable' : 'disable')."-$feat";
 	$enable_opts .= <<END;
-                if grep -q -- $opt \\
+                if egrep -q -- '--disable-$feat|--enable-$feat' \\
                                ${subdir}configure ; then
 		    enable_opts="\$enable_opts $opt"
                 fi