Skip to content

Commit

Permalink
Merge pull request #8 from mhanberg/master
Browse files Browse the repository at this point in the history
  • Loading branch information
richin13 authored Nov 20, 2020
2 parents 719a322 + a542ad0 commit 7ad0fb7
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 42 deletions.
34 changes: 34 additions & 0 deletions bin/download
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# shellcheck source=bin/utils.sh
source "$(dirname "$0")/utils.sh"

download_neovim() {
local install_type=$1
local version=$2
local download_path=$3
local tmp_download_dir
local archive_path

if [ "$TMPDIR" = "" ]; then
tmp_download_dir=$(mktemp -d -t neovim_build_XXXXXX)
else
tmp_download_dir=$TMPDIR
fi

archive_path=$(download_path "$version" "$tmp_download_dir")
download_version "$install_type" "$version" "$archive_path"

# running this in subshell
# we don't want to disturb current working dir
(
if ! type "tar" &>/dev/null; then
echo "ERROR: tar not found"
exit 1
fi

tar zxf "$archive_path" -C "$download_path" --strip-components=1 || exit 1
)
}

download_neovim "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_DOWNLOAD_PATH"
57 changes: 27 additions & 30 deletions bin/install
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
#!/usr/bin/env bash

source "$(dirname "$0")/utils.sh"

install_neovim() {
local install_type=$1
local version=$2
local install_path=$3
local concurrency=$3

if [ "$install_type" != "version" ]; then
echoerr "Cannot install specific ref from source, sorry."
echoerr "For a list of available versions, see \`asdf list-all neovim\`."
exit 1
fi
local install_type="$1"
local download_path="$2"
local install_path="$3"

if [ "$TMPDIR" = "" ]; then
local tmp_download_dir=$(mktemp -d -t neovim_build_XXXXXX)
if [ "$install_type" = "version" ]; then
# move the prebuilt artifact to the install path
mv -f "$download_path"/** "$install_path"
else
local tmp_download_dir=$TMPDIR
fi

echo "$tmp_download_dir"
local archive_path=$(download_path $version $tmp_download_dir)
download_version $version $archive_path

# running this in subshell
# we don't want to disturb current working dir
(
if ! type "tar" &>/dev/null; then
echo "ERROR: tar not found"
exit 1
fi
cd "$download_path" || exit 1

# compile neovim with some extra flags
# these flags add the install path to the rtp, allowing us to package up
# the runtime instead of installing it globally.
# I sourced these flags for the neovim/bot-ci repo, where the prebuilt
# artifacts are compiled.
if [[ "$OSTYPE" == "linux-gnu" ]]; then
make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX:PATH="
else
make CMAKE_BUILD_TYPE=Release \
CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX:PATH="
fi

make DESTDIR="${install_path}" install
)
fi

tar zxf $archive_path -C $install_path --strip-components=1 || exit 1
)
# delete the download path with -f. I noticed there are some files that it
# will prompt you to delete. This avoids that.
rm -rf "$download_path"
}

install_neovim "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" "$ASDF_CONCURRENCY"
install_neovim "$ASDF_INSTALL_TYPE" "$ASDF_DOWNLOAD_PATH" "$ASDF_INSTALL_PATH"
1 change: 1 addition & 0 deletions bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ git ls-remote --heads --tags https://github.com/neovim/neovim.git \
| sort_versions
)

# shellcheck disable=SC2086
echo $list_of_versions
39 changes: 27 additions & 12 deletions bin/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,36 @@ download_path() {
echo "$tmp_download_dir/neovim-${version}.tar.gz"
}

download_version() {
local install_type=$1
local version=$2
local download_path=$3
local download_url

download_url=$(download_url "$install_type" "$version")

rm "$download_path"

echo "==> curl -Lo $download_path -C - $download_url"
curl -Lo "$download_path" -C - "$download_url" || exit 1
}

download_url() {
local version_arg="$1"
if [[ "$version_arg" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
local version="v$1"
local install_type=$1
local version_arg=$2
local version
if [[ "${version_arg}" =~ ^[0-9]+\.* ]] ; then
version="v$2"
else
local version="$1"
version="$2"
fi
echo "https://github.com/neovim/neovim/releases/download/${version}/nvim-${platform}.tar.gz"
}

download_version() {
local version=$1
local download_path=$2
local download_url=$(download_url $version)
if [ "$install_type" = "version" ]; then
echo "https://github.com/neovim/neovim/releases/download/${version}/nvim-${platform}.tar.gz"
else
# otherwise it can be a branch name or commit sha
echo "https://github.com/neovim/neovim/archive/${version}.tar.gz"
fi

echo "curl -Lo $download_path -C - $download_url"
curl -Lo $download_path -C - $download_url
return
}

0 comments on commit 7ad0fb7

Please sign in to comment.