summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-07-28 22:47:17 +0100
committerSam James <sam@gentoo.org>2024-07-29 18:29:18 +0100
commita7107c20c6b3e3e4b656941d395970904059c277 (patch)
tree398b3ea12de31ccf0b5b82433030cc4e874a3256 /sys-apps/gentoo-functions
parentdev-lang/spidermonkey: Stabilize 115.13.0 ppc64, #936886 (diff)
downloadgentoo-a7107c20c6b3e3e4b656941d395970904059c277.tar.gz
gentoo-a7107c20c6b3e3e4b656941d395970904059c277.tar.bz2
gentoo-a7107c20c6b3e3e4b656941d395970904059c277.zip
sys-apps/gentoo-functions: revise 1.6 as 1.6-r1
This revision backports a few patches to prevent ~arch keyword users with unusual EINFO_LOG declarations from being affected by bug #936613. Closes: https://bugs.gentoo.org/936613 Signed-off-by: Kerin Millar <kfm@plushkava.net> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'sys-apps/gentoo-functions')
-rw-r--r--sys-apps/gentoo-functions/files/gentoo-functions-1.6-add-warn-function.patch34
-rw-r--r--sys-apps/gentoo-functions/files/gentoo-functions-1.6-relax-parameter-validation.patch233
-rw-r--r--sys-apps/gentoo-functions/gentoo-functions-1.6-r1.ebuild (renamed from sys-apps/gentoo-functions/gentoo-functions-1.6.ebuild)5
3 files changed, 272 insertions, 0 deletions
diff --git a/sys-apps/gentoo-functions/files/gentoo-functions-1.6-add-warn-function.patch b/sys-apps/gentoo-functions/files/gentoo-functions-1.6-add-warn-function.patch
new file mode 100644
index 000000000000..8fcce19a8fda
--- /dev/null
+++ b/sys-apps/gentoo-functions/files/gentoo-functions-1.6-add-warn-function.patch
@@ -0,0 +1,34 @@
+From 755177bbfcf4c46ad1ac31ad9501a6c8725b1a68 Mon Sep 17 00:00:00 2001
+From: Kerin Millar <kfm@plushkava.net>
+Date: Sun, 2 Jun 2024 04:36:27 +0100
+Subject: Add the warn() function
+
+This will be used internally by a forthcoming commit.
+
+Signed-off-by: Kerin Millar <kfm@plushkava.net>
+---
+ functions.sh | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/functions.sh b/functions.sh
+index 9736747..a97dde7 100644
+--- a/functions.sh
++++ b/functions.sh
+@@ -473,6 +473,14 @@ vewend()
+ fi
+ }
+
++#
++# Prints a diagnostic message prefixed with the basename of the running script.
++#
++warn()
++{
++ printf '%s: %s\n' "${0##*/}" "$*" >&2
++}
++
+ #
+ # Determines whether the first parameter is truthy. The values taken to be true
+ # are "yes", "true", "on" and "1", whereas their opposites are taken to be
+--
+cgit v1.2.3-65-gdbad
+
diff --git a/sys-apps/gentoo-functions/files/gentoo-functions-1.6-relax-parameter-validation.patch b/sys-apps/gentoo-functions/files/gentoo-functions-1.6-relax-parameter-validation.patch
new file mode 100644
index 000000000000..4f89c9f4acb6
--- /dev/null
+++ b/sys-apps/gentoo-functions/files/gentoo-functions-1.6-relax-parameter-validation.patch
@@ -0,0 +1,233 @@
+From 3f2519288f1074a7ef5e8378f4bdf37809b262e5 Mon Sep 17 00:00:00 2001
+From: Kerin Millar <kfm@plushkava.net>
+Date: Sun, 2 Jun 2024 04:36:37 +0100
+Subject: Relax parameter validation for various functions
+
+Following some deliberation over the matter, I have concluded that
+calling die() for the handling of invalid parameters ought not to be
+considered as a matter of course. As such, this commit retains the
+existing diagnostics for the functions listed below, while modifying
+them so as to no longer attempt to exit the shell.
+
+- eend
+- eqatag
+- esyslog
+- ewend
+- is_older than
+- veend
+- vewend
+- yesno
+
+Signed-off-by: Kerin Millar <kfm@plushkava.net>
+---
+ functions.sh | 69 ++++++++++++++++++++++++++++++++++------------------------
+ test-functions | 13 ++---------
+ 2 files changed, 42 insertions(+), 40 deletions(-)
+
+diff --git a/functions.sh b/functions.sh
+index 48b4c5a..ec1f339 100644
+--- a/functions.sh
++++ b/functions.sh
+@@ -63,7 +63,7 @@ if ! command -v die >/dev/null; then
+ *)
+ genfun_status=$?
+ esac
+- printf '%s: %s\n' "${0##*/}" "$*" >&2
++ warn "$@"
+ exit "${genfun_status}"
+ }
+ fi
+@@ -209,7 +209,8 @@ eqatag()
+ shift
+ fi
+ if [ "$#" -eq 0 ]; then
+- die "eqatag: no tag specified"
++ warn "eqatag: no tag specified"
++ return 1
+ fi
+ positional=0
+ tag=$1
+@@ -222,7 +223,8 @@ eqatag()
+ case ${arg} in
+ [!=/]*=?*)
+ if [ "${positional}" -eq 1 ]; then
+- _throw_invalid_args eqatag "${arg}"
++ _warn_for_args eqatag "${arg}"
++ return 1
+ fi
+ set -- "$@" --arg "${arg%%=*}" "${arg#*=}"
+ ;;
+@@ -234,7 +236,8 @@ eqatag()
+ set -- "$@" "${arg}"
+ ;;
+ *)
+- _throw_invalid_args eqatag "${arg}"
++ _warn_for_args eqatag "${arg}"
++ return 1
+ esac
+ done
+ json=$(
+@@ -269,7 +272,8 @@ esyslog()
+ local pri tag msg
+
+ if [ "$#" -lt 2 ]; then
+- die "esyslog: too few arguments (got $#, expected at least 2)"
++ warn "esyslog: too few arguments (got $#, expected at least 2)"
++ return 1
+ elif yesno "${EINFO_LOG}" && hash logger 2>/dev/null; then
+ pri=$1
+ tag=$2
+@@ -380,8 +384,9 @@ is_older_than()
+ {
+ local ref has_gfind
+
+- if [ "$#" -lt 2 ]; then
+- die "is_older_than: too few arguments (got $#, expected at least 2)"
++ if [ "$#" -eq 0 ]; then
++ warn "is_older_than: too few arguments (got $#, expected at least 1)"
++ return 1
+ elif [ -e "$1" ]; then
+ ref=$1
+ else
+@@ -431,7 +436,8 @@ veend()
+ if yesno "${EINFO_VERBOSE}"; then
+ GENFUN_CALLER=veend eend "$@"
+ elif [ "$#" -gt 0 ] && { ! is_int "$1" || [ "$1" -lt 0 ]; }; then
+- _throw_invalid_args veend "$1"
++ _warn_for_args veend "$1"
++ false
+ else
+ return "$1"
+ fi
+@@ -442,7 +448,8 @@ vewend()
+ if yesno "${EINFO_VERBOSE}"; then
+ GENFUN_CALLER=vewend ewend "$@"
+ elif [ "$#" -gt 0 ] && { ! is_int "$1" || [ "$1" -lt 0 ]; }; then
+- _throw_invalid_args vewend "$1"
++ _warn_for_args vewend "$1"
++ false
+ else
+ return "$1"
+ fi
+@@ -459,7 +466,8 @@ yesno()
+ local arg
+
+ if [ "$#" -eq 0 ]; then
+- die "yesno: too few arguments (got $#, expected 1)"
++ warn "yesno: too few arguments (got $#, expected 1)"
++ return 1
+ fi
+ arg=$1
+ for _ in 1 2; do
+@@ -471,14 +479,15 @@ yesno()
+ return 0
+ esac
+ if [ "$_" -ne 1 ] || ! is_identifier "$1"; then
+- ! break
++ break
+ else
+ # The value appears to be a legal variable name. Treat
+ # it as a name reference and try again, once only.
+ eval "arg=\$$1"
+ fi
+- done || _throw_invalid_args yesno "$1"
+- return 1
++ done
++ _warn_for_args yesno "$@"
++ false
+ }
+
+ #
+@@ -494,7 +503,9 @@ _eend()
+ if [ "$#" -eq 0 ]; then
+ retval=0
+ elif ! is_int "$1" || [ "$1" -lt 0 ]; then
+- _throw_invalid_args "${GENFUN_CALLER}" "$1"
++ _warn_for_args "${GENFUN_CALLER}" "$1"
++ retval=1
++ msg=
+ else
+ retval=$1
+ shift
+@@ -662,21 +673,6 @@ _print_args()
+ EOF
+ }
+
+-#
+-# Prints a diganostic message concerning invalid function arguments then exits.
+-# The first argument shall be taken as a function identifier. The remaining
+-# arguments shall be safely rendered as a part of the diagnostic.
+-#
+-_throw_invalid_args()
+-{
+- local ident plural
+-
+- ident=$1
+- shift
+- [ "$#" -gt 1 ] && plural=s || plural=
+- die "${ident}: invalid argument${plural}: $(_print_args "$@")"
+-}
+-
+ #
+ # Determines whether the terminal on STDIN is able to report its dimensions.
+ # Upon success, the number of columns shall be stored in genfun_cols.
+@@ -718,6 +714,21 @@ _update_tty_level()
+ fi
+ }
+
++#
++# Prints a diganostic message concerning invalid function arguments. The first
++# argument shall be taken as a function identifier. The remaining arguments
++# shall be safely rendered as a part of the diagnostic.
++#
++_warn_for_args()
++{
++ local ident plural
++
++ ident=$1
++ shift
++ [ "$#" -gt 1 ] && plural=s || plural=
++ warn "${ident}: invalid argument${plural}: $(_print_args "$@")"
++}
++
+ # All function declarations end here! Initialisation code only from hereon.
+ # shellcheck disable=2034
+ RC_GOT_FUNCTIONS=yes
+diff --git a/test-functions b/test-functions
+index d65a3a2..4a6e7dd 100755
+--- a/test-functions
++++ b/test-functions
+@@ -196,11 +196,7 @@ test_is_older_than() {
+ callback() {
+ shift
+ test_description="is_older_than $(_print_args "$@")"
+- if [ "$#" -lt 2 ]; then
+- ( is_older_than "$@" )
+- else
+- is_older_than "$@"
+- fi
++ is_older_than "$@"
+ }
+
+ iterate_tests 4 "$@"
+@@ -392,16 +388,11 @@ test_yesno() {
+
+ # shellcheck disable=2034
+ truthful_nameref=yes
+- row=0
+
+ callback() {
+ shift
+ test_description="yesno $(_print_args "$@")"
+- if [ "$(( row += 1 ))" -ge 22 ]; then
+- ( yesno "$@" )
+- else
+- yesno "$@"
+- fi
++ yesno "$@"
+ }
+
+ iterate_tests 3 "$@"
+--
+cgit v1.2.3-65-gdbad
+
diff --git a/sys-apps/gentoo-functions/gentoo-functions-1.6.ebuild b/sys-apps/gentoo-functions/gentoo-functions-1.6-r1.ebuild
index 8df3a1e88bad..191370d892fa 100644
--- a/sys-apps/gentoo-functions/gentoo-functions-1.6.ebuild
+++ b/sys-apps/gentoo-functions/gentoo-functions-1.6-r1.ebuild
@@ -24,6 +24,11 @@ RESTRICT="!test? ( test )"
# Specifically needs GNU find, as well.
RDEPEND=">=sys-apps/findutils-4.9"
+PATCHES=(
+ "${FILESDIR}/${P}-relax-parameter-validation.patch"
+ "${FILESDIR}/${P}-add-warn-function.patch"
+)
+
src_configure() {
local emesonargs=(
# Deliberately avoid /usr as consumers assume we're at /lib/gentoo.