Skip to content

Commit

Permalink
Fixes to support PREFIX containing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Feb 1, 2022
1 parent 2cc05a5 commit 5b320df
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Installs __NAME__ __VERSION__
"

if which getopt > /dev/null 2>&1; then
OPTS=$(getopt bifhkp:sut "$*" 2>/dev/null)
OPTS=$(getopt bifhkp:sut "$@" 2>/dev/null)
if [ ! $? ]; then
printf "%s\\n" "$USAGE"
exit 2
Expand Down Expand Up @@ -348,13 +348,6 @@ EOF
fi
fi # !BATCH

case "$PREFIX" in
*\ * )
printf "ERROR: Cannot install into directories with spaces\\n" >&2
exit 1
;;
esac

if [ "$FORCE" = "0" ] && [ -e "$PREFIX" ]; then
printf "ERROR: File or directory already exists: '%s'\\n" "$PREFIX" >&2
printf "If you want to update an existing installation, use the -u option.\\n" >&2
Expand All @@ -363,7 +356,6 @@ elif [ "$FORCE" = "1" ] && [ -e "$PREFIX" ]; then
REINSTALL=1
fi


if ! mkdir -p "$PREFIX"; then
printf "ERROR: Could not create directory: '%s'\\n" "$PREFIX" >&2
exit 1
Expand Down Expand Up @@ -432,7 +424,7 @@ chmod +x "$CONDA_EXEC"

export TMP_BACKUP="$TMP"
export TMP=$PREFIX/install_tmp
mkdir -p $TMP
mkdir -p "$TMP"

# the second binary payload: the tarball of packages
printf "Unpacking payload ...\n"
Expand Down Expand Up @@ -484,8 +476,8 @@ CONDA_PKGS_DIRS="$PREFIX/pkgs" \
"$CONDA_EXEC" install --offline --file "$PREFIX/pkgs/env.txt" -yp "$PREFIX" || exit 1

if [ "$KEEP_PKGS" = "0" ]; then
rm -fr $PREFIX/pkgs/*.tar.bz2
rm -fr $PREFIX/pkgs/*.conda
rm -f "$PREFIX/pkgs/*.tar.bz2"
rm -f "$PREFIX/pkgs/*.conda"
fi

__INSTALL_COMMANDS__
Expand All @@ -494,14 +486,14 @@ POSTCONDA="$PREFIX/postconda.tar.bz2"
"$CONDA_EXEC" constructor --prefix "$PREFIX" --extract-tarball < "$POSTCONDA" || exit 1
rm -f "$POSTCONDA"

rm -f $PREFIX/conda.exe
rm -f $PREFIX/pkgs/env.txt
rm -f "$CONDA_EXEC"
rm -f "$PREFIX/pkgs/env.txt"

rm -rf $PREFIX/install_tmp
rm -rf "$PREFIX/install_tmp"
export TMP="$TMP_BACKUP"

#if has_conda
mkdir -p $PREFIX/envs
mkdir -p "$PREFIX/envs"
#endif

#The templating doesn't support nested if statements
Expand Down Expand Up @@ -532,7 +524,7 @@ if [ "$KEEP_PKGS" = "0" ]; then
else
# Attempt to delete the empty temporary directories in the package cache
# These are artifacts of the constructor --extract-conda-pkgs
find $PREFIX/pkgs -type d -empty -exec rmdir {} \; 2>/dev/null || :
find "$PREFIX/pkgs" -type d -empty -exec rmdir {} \; 2>/dev/null || :
fi

printf "installation finished.\\n"
Expand Down Expand Up @@ -578,8 +570,8 @@ if [ "$BATCH" = "0" ]; then
printf "\\n"
else
case $SHELL in
*zsh) $PREFIX/bin/conda init zsh ;;
*) $PREFIX/bin/conda init ;;
*zsh) "$PREFIX/bin/conda" init zsh ;;
*) "$PREFIX/bin/conda" init ;;
esac
fi
printf "If you'd prefer that conda's base environment not be activated on startup, \\n"
Expand Down

0 comments on commit 5b320df

Please sign in to comment.