From 7b8be0195ebb0765886ed7810d7e10b8f12a54c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Fri, 12 Sep 2025 14:29:31 +0200 Subject: [PATCH 1/2] install: fix shebang mangling The implementation of the shebang mangling had several flaws. First of all, it did not do anything because the "find" invocation was broken. Also, the kernel will strip any number of spaces and tabs after the "#!" marker. We need to do the same when comparing the command with known good values. Additionally, that list was missing the /bin/sh and /bin/bash commands that we certainly do not want to replace. --- classes/install.yaml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/classes/install.yaml b/classes/install.yaml index e24ff758..fd26e6e9 100644 --- a/classes/install.yaml +++ b/classes/install.yaml @@ -163,23 +163,34 @@ packageSetup: | fi } - # replace absolute interpreter paths with /usr/bin/env + # Replace absolute interpreter paths with "/usr/bin/env " for + # all executable scripts in directory. + # + # $1: directory (optional, defaults to ".") installFixShebang() { - local f old new + local shebang while IFS= read -r -d $'\0' f; do - if cmp -s -n2 "$f" <<<'#!' ; then - read -r old_cmd old_arg < "$f" - if [[ "$old_cmd" == "#!/usr/bin/env" ]]; then - continue + read -n 4096 -r shebang < "$f" + if [[ "${shebang:0:2}" == "#!" ]] ; then + # Match part after "#!". Tabs and spaces before and after the + # command are stripped by the kernel. We need to do the same! + if [[ "${shebang:2}" =~ ^[$' \t']*([$'^ \t']+)[$' \t']*(.*)$ ]] ; then + case "${BASH_REMATCH[1]}" in + /usr/bin/env | /bin/sh | /bin/bash) + continue + ;; + esac + + local cmd="${BASH_REMATCH[1]##*/}" + local arg="${BASH_REMATCH[2]}" + new="#!/usr/bin/env ${arg:+-S }${cmd}${arg:+ ${arg@Q}}" + sed -i -e "1c $new" "$f" else - old_cmd="${old_cmd:2}" - old_cmd="${old_cmd##*/}" + echo "WARNING: unrecognized shebang: $shebang" fi - new="#!/usr/bin/env ${old_arg:+-S }${old_cmd}${old_arg:+ ${old_arg@Q}}" - sed -i -e "1c $new" "$f" fi - done < <(find "${1:-.}" -type f -perm -/111 -print0) + done < <(find "${1:-.}" -type f -perm /111 -print0) } # Everything except shared or static libraries or header files. From 22e986731432c561dd39521671e67720a41ee31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Fri, 12 Sep 2025 16:26:46 +0200 Subject: [PATCH 2/2] devel::autoconf: remove absolute paths from scripts The various autoconf scripts contain the trick that let's them execute even if they are interpreted by the shell. This line has the full path to perl which will not be correct in Bobs environment. As it is unneeded in the first place, just remove it. --- recipes/devel/autoconf-2.69.yaml | 2 +- .../0003-remove-abs-perl-path.patch | 86 ++++++++++++++++ .../autoconf/0003-remove-abs-perl-path.patch | 99 +++++++++++++++++++ 3 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 recipes/devel/autoconf-2.69/0003-remove-abs-perl-path.patch create mode 100644 recipes/devel/autoconf/0003-remove-abs-perl-path.patch diff --git a/recipes/devel/autoconf-2.69.yaml b/recipes/devel/autoconf-2.69.yaml index 392a7700..f6b6805d 100644 --- a/recipes/devel/autoconf-2.69.yaml +++ b/recipes/devel/autoconf-2.69.yaml @@ -11,7 +11,7 @@ checkoutSCM: checkoutDeterministic: True checkoutScript: | - patchApplySeries $<> + patchApplySeries $<@autoconf-2.69/*.patch@> # We patch some files that would trigger the rebuild of the manpages. # Prevent that... touch man/*.1 diff --git a/recipes/devel/autoconf-2.69/0003-remove-abs-perl-path.patch b/recipes/devel/autoconf-2.69/0003-remove-abs-perl-path.patch new file mode 100644 index 00000000..d04e115c --- /dev/null +++ b/recipes/devel/autoconf-2.69/0003-remove-abs-perl-path.patch @@ -0,0 +1,86 @@ +From: Jan Kloetzke +Subject: [PATCH] Remove absolute perl path + +The variaous autoconf scipts contain the trick that let's them execute +even if they are interpreted by the shell. This line has the full path +to perl which will not be correct in Bobs environment. As it is +unneeded in the first place, just remove it. + +diff -Nurp a/bin/autoheader.in b/bin/autoheader.in +--- a/bin/autoheader.in 2025-09-12 15:51:09.408126785 +0200 ++++ b/bin/autoheader.in 2025-09-12 15:53:30.661992545 +0200 +@@ -2,9 +2,6 @@ + # -*- Perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autoheader -- create `config.h.in' from `configure.ac' + + # Copyright (C) 1992-1994, 1996, 1998-2012 Free Software Foundation, +diff -Nurp a/bin/autom4te.in b/bin/autom4te.in +--- a/bin/autom4te.in 2025-09-12 15:51:09.408126785 +0200 ++++ b/bin/autom4te.in 2025-09-12 15:53:30.753996376 +0200 +@@ -2,9 +2,6 @@ + # -*- perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autom4te - Wrapper around M4 libraries. + # Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc. + +diff -Nurp a/bin/autoreconf.in b/bin/autoreconf.in +--- a/bin/autoreconf.in 2025-09-12 15:51:09.408126785 +0200 ++++ b/bin/autoreconf.in 2025-09-12 15:53:30.850000372 +0200 +@@ -2,9 +2,6 @@ + # -*- perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autoreconf - install the GNU Build System in a directory tree + # Copyright (C) 1994, 1999-2012 Free Software Foundation, Inc. + +diff -Nurp a/bin/autoscan.in b/bin/autoscan.in +--- a/bin/autoscan.in 2025-09-12 15:51:09.408126785 +0200 ++++ b/bin/autoscan.in 2025-09-12 15:53:30.934003871 +0200 +@@ -20,9 +20,6 @@ + + # Written by David MacKenzie . + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + BEGIN + { + use File::Basename; +diff -Nurp a/bin/autoupdate.in b/bin/autoupdate.in +--- a/bin/autoupdate.in 2025-09-12 15:51:09.408126785 +0200 ++++ b/bin/autoupdate.in 2025-09-12 15:53:31.026007701 +0200 +@@ -21,9 +21,6 @@ + # Originally written by David MacKenzie . + # Rewritten by Akim Demaille . + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + BEGIN + { + use File::Basename; +diff -Nurp a/bin/ifnames.in b/bin/ifnames.in +--- a/bin/ifnames.in 2025-09-12 15:51:09.408126785 +0200 ++++ b/bin/ifnames.in 2025-09-12 15:53:31.074009699 +0200 +@@ -2,9 +2,6 @@ + # -*- perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # ifnames - print the identifiers used in C preprocessor conditionals + + # Copyright (C) 1994-1995, 1999-2003, 2005-2012 Free Software diff --git a/recipes/devel/autoconf/0003-remove-abs-perl-path.patch b/recipes/devel/autoconf/0003-remove-abs-perl-path.patch new file mode 100644 index 00000000..69c9de85 --- /dev/null +++ b/recipes/devel/autoconf/0003-remove-abs-perl-path.patch @@ -0,0 +1,99 @@ +From: Jan Kloetzke +Subject: [PATCH] Remove absolute perl path + +The variaous autoconf scipts contain the trick that let's them execute +even if they are interpreted by the shell. This line has the full path +to perl which will not be correct in Bobs environment. As it is +unneeded in the first place, just remove it. + +diff -Nurp a/bin/autoconf.in b/bin/autoconf.in +--- a/bin/autoconf.in 2025-09-12 11:22:28.208013268 +0200 ++++ b/bin/autoconf.in 2025-09-12 15:37:32.333735416 +0200 +@@ -2,9 +2,6 @@ + # -*- Perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autoconf -- create 'configure' using m4 macros. + + # Copyright (C) 1992-1994, 1996, 1999-2017, 2020-2023 Free Software +diff -Nurp a/bin/autoheader.in b/bin/autoheader.in +--- a/bin/autoheader.in 2025-09-12 11:22:28.208013268 +0200 ++++ b/bin/autoheader.in 2025-09-12 15:37:35.989891503 +0200 +@@ -2,9 +2,6 @@ + # -*- Perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autoheader -- create 'config.h.in' from 'configure.ac'. + + # Copyright (C) 1992-1994, 1996, 1998-2017, 2020-2023 Free Software +diff -Nurp a/bin/autom4te.in b/bin/autom4te.in +--- a/bin/autom4te.in 2025-09-12 11:22:28.212013444 +0200 ++++ b/bin/autom4te.in 2025-09-12 15:37:39.382036313 +0200 +@@ -2,9 +2,6 @@ + # -*- perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autom4te - Wrapper around M4 libraries. + # Copyright (C) 2001-2003, 2005-2017, 2020-2023 Free Software + # Foundation, Inc. +diff -Nurp a/bin/autoreconf.in b/bin/autoreconf.in +--- a/bin/autoreconf.in 2025-09-12 11:22:28.212013444 +0200 ++++ b/bin/autoreconf.in 2025-09-12 15:37:44.074236624 +0200 +@@ -2,9 +2,6 @@ + # -*- perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # autoreconf - install the GNU Build System in a directory tree + # Copyright (C) 1994, 1999-2017, 2020-2023 Free Software Foundation, + # Inc. +diff -Nurp a/bin/autoscan.in b/bin/autoscan.in +--- a/bin/autoscan.in 2025-09-12 11:22:28.212013444 +0200 ++++ b/bin/autoscan.in 2025-09-12 15:38:05.559153749 +0200 +@@ -21,9 +21,6 @@ + + # Written by David MacKenzie . + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + use 5.006; + use strict; + use warnings FATAL => 'all'; +diff -Nurp a/bin/autoupdate.in b/bin/autoupdate.in +--- a/bin/autoupdate.in 2025-09-12 11:22:28.212013444 +0200 ++++ b/bin/autoupdate.in 2025-09-12 15:38:05.683159042 +0200 +@@ -22,9 +22,6 @@ + # Originally written by David MacKenzie . + # Rewritten by Akim Demaille . + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + use 5.006; + use strict; + use warnings FATAL => 'all'; +diff -Nurp a/bin/ifnames.in b/bin/ifnames.in +--- a/bin/ifnames.in 2025-09-12 11:22:28.212013444 +0200 ++++ b/bin/ifnames.in 2025-09-12 15:38:05.735161261 +0200 +@@ -2,9 +2,6 @@ + # -*- perl -*- + # @configure_input@ + +-eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' +- if 0; +- + # ifnames - print the identifiers used in C preprocessor conditionals + + # Copyright (C) 1994-1995, 1999-2003, 2005-2017, 2020-2023 Free Software