diff --git a/platforms/ubuntu/install.sh b/platforms/ubuntu/install.sh new file mode 100644 index 0000000..d6bfd26 --- /dev/null +++ b/platforms/ubuntu/install.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# TODO(po-kai): 'sudo' on proper places +set -exuo pipefail + +# Check local vimrc's download +function replace_vimrc() { + local repo_vimrc="../../cfg/vimrc" + local local_vimrc="$HOME/.vimrc" + if [ -f "$local_vimrc" ]; then + mv $local_vimrc "$local_vimrc.bak" + fi + cp $repo_vimrc $local_vimrc +} + +# Check if vim supports python +function vim_supports_python() { + # ref: https://www.feliciano.tech/blog/how-to-check-if-vim-supports-python/ + local res=`vim --version | grep "+python"` + echo $res # E.g. "+conceal +linebreak +python3 +visualextra" +} + +# Install YouCompleteMe +function install_YCM() { + # Ref: https://github.com/ycm-core/YouCompleteMe + # Note: there's A LOT of places that might fail you here + local password=$1 + + # Cmake troubles + echo $password | sudo -S apt-get purge -y cmake + local version="3.22.1" + cwd=`pwd` + tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) + cd $tmp_dir + wget https://github.com/Kitware/CMake/releases/download/v$version/cmake-$version.tar.gz + tar -xzvf cmake-$version.tar.gz + cd cmake-$version/ + ./bootstrap + echo $password | sudo -S make + echo $password | sudo -S make install + cd $cwd + + # G++8 + echo $password | sudo -S apt-get install -y g++-8 + echo $password | sudo -S update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g++-7 + echo $password | sudo -S update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 + + # Dependencies + echo $password | sudo -S apt install -y build-essential vim-nox python3-dev + echo $password | sudo -S apt install -y mono-complete golang nodejs default-jdk npm + + # Compile YCM (YouCompleteMe) + ## If having cert error, check https://github.com/LplusKira/vimvimder/issues/1 + cd ~/.vim/bundle/YouCompleteMe + python3 install.py --all + cd - +} + +# Install tidy +function install_tidy() { + ### Ref: https://github.com/htacg/tidy-html5/blob/next/README/BUILD.md + cwd=`pwd` + tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) + cd $tmp_dir + git clone https://github.com/htacg/tidy-html5.git + cd tidy-html5/build/cmake + cmake ../.. -DCMAKE_BUILD_TYPE=Release + echo $password | sudo -S make + echo $password | sudo -S make install + cd $cwd +} + +# Install flake8 +function install_flake8() { + pip3 install flake8 +} + +# Read in pwd +echo "Enter your password: " +read -s password + +# Complete dependencies +## - Prerequisites git, curl, python3, my .vimrc +echo $password | sudo -S apt-get update -y +echo $password | sudo -S apt-get install -y git python3 curl cmake +## - Install 8.2-ver vim +echo $password | sudo -S add-apt-repository -y ppa:jonathonf/vim +echo $password | sudo -S apt update -y +echo $password | sudo -S apt install -y vim +## - Change owner +echo $password | sudo -S chown -R $USER "$HOME/.vim*" +## - Overwrite vimrc +replace_vimrc + +# Install plugins through Vundle +git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim +vim +PluginInstall +qall + +# Install specials +## - YCM +install_YCM $password +## - tidy +install_tidy +## - flake8 +install_flake8 diff --git a/platforms/ubuntu/rrr.sh b/platforms/ubuntu/rrr.sh new file mode 100644 index 0000000..94b075a --- /dev/null +++ b/platforms/ubuntu/rrr.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# - (Ubuntu 16.04 and later only) +set -e + +# Checking dependencies ... +## - Assert prerequisites git, curl, python3, my .vimrc +apt-get update -y +apt-get install -y git python3 curl cmake +#git --version +#python3 --version +#curl --version +#cmake --version +#pip3 --version + +remote_vimrc="https://gist.githubusercontent.com/LplusKira/f68437c2b7e4af2b9686043093320f56/raw/a92eb772af2aeb9dac1fcf85911f69b4837093d2/.vimrc" +local_vimrc="$HOME/.vimrc" #"/root/.vimrc" # +curl -o ${local_vimrc} ${remote_vimrc} +if [ ! -f "$local_vimrc" ]; then + echo "$local_vimrc download fails! Abort" + exit 1 +fi + +# Installing ... +git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim + +vim +PluginInstall +qall + +## - Specially handle YouCompleteMe -- complie it mannually @@ +### Ref: https://github.com/ycm-core/YouCompleteMe#linux-64-bit +apt-get install -y build-essential cmake python3-dev +### vv mono-complete +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF +apt-get install -y apt-transport-https ca-certificates +echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | tee /etc/apt/sources.list.d/mono-official-stable.list +apt-get update +apt install mono-devel +### ^^ mono-complete +curl -O https://dl.google.com/go/go1.13.3.linux-amd64.tar.gz +tar -xvf go1.13.3.linux-amd64.tar.gz +mv go /usr/local +for f in ~/.bashrc ~/.zshrc +do + export GOROOT=/usr/local/go + export GOPATH=$HOME/go + export PATH=$GOPATH/bin:$GOROOT/bin:$PATH + echo "export GOROOT=/usr/local/go" >> $f + echo "export GOPATH=$HOME/go" >> $f + echo "export PATH=$GOPATH/bin:$GOROOT/bin:$PATH" >> $f +done +# vv node, npm +ver=12 +apt-get install -y python-software-properties +curl -sL "https://deb.nodesource.com/setup_${ver}.x" | bash - +apt-get install -y nodejs +# ^^ node, npm +# vv clang 9 (default clang is too old) +## Ref: https://justiceboi.github.io/blog/install-clang-9-on-ubuntu/ +## Ref: (if using old clang) https://github.com/ycm-core/YouCompleteMe/issues/3236#issuecomment-439987788 +curl -SL http://releases.llvm.org/9.0.0/clang%2bllvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar -xJC . +mv clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04 clang_9.0.0 +sudo mv clang_9.0.0 /usr/local +for f in ~/.bashrc ~/.zshrc +do + export PATH=/usr/local/clang_9.0.0/bin:$PATH + export LD_LIBRARY_PATH=/usr/local/clang_9.0.0/lib:$LD_LIBRARY_PATH + echo "PATH=/usr/local/clang_9.0.0/bin:$PATH" >> $f + echo "LD_LIBRARY_PATH=/usr/local/clang_9.0.0/lib:$LD_LIBRARY_PATH" >> $f +done +# ^^ clang 9 (default clang is too old) +# Do not use `python3 install.py --all` # this uses some battery-included clang compiler which does not work +## Ref: https://github.com/ycm-core/YouCompleteMe/issues/1711#issuecomment-329520570 +cd ~/.vim/bundle/YouCompleteMe +./install.py --clang-completer --system-libclang + + +## - Specially install tidy +### Ref: https://github.com/htacg/tidy-html5/blob/next/README/BUILD.md +git clone https://github.com/htacg/tidy-html5.git +cd tidy-html5/build/cmake +cmake ../.. -DCMAKE_BUILD_TYPE=Release +make +make install + +## - Specially install flake8 (python linting) +pip3 install flake8