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
0fa112b4
Commit
0fa112b4
authored
4 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
RF: Only create wrappers if env vars look correct - $FSLDIR == $PREFIX, and
FSL_CREATE_WRAPPER_SCRIPTS is non-empty. Use
parent
9ba303fd
No related branches found
No related tags found
1 merge request
!1
Enh/create wrapper
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
etc/fslconf/createFSLWrapper.sh
+64
-50
64 additions, 50 deletions
etc/fslconf/createFSLWrapper.sh
etc/fslconf/removeFSLWrapper.sh
+1
-1
1 addition, 1 deletion
etc/fslconf/removeFSLWrapper.sh
with
65 additions
and
51 deletions
etc/fslconf/createFSLWrapper.sh
+
64
−
50
View file @
0fa112b4
#!/
bin/
sh
#!/
usr/bin/env ba
sh
#
#
# Create wrapper scripts in $FSLDIR/share/fsl/bin/ which invoke commands that
# Create wrapper scripts in $FSLDIR/share/fsl/bin/ which invoke commands that
# are installed in $FSLDIR/bin/.
# are installed in $FSLDIR/bin/.
...
@@ -12,6 +12,13 @@
...
@@ -12,6 +12,13 @@
# fslinstaller.py script - it is not intended to be used when individual
# fslinstaller.py script - it is not intended to be used when individual
# FSL projects are explicitly installed into a custom conda environment.
# FSL projects are explicitly installed into a custom 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.
# -
#
# Early versions of this script would create symlinks from $FSLDIR/bin/ into
# Early versions of this script would create symlinks from $FSLDIR/bin/ into
# $FSLDIR/fslpython/envs/fslpython/bin/ (and, later, into
# $FSLDIR/fslpython/envs/fslpython/bin/ (and, later, into
# $FSLDIR/share/fsl/bin/). However, wrapper scripts are now used instead to
# $FSLDIR/share/fsl/bin/). However, wrapper scripts are now used instead to
...
@@ -30,64 +37,71 @@
...
@@ -30,64 +37,71 @@
# to have a shebang line pointing to $FSLDIR/bin/python which does not
# to have a shebang line pointing to $FSLDIR/bin/python which does not
# exceed 127 characters.
# exceed 127 characters.
# Only create wrappers if the FSL_CREATE_WRAPPER_SCRIPTS
# environment variable is set
if
[
-z
"
$FSL_CREATE_WRAPPER_SCRIPTS
"
]
;
then
exit
0
fi
# Only create wrappers if FSLDIR exists
if
[
!
-d
"
$FSLDIR
"
]
;
then
exit
0
fi
# and if FSLDIR == PREFIX
if
[
"
$FSLDIR
"
!=
"
$PREFIX
"
]
;
then
exit
0
fi
# Names of all executables for which wrapper
# Names of all executables for which wrapper
# scripts are to be created are passed as
# scripts are to be created are passed as
# arguments
# arguments
targets
=
$@
targets
=
$@
# Only create wrappers if scripts
for
script
in
$targets
;
do
# are in subdirectory of FSLDIR
sourceScript
=
"
${
PREFIX
}
/bin/
$script
"
if
[
-z
"
$FSLDIR
"
]
;
then
targetScript
=
"
${
FSLDIR
}
/share/fsl/bin/
$script
"
exit
1
fi
case
"
$PREFIX
"
in
"
$FSLDIR
"
*
)
for
script
in
$targets
;
do
sourceScript
=
"
${
PREFIX
}
/bin/
$script
"
targetScript
=
"
${
FSLDIR
}
/share/fsl/bin/
$script
"
if
[
!
-f
"
$sourceScript
"
]
;
then
if
[
!
-f
"
$sourceScript
"
]
;
then
continue
continue
fi
fi
# create share/fsl/bin/ if it doesn't
# create share/fsl/bin/ if it doesn't
# already exist
# already exist
if
[
!
-e
"
$FSLDIR
/share/fsl/bin"
]
;
then
if
[
!
-e
"
$FSLDIR
/share/fsl/bin"
]
;
then
mkdir
-p
"
$FSLDIR
/share/fsl/bin"
mkdir
-p
"
$FSLDIR
/share/fsl/bin"
fi
fi
# remove target script if it already exists
# remove target script if it already exists
if
[
-e
"
$targetScript
"
]
;
then
if
[
-e
"
$targetScript
"
]
;
then
rm
"
$targetScript
"
rm
"
$targetScript
"
fi
fi
# Figure out whether this is a python
# Figure out whether this is a python
# executable or some other type of
# executable or some other type of
# executable. We search for these strings
# executable. We search for these strings
# in source file headers to ID them as
# in source file headers to ID them as
# python scripts. We need to check both
# python scripts. We need to check both
# match "#!/usr/bin/env python" and
# match "#!/usr/bin/env python" and
# "#!<fsldir>/bin/python...", because
# "#!<fsldir>/bin/python...", because
# conda might generate one or the other
# conda might generate one or the other
# in different scenarios.
# in different scenarios.
id1
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
"#!/usr/bin/env python"
)
id1
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
"#!/usr/bin/env python"
)
id2
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
"
/fslpython
/bin/python"
)
id2
=
$(
head
-c
1024
"
$sourceScript
"
|
grep
"
#!
${
FSLDIR
%/
}
/bin/python"
)
# Non-python executable - use a
# Non-python executable - use a
# pass-through script
# pass-through script
if
[
-z
"
$id1
"
]
&&
[
-z
"
$id2
"
]
;
then
if
[
-z
"
$id1
"
]
&&
[
-z
"
$id2
"
]
;
then
echo
"#!/bin/
sh"
>
"
$targetScript
"
echo
"#!/
usr/
bin/
env bash"
>
"
$targetScript
"
echo
"
$FSLDIR
/bin/
$script
\
"
$@
\"
"
>>
"
$targetScript
"
echo
"
$FSLDIR
/bin/
$script
"
'
"$@"
'
>>
"
$targetScript
"
else
else
# Python executable - run it via
# Python executable - run it via
# $FSLDIR/bin/python in isolated mode
# $FSLDIR/bin/python in isolated mode
echo
"#!/bin/
sh"
>
"
$targetScript
"
echo
"#!/
usr/
bin/
env bash"
>
"
$targetScript
"
echo
"
$FSLDIR
/bin/python -I
$sourceScript
\
"
$@
\"
"
>>
"
$targetScript
"
echo
"
$FSLDIR
/bin/python -I
$sourceScript
"
'
"$@"
'
>>
"
$targetScript
"
fi
fi
# Preserve file permissions
# Preserve file permissions
chmod
--reference
=
"
$sourceScript
"
"
$targetScript
"
chmod
--reference
=
"
$sourceScript
"
"
$targetScript
"
done
done
esac
This diff is collapsed.
Click to expand it.
etc/fslconf/removeFSLWrapper.sh
+
1
−
1
View file @
0fa112b4
#!/
bin/
sh
#!/
usr/bin/env ba
sh
#
#
# Remove wrapper script/links in $FSLDIR/share/fsl/bin/ which invoke commands
# Remove wrapper script/links in $FSLDIR/share/fsl/bin/ which invoke commands
# that are installed in $FSLDIR/bin/. See createFSLWrapper.sh for more
# that are installed in $FSLDIR/bin/. See createFSLWrapper.sh for more
...
...
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