Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement build-install (as per #79) #418

Merged
merged 6 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Implement build-install
I'm still missing the bash and zsh completions
  • Loading branch information
paulo-ferraz-oliveira committed May 4, 2023
commit 1ef5e91579f4e70fa286e26baaf3a52fbb8f0691
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ Activation will backup your $PATH, prepend it with the installation's bin/
directory. Thus it's only valid for the current shell session, and until you
activate another installation or call `kerl_deactivate`.

**Note**: alternatively you can use `kerl build-install` as a shortcut for
the two previous actions to be played in sequence.

$ kerl build-install
usage: ./kerl build-install <release> [build_name] [directory]

$ kerl build-install git
usage: ./kerl build-install git <git_url> <git_version> [build_name] [directory]

You're now ready to work with your 19.2 installation:

$ erl -version
Expand Down
59 changes: 59 additions & 0 deletions kerl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ usage() {
stderr 'Valid commands are:'
stderr ' build Build specified release or git repository'
stderr ' install Install the specified release at the given location'
stderr ' build-install Builds and installs the specified release or git repository at the given location'
stderr ' deploy Deploy the specified installation to the given host and location'
stderr ' update Update the list of available releases from your source provider'
stderr ' list List releases, builds and installations'
Expand Down Expand Up @@ -1165,6 +1166,38 @@ _do_build() {
fi
}

do_build_install() {
if [ "$1" = "git" ]; then
build_name="$4"
else
build_name="$2"
fi

if is_valid_installation "$build_name"; then
l=e stderr "There's already an installation named $build_name. Skipping build step..."
exit 1
fi

if [ "$1" = "git" ]; then
git_url="$2"
git_version="$3"
directory="$5"
$0 build git "$git_url" "$git_version" "$build_name"
else
release=$1
directory="$3"
$0 build "$release" "$build_name"
fi

status=$?
if [ $status -ne 0 ]; then
l=e stderr "Build failed! Skipping install step..."
exit 1
fi

$0 install "$build_name" "$directory"
}

do_install() {
if ! rel=$(get_release_from_name "$1"); then
l=e stderr "No build named $1"
Expand Down Expand Up @@ -2359,6 +2392,32 @@ case "$1" in
fi
fi
;;
build-install)
# naming contains _or_ because do_build_install either accepts $1 as "git" or otherwise
build_name_or_git_url="$3"
build_name="$5"
if [ "$2" = "git" ]; then
if [ $# -eq 4 ]; then
build_name="$4"
elif [ $# -ne 5 ]; then
l=e stderr "usage: $0 $1 $2 <git_url> <git_version> [build_name] [directory]"
exit 1
fi
else
if [ $# -eq 2 ]; then
build_name_or_git_url="$2"
elif [ $# -ne 3 ]; then
l=e stderr "usage: $0 $1 <release> [build_name] [directory]"
exit 1
fi
fi
if [ -z "$KERL_DEFAULT_INSTALL_DIR" ]; then
directory="$PWD"
else
directory="$KERL_DEFAULT_INSTALL_DIR/$2"
fi
do_build_install "$2" "$build_name_or_git_url" "$4" "$build_name" "$directory"
;;
install)
if [ $# -lt 2 ]; then
l=e stderr "usage: $0 $1 <build_name> [directory]"
Expand Down