git: 0aa4a9fc859f - main - bootstrap-packages.sh escape ++

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Wed, 16 Oct 2024 16:27:14 UTC
The branch main has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=0aa4a9fc859fd43343e2d7b5094a50d1ca0948eb

commit 0aa4a9fc859fd43343e2d7b5094a50d1ca0948eb
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2024-10-16 16:26:19 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2024-10-16 16:26:29 +0000

    bootstrap-packages.sh escape ++
    
    We need to escape + when egreping parent makefile too.
    
    Reviewed by:    stevek
---
 targets/pseudo/bootstrap-packages/bootstrap-packages.sh | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/targets/pseudo/bootstrap-packages/bootstrap-packages.sh b/targets/pseudo/bootstrap-packages/bootstrap-packages.sh
index 58b2843a9422..fa87b069f6da 100755
--- a/targets/pseudo/bootstrap-packages/bootstrap-packages.sh
+++ b/targets/pseudo/bootstrap-packages/bootstrap-packages.sh
@@ -118,13 +118,17 @@ end_options() {
 EOF
 }
 
+no_plus() {
+    case "$1" in
+    *+*) echo "$1" | sed 's,+,\\\\+,g';;
+    *) echo "$1";;
+    esac
+}
+
 find_opt() {
     mf=$1
-    sub=$2
+    sub="`no_plus $2`"
     shift 2
-    case "$sub" in
-    *+*) sub=`echo "$sub" | sed 's,+,\\\\+,g'`;;
-    esac
     egrep "$@" "^[^#].*[[:space:]]$sub([[:space:]]|\$)" $mf |
     tr '{' '\n' |
     sed -n 's,^MK_\([^}]*\).*,\1,p' |
@@ -142,8 +146,9 @@ sort -t= -k2 "$@" | sed 's,/Makefile:PACKAGE=, ,' |
 	bname=${reldir##*/}
 	# check parent does not have it commented out
 	# otherwise we should ignore it.
+	# if the parent makefile does not exist, we will skip it.
 	pmf=$SRCTOP/$dname/Makefile
-	egrep -q "^[^#].*[[:space:]]$bname([[:space:]]|\$)" $pmf || continue
+	egrep -q "^[^#].*[[:space:]]`no_plus $bname`([[:space:]]|\$)" $pmf 2> /dev/null || continue
 	: reldir=$reldir
 	case "$reldir" in
 	*lib/*) sub=${reldir#*lib/};;