handle symlinks in install_binary

This commit is contained in:
illiliti 2020-03-09 17:56:14 +03:00
parent b14d9ed658
commit de8603e784

View File

@ -311,16 +311,29 @@ generate_depmod() {
install_binary() { install_binary() {
binary=$(command -v "$1") binary=$(command -v "$1")
realbin="$(dirname "$binary")/$(readlink "$binary")"
fullbin=$(readlink -f "$binary")
workdirbin="${workdir}/usr/bin/" workdirbin="${workdir}/usr/bin/"
# check if binary exists # check if binary exists
[ "$binary" ] || msg panic "$binary doesn't exists" [ "$binary" ] || msg panic "$binary doesn't exists"
# check if binary already installed # check if binary already installed
[ -e "${workdirbin}${binary##*/}" ] && return [ -e "${workdirbin}${fullbin##*/}" ] &&
return
# install symlinks if any
[ -h "$binary" ] && {
# symlink may link to symlink
[ -h "$realbin" ] &&
cp -a "$realbin" "$workdirbin"
cp -a "$binary" "$workdirbin"
}
# install and strip binary # install and strip binary
install -s -m755 "$binary" "${workdirbin}${binary##*/}" install -s -m755 "$fullbin" "${workdirbin}${fullbin##*/}"
# check static # check static
ldd "$binary" > /dev/null 2>&1 || return ldd "$binary" > /dev/null 2>&1 || return
@ -344,13 +357,12 @@ install_binary() {
install_library() { install_library() {
library="$1" library="$1"
reallib="/usr/lib/$(readlink "$library")" reallib="$(dirname "$library")/$(readlink "$library")"
fulllib=$(readlink -f "$library") fulllib=$(readlink -f "$library")
workdirlib="${workdir}/usr/lib/" workdirlib="${workdir}/usr/lib/"
# check if library already installed # check if library already installed
[ -e "${workdirlib}${fulllib##*/}" ] && [ -e "${workdirlib}${fulllib##*/}" ] &&
[ -e "${workdirlib}${library##*/}" ] &&
return return
# install symlinks if any # install symlinks if any