Skip to content

Commit

Permalink
gen_funcs: Add an install_exe function
Browse files Browse the repository at this point in the history
This helps when the build uses slibtool where the compiled binary output
path differs from GNU libtool.

Signed-off-by: orbea <orbea@riseup.net>
  • Loading branch information
orbea committed May 15, 2022
1 parent 1b1da75 commit 1bb3cc1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions gen_funcs.sh
Expand Up @@ -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:
Expand Down

0 comments on commit 1bb3cc1

Please sign in to comment.