0
0
mirror of https://github.com/termux-pacman/glibc-packages.git synced 2024-09-22 08:31:01 +00:00
glibc-packages/cgct/glibc-cgct/setup-cgct
Ivan Max 7d8cc165de
cgct/glibc-cgct: improvements (#288)
removing rpath setting in setup-cgct script
fixing paths to dynamic linker in ldd
2024-09-14 19:02:24 +03:00

34 lines
927 B
Bash

#!/usr/bin/env bash
export CGCT_DIR="/data/data/com.termux/cgct"
_setup_cgct_error() {
echo "Error: ${1}"
exit 1
}
[ ! -d "${CGCT_DIR}" ] && _setup_cgct_error "cgct was not found, are you sure you installed it?"
RPATH_LIBS="${CGCT_DIR}/lib"
if [ -n "${1}" ]; then
RPATH_LIBS+=":${1}"
fi
LD_LIB=$(ls ${CGCT_DIR}/lib/ld-* 2> /dev/null)
[ -z "$LD_LIB" ] && _setup_cgct_error "interpreter not found in lib directory"
! type patchelf &> /dev/null && _setup_cgct_error "patchelf not found"
[ ! -f "${CGCT_DIR}/bin/ldconfig" ] && _setup_cgct_error "ldconfig from glibc-cgct not found"
echo "Setting up CGCT..."
for f in $(find "${CGCT_DIR}"/{aarch64,arm,x86_64,i686}/{bin,lib/gcc} -type f -exec grep -IL . "{}" \; | grep -v -e '\.a' -e '\.o' -e '\.so'); do
patchelf --set-interpreter "$LD_LIB" "$f"
echo "Configured '${f}'"
done
echo -e "${RPATH_LIBS//:/\\n}" > "${CGCT_DIR}"/etc/ld.so.conf
"${CGCT_DIR}"/bin/ldconfig