Unverified Commit 3bc26814 authored by porres's avatar porres Committed by GitHub
Browse files

Merge pull request #7 from reduzent/linuxdep2

Linuxdep2
parents d3486a17 7be0910d
......@@ -10,12 +10,6 @@ define forWindows
endef
define forLinux
datafiles += scripts/localdeps.linux.sh
endef
define forDarwin
datafiles += scripts/localdeps.macos.sh
......@@ -32,4 +26,4 @@ localdep_windows: install
cd "${installpath}"; ./windep.sh fluidsynth~.dll
localdep_linux: install
cd "${installpath}"; /bin/sh localdeps.linux.sh fluidsynth~.pd_linux
scripts/localdeps.linux.sh "${installpath}/fluidsynth~.pd_linux"
......@@ -105,14 +105,16 @@ cd build
cmake -Denable-libsndfile=on -Denable-jack=off -Denable-alsa=off -Denable-oss=off -Denable-pulseaudio=off -Denable-ladspa=off -Denable-aufile=off -Denable-network=off -Denable-ipv6=off -Denable-getopt=off -Denable-sdl2=off -Denable-threads=off ..
sudo make install
`````
**Note** for arch `amd64`: If you installed fluidsynth for the first time, it might be necessary to update your
library paths by executing `sudo ldconfig /usr/local/lib64`.
then `cd` to the sources of this repo and do (change the pgklibdir path according to your needs):
Then `cd` to the sources of this repo and do (change `PDLIBDIR` according to your needs):
`make pkglibdir=$HOME/Pd/externals install`
`make PDLIBDIR=$HOME/Pd/externals install`
Now you can copy all dependencies of `fluidsynth~.pd_linux` to the install path by running:
`make pkglibdir=$HOME/Pd/externals localdep_linux`
`make PDLIBDIR=$HOME/Pd/externals localdep_linux`
The result can be uploaded to Deken, since it runs also on systems where the fluidsynth library is not installed.
......
......@@ -5,26 +5,20 @@
# each other.
#
# usage: $0 <binary>
#
# Author: Roman Haefeli <reduzent@gmail.com>
usage() {
echo "Usage: ${0} <binary> [ <binary2> ... ]"
echo " copies the local dependencies of all given binaries besides them"
}
case $1 in
"")
echo "Usage: /bin/sh ${0} <binary>"
exit
;;
*)
binary_file=$1
;;
esac
if [ $# -lt 1 ]; then
usage
exit 1
fi
# List of libraries that we do not include into our packaging
# becaue we think they will be installed on any system
LD_EXCLUDE_LIST="linux-gate\.so.*
linux-vdso\.so.*
ld_exclude_list="libc\.so\.*
libarmmem.*\.so.*
libc.so\.*
ld-linux.*\.so.*
libdl\.so.*
libglib-.*\.so.*
libgomp\.so.*
......@@ -35,124 +29,71 @@ libstdc++\.so.*
libgcc_s\.so.*
libpcre\.so.*"
error() {
echo "$@" 1>&2
}
# Check dependencies
cmdlist="awk grep ldd patchelf uname"
for cmd in $cmdlist
do
if ! which $cmd > /dev/null
then
echo "Could not find ${cmd}. Is it installed?" > /dev/stderr
exit 1
fi
cmdlist="awk grep ldd patchelf"
for cmd in $cmdlist; do
if ! which "${cmd}" > /dev/null; then
error "Could not find ${cmd}. Is it installed?"
exit 1
fi
done
# Set LD_LIBRARY_PATH depending on arch
ARCH=$(uname -m)
case $ARCH in
"x86_64")
LD_LIBRARY_PATH="$HOME/.local/lib:/usr/local/lib64:/usr/lib/x86_64-linux-gnu"
;;
"i686")
LD_LIBRARY_PATH="$HOME/.local/lib:/usr/local/lib:/usr/lib/i386-linux-gnu"
;;
"armv7l")
LD_LIBRARY_PATH="$HOME/.local/lib:/usr/local/lib:/usr/lib/arm-linux-gnueabihf"
;;
*)
echo "Arch '$ARCH' not (yet) supported. Please file a bug report"
exit 1
esac
# Check if we can read from given file
if ! ldd $binary_file > /dev/null 2>&1
then
echo "Can't read '${binary_file}'. Is it a binary file?" > /dev/stderr
exit 1
fi
library_in_exclude_list() {
# arg1: library name
# returns 0 if arg1 is found in exclude list, otherwise 1
libexname="$1"
skip=1
set -f
for expat in $(echo "$LD_EXCLUDE_LIST")
do
if echo "$(basename $libexname)" | grep "${expat}" > /dev/null
then
skip=0
break
fi
done
set +f
return $skip
}
search_make_local_copy() {
# look for given library in all library paths
# and make a local copy of it
# arg1: name of the library to make a local copy of
found=false
IFSold=$IFS
IFS=:
for path in ${LD_LIBRARY_PATH}
do
[ -f "${path}/$1" ] && cp "${path}/$1" . && found=true && break
done
IFS=$IFSold
if ! $found
then
echo "$1 not found" > /dev/stderr
exit 1
fi
# arg1: library name
# returns 0 if arg1 is found in exclude list, otherwise 1
local libexname="$1"
skip=1
set -f
for expat in $(echo "${ld_exclude_list}"); do
if echo "$(basename $libexname)" | grep "${expat}" > /dev/null; then
skip=0
break
fi
done
set +f
return $skip
}
make_local_copy_and_set_rpath() {
# make a local copy of all linked libraries of given binary
# and set RUNPATH to $ORIGIN (exclude "standard" libraries)
# arg1: binary to check
ldd $1 | while read ldd_line
do
libname=$(echo "$ldd_line" | awk '{ print $1 }')
libpath=$(echo "$ldd_line" | awk '{ print $3 }')
if ! [ -f "$(basename $libname)" ] && ! library_in_exclude_list "$libname"
then
if [ "$libpath" != "" ]
then
cp "$libpath" .
elif echo "$libname" | grep '/' > /dev/null
then
cp "$libname" .
else
echo "Warning: could not make copy of '$libname'. Not found"
fi
fi
if ! library_in_exclude_list "$libname"
then
patchelf --set-rpath \$ORIGIN "$(basename $libname)"
# make a local copy of all linked libraries of given binary
# and set RUNPATH to $ORIGIN (exclude "standard" libraries)
# arg1: binary to check
local outdir
outdir=$(dirname "$1")
if [ ! -d "${outdir}" ]; then
outdir=.
fi
done
ldd "$1" | grep ' => ' | while read _ _ libpath _; do
libname=$(basename "${libpath}")
outfile="${outdir}/${libname}"
if library_in_exclude_list "${libname}"; then
continue
fi
if [ ! -e "${libpath}" ]; then
error "DEP: ${INSTALLDEPS_INDENT} WARNING: could not make copy of '${libpath}'. Not found"
continue
fi
if [ -e "${outfile}" ]; then
error "DEP: ${INSTALLDEPS_INDENT} ${libpath} SKIPPED"
else
error "DEP: ${INSTALLDEPS_INDENT} ${libpath} -> ${outdir}/"
cp "${libpath}" "${outfile}"
patchelf --set-rpath \$ORIGIN "${outfile}"
fi
done
patchelf --set-rpath \$ORIGIN "${1}"
}
find_missing() {
# find libraries that are shown as 'not found' in ldd and
# create a local copy of them.
# arg1: binary file to check for missing links
while true
do
ldd_output=$(ldd ${1})
if echo "$ldd_output" | grep '=> not found' > /dev/null
then
next_missing=$(echo "$ldd_output" | grep '=> not found' | head -n1 | awk '{print $1}')
search_make_local_copy "$next_missing"
else
break
fi
done
}
find_missing $binary_file
make_local_copy_and_set_rpath $binary_file
# clean after ourselves
rm $0
for binary_file in "$@"; do
# Check if we can read from given file
if ! ldd "${binary_file}" > /dev/null 2>&1; then
error "Skipping '${binary_file}'. Is it a binary file?"
continue
fi
make_local_copy_and_set_rpath $binary_file
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment