aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororbea <orbea@riseup.net>2022-05-15 15:49:21 -0700
committerorbea <orbea@riseup.net>2022-05-15 16:13:55 -0700
commit1bb3cc10d51026ad500bc9cec883f1f2f0c445ec (patch)
tree13ce832d85b3630e11287af6b134f0cca7fa1aaf
parentfuse: Add patch to allow building against glibc-2.34 (diff)
downloadgenkernel-1bb3cc10d51026ad500bc9cec883f1f2f0c445ec.tar.gz
genkernel-1bb3cc10d51026ad500bc9cec883f1f2f0c445ec.tar.bz2
genkernel-1bb3cc10d51026ad500bc9cec883f1f2f0c445ec.zip
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@riseup.net>
-rwxr-xr-xgen_funcs.sh23
1 files changed, 23 insertions, 0 deletions
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: