ports/Mk/Scripts/find-lib.sh
Baptiste Daroussin a77d7def34 Stop trying to resolv symlinks when looking up for a shlib
file -L is resolving them properly and actual-package-depends.sh is also
correctly resolving them

Exp-run by:	antoine
2015-04-09 06:36:01 +00:00

43 lines
783 B
Bash

#!/bin/sh
# MAINTAINER: portmgr@FreeBSD.org
# $FreeBSD$
if [ -z "${LIB_DIRS}" -o -z "${LOCALBASE}" ]; then
echo "LIB_DIRS, LOCALBASE required in environment." >&2
exit 1
fi
if [ $# -ne 1 ]; then
echo "$0: no argument provided." >&2
fi
lib=$1
dirs="${LIB_DIRS} `cat ${LOCALBASE}/libdata/ldconfig/* 2>/dev/null || :`"
absolute_path() {
local file myifs target
file=$1
myifs=${IFS}
IFS='/'
set -- ${file}
IFS=${myifs}
for el; do
case $el in
.) continue ;;
'') continue ;;
..) target=${target%/*} ;;
*) target="${target}/${el}" ;;
esac
done
echo ${target}
}
for libdir in ${dirs} ; do
test -f ${libdir}/${lib} || continue
libfile=${libdir}/${lib}
[ `file -b -L --mime-type ${libfile}` = "application/x-sharedlib" ] || continue
echo $libfile
break
done