packelf/packelf-copylibs.sh

23 lines
526 B
Bash
Raw Normal View History

#!/usr/bin/env sh
2024-07-07 17:46:39 +02:00
#set -o pipefail # bash extension
2024-07-08 14:00:05 +02:00
#set -e
2024-07-08 14:25:20 +02:00
# Pack elf binary and it's dependencies into standalone executable
# License: GPLv2.0
if [ -z "${1}" ] ; then
2024-07-07 17:46:39 +02:00
echo "$0 <ELF_SRC_PATH> <PATH_TO_COPY_LIBRARIES>"
exit 0
else
if [ -z "${2}" ] ; then
2024-07-07 17:46:39 +02:00
echo "$0 <ELF_SRC_PATH> <PATH_TO_COPY_LIBRARIES>"
exit 0
else
libs="$(ldd "${1}" | grep -F '/' | sed -E 's|[^/]*/([^ ]+).*?|/\1|')"
for library in ${libs} ; do
cp -L ${library} ${2}
echo "Copied ${library} to ${2}"
done
fi
fi