Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions tools/build/install_fs_pruned.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ else THIS_SCRIPT="${BASH_SOURCE[0]}"
fi
# Link where to find the FreeSurfer tarball:
fslink="default"
insecure="false"

if [[ "$#" -lt 1 ]]; then
echo
echo "Usage: install_fs_pruned.sh install_dir [--upx] [--url freesurfer_download_url]"
echo "Usage: install_fs_pruned.sh install_dir [--upx] [--url freesurfer_download_url] [--insecure]"
echo
echo "--upx is optional, if passed, fs/bin will be packed"
echo "--url is recommended! This is the download link for freesurfer."
echo " The link can be found in pyproject.toml:tool.freesurfer.url!"
echo "--insecure will skip certificate checks when downloading freesurfer."
echo
exit 2
fi
Expand All @@ -39,6 +41,7 @@ while [[ "$#" -ge 1 ]]; do
case $lowercase in
--upx) upx="true" ; shift ;;
--url) fslink=$2 ; shift ; shift ;;
--insecure) insecure="true" ; shift ;;
*) echo "Invalid argument $1" ; exit 1 ;;
esac
done
Expand Down Expand Up @@ -99,9 +102,17 @@ if [[ -f "$freesurfer_dl" ]] ; then
echo "Found cached download $freesurfer_dl, using that ..."
else
# dl aria2c if that exists, else wget or curl
if [[ -n "$(which aria2c)" ]] ; then dl=(aria2c -cx 16 -s 16 --check-certificate=false -o "$freesurfer_dl" "$fslink")
elif [[ -n "$(which wget)" ]] ; then dl=(wget --no-check-certificate -qO- "$fslink" -O "$freesurfer_dl")
else dl=(curl -L --insecure "$fslink" -o "$freesurfer_dl")
cert=()
if [[ -n "$(which aria2c)" ]] ; then
if [[ "$insecure" == "true" ]] ; then cert=("--check-certificate=false") ; fi
# shellcheck disable=SC2206
dl=(aria2c -c -x 16 -s 16 "${cert[@]}" -o "$freesurfer_dl" "$fslink")
elif [[ -n "$(which wget)" ]] ; then
if [[ "$insecure" == "true" ]] ; then cert=("--no-check-certificate") ; fi
dl=(wget "${cert[@]}" -qO- "$fslink" -O "$freesurfer_dl")
else
if [[ "$insecure" == "true" ]] ; then cert=("--insecure") ; fi
dl=(curl -L "${cert[@]}" "$fslink" -o "$freesurfer_dl")
fi

echo "Downloading FreeSurfer from $fslink with ${dl[0]}..."
Expand All @@ -110,7 +121,8 @@ fi


if [[ ! -f "$freesurfer_dl" ]] ; then
echo "ERROR: Downloading FreeSurfer failed! This is not recoverable, see message above and retry!"
echo "ERROR: Downloading FreeSurfer failed, maybe due to a certificate error (consider --insecure)!"
echo " This is not recoverable, see message above and retry!"
exit 1
fi

Expand Down
6 changes: 5 additions & 1 deletion tools/macos_build/build_release_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ sed -e "s|<fastsurfer_home_dir>|${PATH_TO_FASTSURFER}|g" \
-e "s|<homebrew_dir>|$HOMEBREW_DIR|g" \
< "$SCRIPTS_DIR/postinstall.sh.template" \
> "$SCRIPTS_DIR/postinstall"
# copy link_fs script (do not keep double copies, so delete after build)
cp "$tools_dir/build/link_fs.sh" "$SCRIPTS_DIR/link_fs.sh"

chmod +x "$SCRIPTS_DIR/postinstall"

Expand Down Expand Up @@ -129,8 +131,10 @@ mkdir -p "$build_dir/installer"
productbuild \
--distribution "$DISTRIBUTION_FILE" \
--resources "$RESOURCES_DIR" \
--package-path $build_dir/raw_package \
--package-path "$build_dir/raw_package" \
"$INSTALLER_PKG"

# get rid of temporary folder
rm -rf "$STAGED_DIR" "$RESOURCES_DIR" "$build_dir/dist" "$build_dir/build"
# remove the previously copied link_fs.sh script
rm "$SCRIPTS_DIR/link_fs.sh"
75 changes: 0 additions & 75 deletions tools/macos_build/scripts/link_fs.sh

This file was deleted.

6 changes: 5 additions & 1 deletion tools/macos_build/scripts/postinstall.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export PYTHONPATH="${FASTSURFER_HOME}:${PYTHONPATH}"
"$PYTHON" "$FASTSURFER_HOME/FastSurferCNN/download_checkpoints.py" --all

FREESURFER_HOME="/Applications/freesurfer"
"$SCRIPT_DIR/link_fs.sh" "$FASTSURFER_HOME/venv/bin/$PYTHON" "$FREESURFER_HOME"
"$SCRIPT_DIR/link_fs.sh" "$FREESURFER_HOME"

# use our python (not really needed in recon-all anyway)
# TODO: soft-linking python has proven to break the python installation for the docker container
ln -sf "$FASTSURFER_HOME/venv/bin/$PYTHON" "$FREESURFER_HOME/bin/fspython"

sed -i '' -e "s|(venv)|($(basename $FASTSURFER_HOME))|g" "$FASTSURFER_HOME/venv/bin/activate"

Expand Down
1 change: 1 addition & 0 deletions tools/macos_build/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
py_modules=[],
)