Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
base
Commits
5ab211b1
Commit
5ab211b1
authored
3 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New option in createFSLWrapper to generate wrapper script with different
name to executable
parent
7f432bca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!47
ENH: New option in createFSLWrapper to generate wrapper script with different name to executable
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
share/fsl/sbin/createFSLWrapper
+21
-54
21 additions, 54 deletions
share/fsl/sbin/createFSLWrapper
share/fsl/sbin/removeFSLWrapper
+20
-9
20 additions, 9 deletions
share/fsl/sbin/removeFSLWrapper
with
41 additions
and
63 deletions
share/fsl/sbin/createFSLWrapper
+
21
−
54
View file @
5ab211b1
#!/usr/bin/env bash
#
# Create wrapper scripts in $FSLDIR/share/fsl/bin/ which invoke commands that
# are installed in $FSLDIR/bin/.
# are installed in $FSLDIR/bin/.
Calling this script like:
#
# 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).
# createFSLWrapper command1 command2 command3
#
#
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.
#
will cause wrapper scripts to be created in $FSLDIR/share/fsl/bin/, which
#
call the commands of the same name in $FSLDIR/bin/, i.e.:
#
# This script should only be invoked when FSL is being installed via the
# 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.
#
# 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.
#
# 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
# activated, and/or libraries installed into a local site-packages
# directory. So we need to invoke the python interpreter in isolated mode,
# with the -I flag:
#
# https://docs.python.org/3/using/cmdline.html#id2
#
# - There is no guarantee that a shell supports shebang lines longer than 127
# characters. Depending on where FSL is installed, it may not be possible
# to have a shebang line pointing to $FSLDIR/bin/python which does not
# exceed 127 characters.
#
# Wrapper scripts are created for *all* FSL commands, including FSL TCL GUI
# commands (e.g. "fsl", "Flirt", "Flirt_gui", etc). FSL TCL GUIs are called
# (e.g.) "<Command>" om Linux, but "<Command>_gui" on macOS, because macOS
# file systems are usually case-sensitive.
#
# To work around this, and to not accidentally create a link called <Command>
# to <command>, the FSL package post link scripts must only specify
# "<Command>_gui", and *not* "<Command>". This script will create a wrapper
# script for the appropriate variant ("<Command>_gui" on macOS, or "<Command>"
# on Linux).
# $FSLDIR/share/fsl/bin/command1 calls $FSLDIR/bin/command1
# $FSLDIR/share/fsl/bin/command2 calls $FSLDIR/bin/command2
# Names of all executables for which wrapper
# scripts are to be created are passed as
...
...
@@ -75,16 +33,27 @@ if [ "${FSLDIR}" != "${PREFIX}" ]; then
fi
for
targetName
in
${
targets
}
;
do
for
target
in
${
targets
}
;
do
# A wrapper script with a different
# name to the target can be created
# by passing "targetName=wrapperName"
if
[[
"
${
target
}
"
==
*
"="
*
]]
;
then
wrapper
=
${
target
#*=
}
target
=
${
target
%=*
}
else
wrapper
=
${
target
}
fi
target
=
"
${
PREFIX
}
/bin/
${
targetName
}
"
target
=
"
${
FSLDIR
}
/bin/
${
target
}
"
wrapper
=
"
${
FSLDIR
}
/share/fsl/bin/
${
wrapper
}
"
# Wrapper script for a FSL TCL GUI - here,
# we remove the _gui suffix if the target
# file does not exist (in which case we are
# likely running on Linux).
if
[[
"
${
target
Name
}
"
==
*
"_gui"
]]
&&
[
!
-f
"
${
target
}
"
]
;
then
targetName
=
${
targetName
/%_gui
}
if
[[
"
${
target
}
"
==
*
"_gui"
]]
&&
[
!
-f
"
${
target
}
"
]
;
then
wrapper
=
${
wrapper
/%_gui
}
target
=
${
target
/%_gui
}
fi
...
...
@@ -97,8 +66,6 @@ for targetName in ${targets}; do
continue
fi
wrapper
=
"
${
FSLDIR
}
/share/fsl/bin/
${
targetName
}
"
# create share/fsl/bin/ if it doesn't
# already exist
if
[
!
-e
"
${
FSLDIR
}
/share/fsl/bin"
]
;
then
...
...
This diff is collapsed.
Click to expand it.
share/fsl/sbin/removeFSLWrapper
+
20
−
9
View file @
5ab211b1
#!/usr/bin/env bash
#
# Remove wrapper script/links in $FSLDIR/share/fsl/bin/ which invoke commands
# that are installed in $FSLDIR/bin/.
See createFSLWrapper for more
# 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
...
...
@@ -19,25 +19,36 @@ targets="$@"
# delete any wrapper scripts that exist.
# Only remove wrappers if FSLDIR exists
if
[
!
-d
"
$FSLDIR
"
]
;
then
if
[
!
-d
"
$
{
FSLDIR
}
"
]
;
then
exit
0
fi
# and if FSLDIR == PREFIX
if
[
"
$FSLDIR
"
!=
"
$PREFIX
"
]
;
then
if
[
"
$
{
FSLDIR
}
"
!=
"
$
{
PREFIX
}
"
]
;
then
exit
0
fi
# Only remove if scripts are in subdirectory of FSLDIR
for
script
in
$targets
;
do
targetScript
=
"
${
FSLDIR
}
/share/fsl/bin/
$script
"
for
target
in
${
targets
}
;
do
# A wrapper script with a different
# name to the target can be created
# by passing "targetName=wrapperName"
if
[[
"
${
target
}
"
==
*
"="
*
]]
;
then
wrapper
=
${
target
#*=
}
target
=
${
target
%=*
}
else
wrapper
=
${
target
}
fi
wrapper
=
"
${
FSLDIR
}
/share/fsl/bin/
${
wrapper
}
"
# See comment about FSL GUIs in post-link.sh
if
[[
"
$target
Script
"
==
*
"_gui"
]]
&&
[
!
-f
"
$
targetScript
"
]
;
then
targetScript
=
${
targetScript
/
_gui
/
}
if
[[
"
$
{
target
}
"
==
*
"_gui"
]]
&&
[
!
-f
"
$
{
wrapper
}
"
]
;
then
wrapper
=
${
wrapper
/%
_gui
}
fi
if
[
-f
"
$
targetScript
"
]
;
then
rm
"
$
targetScript
"
if
[
-f
"
$
{
wrapper
}
"
]
;
then
rm
"
$
{
wrapper
}
"
fi
done
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment