Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 70f0ac5a authored by hhakim's avatar hhakim
Browse files

Add a new postinstall script specific to macOS.

The previous general one works only for Linux.
parent bbd03582
Branches
Tags
No related merge requests found
......@@ -840,7 +840,7 @@ ELSE(WIN32 AND NOT UNIX)
endif()
if(BUILD_WRAPPER_PYTHON)
# prepare the script allowing the user to avoid PYTHONPATH setting
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/postinst_py.sh ${PROJECT_BINARY_DIR}/postinstall2 @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/macosx/postinst_py.sh ${PROJECT_BINARY_DIR}/postinstall2 @ONLY)
file(READ ${PROJECT_BINARY_DIR}/postinstall2 POSTINST2_LINES)
file(APPEND ${PROJECT_BINARY_DIR}/postinstall "${POSTINST2_LINES}")
file(REMOVE ${PROJECT_BINARY_DIR}/postinstall2)
......@@ -858,7 +858,7 @@ ELSE(WIN32 AND NOT UNIX)
endif()
if(BUILD_WRAPPER_PYTHON)
# prepare the script allowing the user to avoid PYTHONPATH setting
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/postinst_py.sh ${PROJECT_BINARY_DIR}/postinst2 @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/misc/binpkg_postinst_scripts/debrpm/postinst_py.sh ${PROJECT_BINARY_DIR}/postinst2 @ONLY)
file(READ ${PROJECT_BINARY_DIR}/postinst2 POSTINST2_LINES)
file(APPEND ${PROJECT_BINARY_DIR}/postinst "${POSTINST2_LINES}")
file(REMOVE ${PROJECT_BINARY_DIR}/postinst2)
......
#!/bin/bash
uid=$(id -u)
[[ ! "$uid" = 0 ]] && echo "Error: need to be root." >&2 && exit 1 # not needed, we're supposed to be root at installation time
[[ -n "$1" && -d "$1" ]] && FAUST_PY_WRAPPER_PATH="$1" || FAUST_PY_WRAPPER_PATH="@CMAKE_INSTALL_PYTHON_PREFIX@"
[[ -z "$FAUST_PY_WRAPPER_PATH" ]] && echo "USAGE: $0 <path>" && exit 2 # shouldn't happen with cmake
[[ ! -d "$FAUST_PY_WRAPPER_PATH" ]] && echo "ERROR: directory $FAUST_PY_WRAPPER_PATH doesn't exist" && exit 3 # shouldn't happen with cmake
function link_py_files(){
PYTHON=$1
[[ -n "$DEBUG" ]] && echo PYTHON=$PYTHON
[[ -d "$PYTHON" ]] && return
PY_MAJOR_MINOR_VER=$($PYTHON --version 2>&1 | sed -e 's/.*[[:blank:]]\{1,\}\([[:digit:]]\.[[:digit:]]\)\.[[:digit:]]\{1,\}/\1/')
PY_SITE_PACKAGES_PATH=$($PYTHON -c 'import os,site,re;print([path for path in site.getsitepackages() if re.match(".*"+os.path.sep+"site-packages$", path) and os.path.exists(path) ][0])')
[[ ! -d "${PY_SITE_PACKAGES_PATH}" ]] && return
[[ -n "$DEBUG" ]] && echo PY_SITE_PACKAGES_PATH=${PY_SITE_PACKAGES_PATH}
PYFILES=${FAUST_PY_WRAPPER_PATH}/FaustPy.py
[[ "$PY_MAJOR_MINOR_VER" = 3* ]] && PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.cpython-3*so" || \
PYFILES+=" ${FAUST_PY_WRAPPER_PATH}/FaustCorePy.so"
for PYFILE in $PYFILES
do
[[ -n "$DEBUG" ]] && echo ln -sf "$PYFILE" "${PY_SITE_PACKAGES_PATH}/"
[[ -r "$PYFILE" ]] && ln -sf "$PYFILE" "${PY_SITE_PACKAGES_PATH}/"
done && echo "Linked py wrapper version $PY_MAJOR_MINOR_VER into ${PY_SITE_PACKAGES_PATH}."
}
# python on macOS is always in /usr/local or /opt/local with macports
for DIR in /usr/local /opt/local
do
for FILE in $(find $DIR -type l -name "python*") $(find $DIR -type f -name "python*")
do
[[ -x "$FILE" ]] && link_py_files "$FILE"
done
done
echo
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment