commit: 1bb3cc10d51026ad500bc9cec883f1f2f0c445ec
Author: orbea <orbea <AT> riseup <DOT> net>
AuthorDate: Sun May 15 22:49:21 2022 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun May 15 23:13:55 2022 +0000
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=1bb3cc10
gen_funcs: Add an install_exe function
This helps when the build uses slibtool where the compiled binary output
path differs from GNU libtool.
Signed-off-by: orbea <orbea <AT> riseup.net>
gen_funcs.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gen_funcs.sh b/gen_funcs.sh
index 500caf2..a4dc0e4 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -1974,6 +1974,29 @@ check_distfiles() {
fi
}
+# @FUNCTION: install_exe
+# @USAGE: <file> <destination>
+# @DESCRIPTION:
+# Finds an executable binary file and installs it in cases where there may be
+# similarly named shell wrapper scripts. This happens when GNU libtool creates
+# an executable named 'foo' while slibtool creates '.libs/foo' and 'foo' is a
+# shell script that should not be installed.
+install_exe() {
+ local file="${1##*/}"
+ local dest="${2}"
+
+ local dir
+ [[ "${1%/*}" == "${file}" ]] || dir="${1%/*}/"
+
+ [[ -f "${dir}${file}" ]] || gen_die "File '${dir}${file}' does not
exist!"
+
+ # Ensure only the binaries are installed and not a similarly named
wrapper script
+ find "${S}/${dir}" -type f -name "${file}" -print0 |
+ xargs -0 file | grep executable | grep ELF | cut -f 1 -d : |
+ xargs -I '{}' cp -a '{}' "${dest}" ||
+ gen_die "Failed to copy '${S}/${dir}${file}' to '${dest}'!"
+}
+
# @FUNCTION: expand_file
# @USAGE: <file>
# @DESCRIPTION: