From: Johannes Schauer Marin Rodrigues <josch@debian.org>
Date: Thu, 13 Feb 2025 19:26:55 +0100
Subject: Makefile: fix option parsing regex for python 3.13 argparse output

---
 Makefile                              | 8 ++++----
 tools/cross.sh                        | 1 +
 tools/native.sh                       | 1 +
 tools/y-u-b-d-transitive-essential.sh | 1 +
 tools/y-u-no-bootstrap.sh             | 1 +
 5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 23202d0..3587dfc 100644
--- a/Makefile
+++ b/Makefile
@@ -303,8 +303,8 @@ test-man: $(OCAMLBUILD_BEST)
 		| grep -v tools/debarch.py \
 		| grep -v buildcheck-more-problems | grep -v distcheck-more-problems \
 		| while read pkg; do \
-			shortopts=`./$$pkg --help 2>&1 | sed -ne 's/^ \+-\([^ =-]\).*$$/\1/p' | sort`; \
-			longopts=`./$$pkg --help 2>&1 | sed -ne 's/^ \+\(-[^ =-]\+,\)\? --\([^ =]\+\)\([ =].*\)\?$$/\2/p' | sort`; \
+			shortopts=`./$$pkg --help 2>&1 | sed -n '/^options:$$/,$$p' | sed -ne 's/^ \{1,4\}-\([^ =-]\).*$$/\1/p' | sort`; \
+			longopts=`./$$pkg --help 2>&1 | sed -n '/^options:$$/,$$p' | sed -ne 's/^ \{1,4\}\(-[^ =-]\+,\)\? --\([^ =]\+\)\([ =].*\)\?$$/\2/p' | sort`; \
 			echo "compare \`./$$pkg --help\` with man page..."; \
 			man=`basename $$pkg .$(OCAMLBUILD_BEST)`; \
 			man=`basename $$man .py`; \
@@ -313,12 +313,12 @@ test-man: $(OCAMLBUILD_BEST)
 			longman=`sed -ne 's/=item B<[^>]*--\([^>=]\+\)=\?>.*$$/\1/p' doc/man/botch-$${man}.pod | sort`; \
 			shortman=`sed -ne 's/=item B<-\([^>,-]\)[^>]*>.*$$/\1/p' doc/man/botch-$${man}.pod | sort`; \
 			if [ "$$shortopts" != "$$shortman" ]; then \
-				echo "\`./$$pkg --help\` and man page ./$$man disagree:"; \
+				echo "\`./$$pkg --help\` short options and man page ./$$man disagree:"; \
 				echo "$$shortopts != $$shortman"; \
 				exit 1; \
 			fi; \
 			if [ "$$longopts" != "$$longman" ]; then \
-				echo "\`./$$pkg --help\` and man page ./$$man disagree:"; \
+				echo "\`./$$pkg --help\` long options and man page ./$$man disagree:"; \
 				echo "$$longopts != $$longman"; \
 				exit 1; \
 			fi; \
diff --git a/tools/cross.sh b/tools/cross.sh
index 44ac0d0..16e5d90 100755
--- a/tools/cross.sh
+++ b/tools/cross.sh
@@ -20,6 +20,7 @@ VERBOSE=
 usage() {
 	echo "usage: $PROGNAME [OPTIONS] [buildarch hostarch buildpackages sources]" >&2
 	echo >&2
+	echo "options:" >&2
 	echo " -h, --help       Show this help message and exit" >&2
 	echo " -k, --keep       Keep the temporary files" >&2
 	echo " -w, --online     Produce stat.html for online consumption" >&2
diff --git a/tools/native.sh b/tools/native.sh
index 1464bc1..05b2af3 100755
--- a/tools/native.sh
+++ b/tools/native.sh
@@ -29,6 +29,7 @@ DEBUG=
 usage() {
 	echo "usage: $PROGNAME [OPTIONS] [architecture Packages Sources]" >&2
 	echo >&2
+	echo "options:" >&2
 	echo " -h, --help             Show this help message and exit" >&2
 	echo " -k, --keep             Keep the temporary files" >&2
 	echo " -c, --self-contained   Do not work on the full repository but on a smaller" >&2
diff --git a/tools/y-u-b-d-transitive-essential.sh b/tools/y-u-b-d-transitive-essential.sh
index 839483f..12cb3f6 100755
--- a/tools/y-u-b-d-transitive-essential.sh
+++ b/tools/y-u-b-d-transitive-essential.sh
@@ -21,6 +21,7 @@ usage() {
 	echo "If the optional \"pkgname\" argument is specified as well, then only" >&2
 	echo "the results for that one package will be output." >&2
 	echo >&2
+	echo "options:" >&2
 	echo " -h, --help       Show this help message and exit" >&2
 	echo " -k, --keep       Keep the temporary files" >&2
 	echo " -T, --timers     time all program executions" >&2
diff --git a/tools/y-u-no-bootstrap.sh b/tools/y-u-no-bootstrap.sh
index 82ad4d6..aff6593 100755
--- a/tools/y-u-no-bootstrap.sh
+++ b/tools/y-u-no-bootstrap.sh
@@ -15,6 +15,7 @@ VERBOSE=
 usage() {
 	echo "usage: $PROGNAME architecture Packages Sources" >&2
 	echo >&2
+	echo "options:" >&2
 	echo "Find the reasons why Debian is currently not bootstrappable." >&2
 	echo "Assumes that Architecture:all packages need not be bootstrapped." >&2
 	echo "Operates on the strong dependency graph." >&2
