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 authored May 7, 2021
1 parent 1d1ee2d commit d70e561
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 @@ -64,7 +64,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 @@ -352,13 +352,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 @@ -367,7 +360,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 @@ -436,7 +428,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 @@ -488,8 +480,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 @@ -498,14 +490,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 @@ -536,7 +528,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 @@ -589,8 +581,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 d70e561

Please sign in to comment.