Blame SOURCES/0002-configure-fix-parsing-issue-on-libbpf_dir-option.patch

6548d8
From a9cf0f0c57cf978ebe2abfd4c5a1b7df94f0a8ac Mon Sep 17 00:00:00 2001
6548d8
Message-Id: <a9cf0f0c57cf978ebe2abfd4c5a1b7df94f0a8ac.1637678195.git.aclaudi@redhat.com>
6548d8
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1637678195.git.aclaudi@redhat.com>
6548d8
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1637678195.git.aclaudi@redhat.com>
6548d8
From: Andrea Claudi <aclaudi@redhat.com>
6548d8
Date: Tue, 23 Nov 2021 15:28:18 +0100
6548d8
Subject: [PATCH] configure: fix parsing issue on libbpf_dir option
6548d8
6548d8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2016061
6548d8
Upstream Status: iproute2.git commit 48c379bc
6548d8
6548d8
commit 48c379bc2afd43b3246f68ed46475f5318b1218f
6548d8
Author: Andrea Claudi <aclaudi@redhat.com>
6548d8
Date:   Thu Oct 14 10:50:50 2021 +0200
6548d8
6548d8
    configure: fix parsing issue on libbpf_dir option
6548d8
6548d8
    configure is stuck in an endless loop if '--libbpf_dir' option is used
6548d8
    without a value:
6548d8
6548d8
    $ ./configure --libbpf_dir
6548d8
    ./configure: line 515: shift: 2: shift count out of range
6548d8
    ./configure: line 515: shift: 2: shift count out of range
6548d8
    [...]
6548d8
6548d8
    Fix it splitting 'shift 2' into two consecutive shifts, and making the
6548d8
    second one conditional to the number of remaining arguments.
6548d8
6548d8
    A check is also provided after the while loop to verify the libbpf dir
6548d8
    exists; also, as LIBBPF_DIR does not have a default value, configure bails
6548d8
    out if the user does not specify a value after --libbpf_dir, thus avoiding
6548d8
    to produce an erroneous configuration.
6548d8
6548d8
    Fixes: 7ae2585b865a ("configure: convert LIBBPF environment variables to command-line options")
6548d8
    Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
6548d8
    Acked-by: Phil Sutter <phil@nwl.cc>
6548d8
    Signed-off-by: David Ahern <dsahern@kernel.org>
6548d8
---
6548d8
 configure | 10 +++++++---
6548d8
 1 file changed, 7 insertions(+), 3 deletions(-)
6548d8
6548d8
diff --git a/configure b/configure
6548d8
index ea9051ab..0f304206 100755
6548d8
--- a/configure
6548d8
+++ b/configure
6548d8
@@ -486,7 +486,7 @@ usage()
6548d8
 	cat <
6548d8
 Usage: $0 [OPTIONS]
6548d8
 	--include_dir <dir>	Path to iproute2 include dir
6548d8
-	--libbpf_dir		Path to libbpf DESTDIR
6548d8
+	--libbpf_dir <dir>	Path to libbpf DESTDIR
6548d8
 	--libbpf_force		Enable/disable libbpf by force. Available options:
6548d8
 				  on: require link against libbpf, quit config if no libbpf support
6548d8
 				  off: disable libbpf probing
6548d8
@@ -506,8 +506,9 @@ else
6548d8
 				INCLUDE="$1"
6548d8
 				[ "$#" -gt 0 ] && shift ;;
6548d8
 			--libbpf_dir)
6548d8
-				LIBBPF_DIR="$2"
6548d8
-				shift 2 ;;
6548d8
+				shift
6548d8
+				LIBBPF_DIR="$1"
6548d8
+				[ "$#" -gt 0 ] && shift ;;
6548d8
 			--libbpf_force)
6548d8
 				if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then
6548d8
 					usage 1
6548d8
@@ -525,6 +526,9 @@ else
6548d8
 fi
6548d8
 
6548d8
 [ -d "$INCLUDE" ] || usage 1
6548d8
+if [ "${LIBBPF_DIR-unused}" != "unused" ]; then
6548d8
+	[ -d "$LIBBPF_DIR" ] || usage 1
6548d8
+fi
6548d8
 
6548d8
 echo "# Generated config based on" $INCLUDE >$CONFIG
6548d8
 quiet_config >> $CONFIG
6548d8
-- 
6548d8
2.31.1
6548d8