Skip to content
Snippets Groups Projects
Commit 925999d7 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Add env var checks to removeFSLWrapper. Add more documentation for

create/removeFSLWrapper scripts.
parent 61e74ede
No related branches found
No related tags found
1 merge request!1Enh/create wrapper
Pipeline #6234 passed
......@@ -3,26 +3,31 @@
# Create wrapper scripts in $FSLDIR/share/fsl/bin/ which invoke commands that
# are installed in $FSLDIR/bin/.
#
# This script is used to create isolated versions of all executables
# provided by FSL projects, so they can be added to the user $PATH without
# any other executables that are installed into the conda environment that
# is $FSLDIR/bin (for example, python, pip, tcl, etc).
# This script is used to create isolated versions of all executables provided
# by FSL projects, so they can be added to the user $PATH without any other
# executables that are installed into the FSL conda environment (for example,
# python, pip, tcl, etc).
#
# This script should only be invoked when FSL is being installed via the
# fslinstaller.py script - it is not intended to be used when individual
# FSL projects are explicitly installed into a custom conda environment.
# fslinstaller script - it is not intended to be used when individual FSL
# projects are explicitly installed into a custom conda environment.
#
# The fslinstaller script should ensure that the FSLDIR and
# FSL_CREATE_WRAPPER_SCRIPTS variables are set appropriately before creating
# the FSL conda environment.
#
# This script is intended to be called by the post-link.sh script of the conda
# recipe for each FSL project that provides executable commands.
#
# Wrapper scripts will only be created if the following conditions are met:
#
# - The $FSLDIR and $PREFIX environment variables are set, and
# are equivalent
# - The $FSL_CREATE_WRAPPER_SCRIPTS environment variable is set and is not
# empty.
# -
#
# Early versions of this script would create symlinks from $FSLDIR/bin/ into
# $FSLDIR/fslpython/envs/fslpython/bin/ (and, later, into
# $FSLDIR/share/fsl/bin/). However, wrapper scripts are now used instead to
# work around a couple of problems:
# Wrapper scripts, and not sym-links, are used to avoid a couple of potential
# problems:
#
# - We need python executables to exclusively use the libraries installed in
# the FSL conda environment. Users may have other Python environments
......@@ -37,6 +42,11 @@
# to have a shebang line pointing to $FSLDIR/bin/python which does not
# exceed 127 characters.
# Names of all executables for which wrapper
# scripts are to be created are passed as
# arguments
targets="$@"
# Only create wrappers if the FSL_CREATE_WRAPPER_SCRIPTS
# environment variable is set
if [ -z "$FSL_CREATE_WRAPPER_SCRIPTS" ]; then
......@@ -53,10 +63,6 @@ if [ "$FSLDIR" != "$PREFIX" ]; then
exit 0
fi
# Names of all executables for which wrapper
# scripts are to be created are passed as
# arguments
targets=$@
for script in $targets; do
sourceScript="${PREFIX}/bin/$script"
......
......@@ -3,21 +3,36 @@
# Remove wrapper script/links in $FSLDIR/share/fsl/bin/ which invoke commands
# that are installed in $FSLDIR/bin/. See createFSLWrapper for more
# information.
#
# This script is intended to be called by the pre-unlink.sh script of the
# conda recipe for each FSL project that provides executable commands.
# Names of all executables for which wrapper
# scripts are to be created are passed as
# arguments
targets="$@"
if [ -z "$FSLDIR" ]; then
exit 1
# Note that we don't check the FSL_CREATE_WRAPPER_SCRIPTS environment variable
# here. Wrapper scripts in $FSLDIR/share/fsl/bin/ will exist only if a
# FSL conda packages was installed in an environment where thenb
# FSL_CREATE_WRAPPER_SCRIPTS variable was set, so this script will simply
# delete any wrapper scripts that exist.
# Only remove wrappers if FSLDIR exists
if [ ! -d "$FSLDIR" ]; then
exit 0
fi
# Only remove if scripts are in subdirectory of FSLDIR
case "$PREFIX" in "$FSLDIR"*)
# and if FSLDIR == PREFIX
if [ "$FSLDIR" != "$PREFIX" ]; then
exit 0
fi
for script in $targets; do
targetScript="${FSLDIR}/share/fsl/bin/$script"
# Only remove if scripts are in subdirectory of FSLDIR
for script in $targets; do
targetScript="${FSLDIR}/share/fsl/bin/$script"
if [ -f "$targetScript" ]; then
rm "$targetScript"
fi
done
esac
if [ -f "$targetScript" ]; then
rm "$targetScript"
fi
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment