commit: e296d7ac9b45c75499dbfa89cfd4e2341303d2e2
Author: Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Mon Oct 4 21:46:02 2021 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Oct 4 21:46:02 2021 +0000
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=e296d7ac
build: add --debug for easy shell script tracing
Improve the CLI parser slightly so we can add a --debug option.
This makes it easy to get shell script tracing with a -x option
rather than having to override the shebang/shell interpreter.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
autogen.sh | 26 ++++++++++++++++++++++++--
make-tarball.sh | 13 ++++++++++---
2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index 42e8a8c..a21b8e5 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -2,11 +2,33 @@
. "${0%/*}"/travis/lib.sh
+# NB: This script is normally run in a GNU environment (e.g. Linux), but we
also run it on other
+# systems (e.g. macOS) as part of our automated CI. So a little care must be
taken.
+
+cd "${0%/*}" || exit 1
+
m4dir="autotools/m4"
+: ${MAKE:=make}
+
+FROM_TOOL=
+while [[ $# -gt 0 ]] ;do
+ case $1 in
+ --from=*) FROM_TOOL=${1#*=};;
+ -x|--debug) set -x;;
+ *) break;;
+ esac
+ shift
+done
+
+if [[ $# -ne 0 ]] ; then
+ echo "Usage: $0" >&2
+ exit 1
+fi
+
v rm -rf autotools
-if [[ $1 != "--from=make" ]] ; then
- v ${MAKE:-make} autotools-update
+if [[ ${FROM_TOOL} != "make" ]] ; then
+ v ${MAKE} autotools-update
fi
# reload the gnulib code if possible
diff --git a/make-tarball.sh b/make-tarball.sh
index 04f778d..3cd3219 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# NB: This script is expected to be run in a GNU environment (e.g. Linux).
+# So it is not written to be completely POSIX compliant.
+
set -e
if ! . /etc/init.d/functions.sh 2>/dev/null ; then
@@ -13,10 +16,14 @@ v() { printf '\t%s\n' "$*"; "$@"; }
: ${MAKE:=make}
CHECK=false
-if [[ $1 == "--check" ]] ; then
- CHECK=true
+while [[ $# -gt 0 ]] ;do
+ case $1 in
+ --check) CHECK=true;;
+ -x|--debug) set -x;;
+ *) break;;
+ esac
shift
-fi
+done
if [[ $# -ne 1 ]] ; then
die "Usage: $0 <ver>"