Fall back to Ruby version when download failed
This commit is contained in:
parent
9930a1d4d9
commit
0a6cb62169
52
install
52
install
@ -6,27 +6,49 @@ fzf_base=`pwd`
|
|||||||
ARCHI=$(uname -sm)
|
ARCHI=$(uname -sm)
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
mkdir -p "$fzf_base"/bin
|
|
||||||
cd "$fzf_base"/bin
|
|
||||||
echo "Downloading fzf executable ($1) ..."
|
echo "Downloading fzf executable ($1) ..."
|
||||||
if curl -fL \
|
mkdir -p "$fzf_base"/bin && cd "$fzf_base"/bin
|
||||||
https://github.com/junegunn/fzf-bin/releases/download/snapshot/${1}.tar.gz |
|
if [ $? -ne 0 ]; then
|
||||||
tar -xz; then
|
echo "- Failed to create bin directory."
|
||||||
mv $1 fzf
|
return 1
|
||||||
chmod +x fzf
|
|
||||||
else
|
|
||||||
echo "Failed to download $1"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
cd - > /dev/null
|
|
||||||
|
local url=https://github.com/junegunn/fzf-bin/releases/download/snapshot/${1}.tar.gz
|
||||||
|
if which curl > /dev/null; then
|
||||||
|
curl -fL $url | tar -xz
|
||||||
|
elif which wget > /dev/null; then
|
||||||
|
wget -O - $url | tar -xz
|
||||||
|
else
|
||||||
|
echo "- curl or wget required to download fzf executable."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $1 ]; then
|
||||||
|
echo "- Failed to download ${1}."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv $1 fzf && chmod +x fzf && cd - > /dev/null && echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Try to download binary executable
|
||||||
|
binary_available=0
|
||||||
|
downloaded=0
|
||||||
if [ "$ARCHI" = "Darwin x86_64" ]; then
|
if [ "$ARCHI" = "Darwin x86_64" ]; then
|
||||||
download fzf_darwin_amd64
|
binary_available=1
|
||||||
|
download fzf_darwin_amd64 && downloaded=1
|
||||||
elif [ "$ARCHI" = "Linux x86_64" ]; then
|
elif [ "$ARCHI" = "Linux x86_64" ]; then
|
||||||
download fzf_linux_amd64
|
binary_available=1
|
||||||
else # No prebuilt executable
|
download fzf_linux_amd64 && downloaded=1
|
||||||
echo "No prebuilt binary for $ARCHI ... Installing legacy Ruby version ..."
|
fi
|
||||||
|
|
||||||
|
if [ $downloaded -ne 1 ]; then
|
||||||
|
if [ $binary_available -eq 0 ]; then
|
||||||
|
echo -n "No prebuilt binary for $ARCHI ... "
|
||||||
|
else
|
||||||
|
echo -n "Failed to download binary executable ... "
|
||||||
|
fi
|
||||||
|
echo "Installing legacy Ruby version ..."
|
||||||
|
|
||||||
# ruby executable
|
# ruby executable
|
||||||
echo -n "Checking Ruby executable ... "
|
echo -n "Checking Ruby executable ... "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user