diff --git a/Packaging/Files/linux_pkgsetup.in b/Packaging/Files/linux_pkgsetup.in index 198b112a3dab30cf3c2e1639962d7efe09a691f9..50dc0b21ef7a23a6f77ffb711acb8d707a72ca9c 100644 --- a/Packaging/Files/linux_pkgsetup.in +++ b/Packaging/Files/linux_pkgsetup.in @@ -20,6 +20,17 @@ # set -e +# verify basic tools are here +which 2>/dev/null || ret=$? +if [ ! $ret -eq 0 ] ; then echo "ERROR: Missing tool 'which'"; exit 1 ; fi +for tool in dirname find file grep cut sed chmod cat readlink ; do + if [ -z "$(which $tool)" ] ; then + echo "ERROR: Missing tool '${tool}'" + echo "Please install it and make sure it can be found from PATH" + exit 1; + fi +done + DIRNAME_0=$(dirname "$0") cd "$DIRNAME_0" @@ -32,20 +43,16 @@ PATCH_ELF_EXE="$OUT_DIR/patchelf" #do not move below block. it must be before "unset LD_LIBRARY_PATH" code #check if we have any python bindings -OTB_PYTHON_LIB_PATH= if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ] ; then - sed -i "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/setup_python.sh" chmod +x $OUT_DIR/setup_python.sh - . ./setup_python.sh - OTB_PYTHON_LIB_PATH=$OUT_DIR/lib/python + ./setup_python.sh || setup_python_ret=$? fi # No no interference with LD_LIBRARY_PATH unset LD_LIBRARY_PATH -#RK: We cannot avoid -maxdepth 1 option in find command below because, -# there are files in $OUT_DIR/lib/gtk which we CANNOT add new rpath -BINARY_FILES=$(find $OTB_PYTHON_LIB_PATH $OUT_DIR/lib $OUT_DIR/bin $OUT_DIR/lib/otb/applications -maxdepth 1 -type f -exec file {} \; | grep -i elf|cut -f1 -d':') +# we remove files in $OUT_DIR/lib/gtk which we CANNOT add new rpath +BINARY_FILES=$(find $OUT_DIR/lib $OUT_DIR/bin -type f -exec file {} \; | grep -v '/lib/gtk/' | grep -i elf|cut -f1 -d':') # run patchelf for bin_file in $BINARY_FILES; do #echo "adding rpath to $bin_file" diff --git a/Packaging/Files/macx_pkgsetup.in b/Packaging/Files/macx_pkgsetup.in index 46606ffb164881b7afe4639c42cb1ff6ce3ab519..e01ff9fe3afca6b3b51fa2933c533ae4aef95b21 100755 --- a/Packaging/Files/macx_pkgsetup.in +++ b/Packaging/Files/macx_pkgsetup.in @@ -20,6 +20,17 @@ # set -e +# verify basic tools are here (install_name_tool is specific macOS) +which 2>/dev/null || ret=$? +if [ ! $ret -eq 0 ] ; then echo "ERROR: Missing tool 'which'"; exit 1 ; fi +for tool in dirname find file grep cut sed chmod cat readlink install_name_tool ; do + if [ -z "$(which $tool)" ] ; then + echo "ERROR: Missing tool '${tool}'" + echo "Please install it and make sure it can be found from PATH" + exit 1; + fi +done + DIRNAME_0=$(dirname "$0") cd "$DIRNAME_0" || exit 1 @@ -29,16 +40,9 @@ cd "$DIRNAME_0" || exit 1 OUT_DIR=$(pwd) #do not move below 3 lines. it must be before "unset LD_LIBRARY_PATH" code -sed -i "" "s,OUT_DIR,$OUT_DIR,g" "$OUT_DIR/setup_python.sh" -chmod +x $OUT_DIR/setup_python.sh -./setup_python.sh - -# find install_name_tool -INSTALL_NAME_TOOL=$(which install_name_tool) -if [ -z "$INSTALL_NAME_TOOL" ]; then - echo "install_name_tool does not exists.." - echo "please install install_name_tool and make sure it can be found from PATH" - exit 1; +if [ -f "$OUT_DIR/lib/python/_otbApplication.so" ] ; then + chmod +x $OUT_DIR/setup_python.sh + ./setup_python.sh || setup_python_ret=$? fi # no interference with DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH diff --git a/Packaging/Files/setup_python.sh b/Packaging/Files/setup_python.sh index 0b80e40356098303b56f7c42a5f80b6b62cdd786..e0f03205ed966f18365d144ed493f805f46eaffc 100755 --- a/Packaging/Files/setup_python.sh +++ b/Packaging/Files/setup_python.sh @@ -19,11 +19,20 @@ # limitations under the License. # +# get current working dir (this should be the install directory) +CWD=$(pwd) + # Setup python environment if [ ! -f "$OTB_PYTHON_EXE" ] ; then OTB_PYTHON_EXE=$(which python) fi +if [ ! -f "$OTB_PYTHON_EXE" ] ; then + printf %s\\n "*****Error occurred during installation******" + printf %s\\n "Python executable not found" + exit 1 +fi + python_major_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[0])") python_minor_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[1])") python_patch_version=$($OTB_PYTHON_EXE -c "import sys;print(sys.version_info[2])") @@ -35,6 +44,7 @@ python_check_failed() { printf %s\\n "If you have python2.6 or Python2.7 installed in your system " printf %s\\n "You should set OTB_PYTHON_EXE and re-run this installation script." printf %s\\n "eg: OTB_PYTHON_EXE=/path/to/python2.7 ./OTB-X.Y-Linux64.run" + exit 1 } if [ "$python_major_version" -gt 2 ]; then python_check_failed @@ -70,11 +80,12 @@ if [ "$found_python_lib" -eq "1" ]; then printf %s\\n "numpy not installed with '$OTB_PYTHON_EXE'" printf %s\\n "Check failed with result:" printf %s\\n "$numpy_import_result" + exit 1 else printf %s\\n "OTB python bindings will be configured for $OTB_PYTHON_EXE ( version: $python_version )" printf %s\\n "Found python library: $python_lib_file_path" fi - #ln -sf "$python_lib_file_path" "OUT_DIR/lib/$python_INSTALLED_SONAME" + #ln -sf "$python_lib_file_path" "$CWD/lib/$python_INSTALLED_SONAME" else printf %s\\n "*****Error occurred during installation******" printf %s\\n "Python interpreter detected is : $OTB_PYTHON_EXE ( version: $python_version )" @@ -82,5 +93,6 @@ else printf %s\\n "We had searched following directories $python_lib_dirs" printf %s\\n "If you don't have python-dev package installed, install it and make a symlink" printf %s\\n "If you don't have python headers and so installed on a custom location, then make a symlink" - printf %s\\n "eg: ln -s /usr/lib/x86_64-linux-gnu/$python_INSTSONAME OUT_DIR/lib/$python_INSTSONAME" + printf %s\\n "eg: ln -s /usr/lib/x86_64-linux-gnu/$python_INSTSONAME $CWD/lib/$python_INSTSONAME" + exit 1 fi