linux stuff

This commit is contained in:
doyle 2022-07-10 17:25:29 +10:00
parent 99c16ae0c3
commit 77507e0b35
3 changed files with 76 additions and 56 deletions

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# Functions
# ------------------------------------------------------------------------------
DownloadFile()
@ -9,33 +8,34 @@ DownloadFile()
dest_file=$2
if [[ -f "${dest_file}" ]]; then
echo "- [Download] [Cached] ${url} to ${dest_file}"
echo "- [DownloadFile/Cached] ${url} to ${dest_file}"
else
echo "- [DownloadFile] ${url} to ${dest_file}"
wget --output-document ${dest_file} ${url}
if [ $? -ne 0 ]; then
echo "Failed to download file from ${url}"
echo "- [DownloadFile] Download failed [url=${url}]"
exit
fi
fi
}
FileSHA256HashCheck()
FileSHA256Check()
{
file=$1
expected=$2
echo "${expected} ${file}" | sha256sum --check
if [[ $? -ne 0 ]]; then
echo "- [Verify] ${file} "
echo "Expected: ${expected}"
echo "Actual: $(sha256sum ${file})"
echo "- [FileSHA256Check] Failed [file=${file}, "
echo " expect=${expected} ${file},"
echo " actual=$(sha256sum ${file})"
echo " ]"
exit
else
echo "- [Verify] Hash OK: ${file} ${expected}"
echo "- [FileSHA256Check] OK [file=${file}, hash=${expected}]"
fi
}
# ------------------------------------------------------------------------------
# Setup
# ------------------------------------------------------------------------------
root_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
@ -49,71 +49,94 @@ mkdir --parents ${tools_dir}
mkdir --parents ${downloads_dir}
bin_dir=${tools_dir}/Binaries
vim_dir=${HOME}/.vim
vim_plug_dir=${vim_dir}/autoload
mkdir --parents ${vim_plug_dir}
mkdir --parents ${bin_dir}
mkdir --parents ~/.config/nvim
# ------------------------------------------------------------------------------
# Tools
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Dependencies
# ------------------------------------------------------------------------------
sudo apt install exuberant-ctags neovim clang-format
# ------------------------------------------------------------------------------
# CMake
# ----------------------------------------------------------------------------
cmake_sha256=aaced6f745b86ce853661a595bdac6c5314a60f8181b6912a0a4920acfa32708
cmake_exe_sha256=95b80ba2b97b619abce1ed6fd28fe189cacba48403e9c69256f2f94e3405e645
cmake_version=3.23.2
cmake_label=cmake_linux64_${cmake_version}
cmake_download_file=${downloads_dir}/${cmake_label}.tar.gz
cmake_dir=${tools_dir}/${cmake_label}
cmake_exe=${cmake_dir}/bin/cmake
if [[ ! -f "${cmake_exe}" ]]; then
DownloadFile "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-linux-x86_64.tar.gz" "${cmake_download_file}" || exit
FileSHA256Check "${cmake_download_file}" "${cmake_sha256}" || exit
mkdir --parents "${cmake_dir}" && tar xf "${cmake_download_file}" --overwrite --directory="${cmake_dir}" || exit
echo "mv --force ${cmake_dir}/cmake-${cmake_version}-linux-x86_64 "${cmake_dir}""
mv ${cmake_dir}/cmake-${cmake_version}-linux-x86_64/* "${cmake_dir}" || exit
rm --recursive ${cmake_dir}/cmake-${cmake_version}-linux-x86_64 || exit
fi
FileSHA256Check "${cmake_exe}" "${cmake_exe_sha256}" || exit
cd "${bin_dir}" && ln --force --symbolic --relative "${cmake_exe}" cmake && cd "${root_dir}"
cd "${bin_dir}" && ln --force --symbolic --relative "${cmake_exe}" cmake-${cmake_version} && cd "${root_dir}"
# Vim Configuration
# ------------------------------------------------------------------------------
cp --force ${installer_dir}/os_vimrc ~/.vimrc || exit
cp --force ${installer_dir}/os_clang_format_style_file ~/_clang-format || exit
# Nvim Config
nvim_init_dir=~/.config/nvim
mkdir --parents "${nvim_init_dir}"
cp --force ${installer_dir}/os_nvim_init.vim ${nvim_init_dir}/init.vim || exit
# Vim Package Manager
if [[ ! -f "${vim_plug_dir}/plug.vim" ]]; then
wget --directory-prefix=${vim_plug_dir} https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
# Clang Format
if [[ ! -f "${vim_dir}/clang-format.py" ]]; then
wget --directory-prefix=${vim_dir} https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format.py
fi
vim_plug_dir=${nvim_init_dir}/autoload
vim_plug=${vim_plug_dir}/plug.vim
mkdir --parents ${vim_plug_dir}
DownloadFile "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" "${vim_plug}" || exit
# Nvim
# ------------------------------------------------------------------------------
# NVim
# ------------------------------------------------------------------------------
cp --force ${installer_dir}/os_vimrc ~/.vimrc
cp --force ${installer_dir}/os_clang_format_style_file ~/_clang-format
cp --force ${installer_dir}/os_nvim_init.vim ~/.config/nvim/init.vim
nvim_sha256=33b5d020c730b6d1b5185b1306ead83b6b8f8fab0239e0580c72b5224a9658e1
nvim_version=0.7.2
nvim_label=nvim_linux64_${nvim_version}
nvim_exe=${tools_dir}/${nvim_label}.appimage
DownloadFile "https://github.com/neovim/neovim/releases/download/v${nvim_version}/nvim.appimage" "${nvim_exe}" || exit
FileSHA256Check "${nvim_exe}" "${nvim_sha256}" || exit
chmod +x "${nvim_exe}"
cd "${bin_dir}" && ln --force --symbolic --relative "${nvim_exe}" nvim && cd "${root_dir}"
cd "${bin_dir}" && ln --force --symbolic --relative "${nvim_exe}" vim && cd "${root_dir}"
# ----------------------------------------------------------------------------
# Neovide
# ----------------------------------------------------------------------------
neovide_sha256=dbd0903bae5baff550406fd1e09e7ca0afc57ec855305545ae1c13485c7f1d69
neovide_exe_sha256=fc946c3d58f6e61eef78635eec81cbbb067b02c0deffb7661254896ce5b20578
neovide_version=0.8.0
neovide_sha256=684cbcaeb2e67f1d95822ef80e03e1475395d537f2032f47b8202fe48c428b08
neovide_exe_sha256=e4fbc8b56af2e25127938ae2974921e25b4df5722086d7e8c3e517e8ee86e2df
neovide_version=0.9.0
neovide_download_file=${downloads_dir}/neovide-v${neovide_version}.tar.gz.zip
neovide_dir=${tools_dir}/neovide-v${neovide_version}-linux
neovide_exe=${neovide_dir}/neovide
neovide_url=https://github.com/neovide/neovide/releases/download/${neovide_version}/neovide-linux.tar.gz.zip
neovide_label=neovide_linux64_${neovide_version}
neovide_download_file=${downloads_dir}/${neovide_label}.tar.gz
neovide_dir=${tools_dir}
neovide_exe=${neovide_dir}/${neovide_label}
if [[ ! -f "${neovide_exe}" ]]; then
DownloadFile "https://github.com/neovide/neovide/releases/download/${neovide_version}/neovide-linux.tar.gz.zip" ${neovide_download_file}
FileSHA256HashCheck ${neovide_download_file} ${neovide_sha256}
DownloadFile "https://github.com/neovide/neovide/releases/download/${neovide_version}/neovide.tar.gz" ${neovide_download_file} || exit
FileSHA256Check ${neovide_download_file} ${neovide_sha256} || exit
unzip -o ${neovide_download_file} -d ${neovide_dir}
tar xf ${neovide_dir}/neovide.tar.gz --overwrite --directory=${neovide_dir}
mv ${neovide_dir}/target/release/neovide ${neovide_dir}
rm -rf ${neovide_dir}/neovide.tar.gz
rm -rf ${neovide_dir}/target
mkdir --parents "${cmake_dir}" && tar xf ${neovide_download_file} --overwrite --directory=${neovide_dir}/neovide-tmp || exit
mv ${neovide_dir}/neovide-tmp/target/release/neovide "${neovide_exe}" || exit
rm -rf ${neovide_dir}/neovide-tmp
fi
FileSHA256HashCheck ${neovide_exe} ${neovide_exe_sha256}
FileSHA256Check ${neovide_exe} ${neovide_exe_sha256} || exit
cd "${bin_dir}" && ln --force --symbolic --relative "${neovide_exe}" neovide && cd "${root_dir}"
# ------------------------------------------------------------------------------
# Ctags
# ------------------------------------------------------------------------------
rm --force ${bin_dir}/ctags_cpp.sh
echo ctags --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ \$\@ >> ${bin_dir}/ctags_cpp.sh
chmod +x ${bin_dir}/ctags_cpp.sh
echo PATH=${tools_dir}/Binaries:\$\{PATH\}> ${tools_dir}/linux_terminal.sh

View File

@ -1,6 +1,6 @@
@echo off
setlocal EnableDelayedExpansion
REM Win Helpers - Version 2
REM Win Helpers - Version 3
call %*
goto exit
@ -20,7 +20,7 @@ if exist "!dest_file!" (
if exist "!dest_file!" (
exit /B 0
) else (
echo [Download File] Failed to download file from !url!
echo [DownloadFile] Download failed [url=!url!]
exit /B 1
)

View File

@ -14,9 +14,7 @@ if not exist !home_dir! mkdir !home_dir!
if not exist !tools_dir! mkdir !tools_dir!
if not exist !downloads_dir! mkdir !downloads_dir!
set vim_dir=!home_dir!\.vim
set bin_dir=!tools_dir!\Binaries
if not exist !vim_dir! mkdir !vim_dir!
if not exist !bin_dir! mkdir !bin_dir!
set tmp_terminal_script=!tools_dir!\win_terminal.bat.tmp
@ -665,7 +663,6 @@ if not exist "!neovide_exe!" (
call win_helpers.bat :FileHashCheck sha256 "!neovide_exe!" "!neovide_exe_sha256!" || exit /B %ERRORLEVEL%
call win_helpers.bat :MakeBatchShortcut "neovide" "!neovide_exe!" "!bin_dir!" || exit /B %ERRORLEVEL%
REM ----------------------------------------------------------------------------
REM Vim Configuration
REM ----------------------------------------------------------------------------
REM Nvim Config