-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·709 lines (636 loc) · 15.8 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
#! /bin/bash
# set -x
# echo "****************** INSTALLATION STARTS HERE ************************"
devdir=$PWD
if [ "$devdir" != "$HOME/devenv" ]
then
echo "Please install from ~/devenv"
exit -1
fi
builddir=$devdir/build
mkdir $builddir
LOGFILE=$PWD/build/install.log
rm -rf $LOGFILE > /dev/null 2>&1
touch $LOGFILE
myname=$0
export DEBIAN_FRONTEND=noninteractive
ubver=$(cat /etc/lsb-release |grep RELEASE|cut -d= -f2)
shopt -s expand_aliases
. ./shell/bash/devenv_bashrc
#crate and enter specific directory
ce_dir ()
{
sudo rm -rf $builddir/$1 > /dev/null;
mkcd $builddir/$1
}
clean_dir ()
{
sudo rm -rf build
mkcd build
prv_install_bash_completions;
}
############################## INSTALLERS STARTS HERE ###################################
prv_node21 ()
{
ce_dir nodejs
sudo apt -yq install aptitude
sudo aptitude -yq install libnode-dev
sudo aptitude -yq install libnode64
sudo aptitude -yq install node-gyp
sudo aptitude -yq install npm
# sudo apt install libnode72=12.21.0~dfsg-3ubuntu1
sudo apt-get -yq update
sudo apt-get -yq install nodejs
sudo apt-get -yq install npm
curl -sS -L https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
}
prv_node20()
{
ce_dir nodejs
curl -vs -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get -yq update
sudo apt-get -yq install nodejs
sudo apt-get -yq install npm
}
tools_node()
{
if [ "$ubver" = "21" ];then
prv_install_node21
else
prv_install_node20
fi
}
gem_pkg()
{
for i in $@
do
sudo gem install $i
done
}
npm_pkg()
{
for i in $@
do
sudo npm i -g $i
done
}
apt_pkg()
{
for i in $@
do
sudo apt-get -yqm install $i
done
}
cargo_pkg ()
{
for i in $@
do
sudo cargo install $i
done
}
pip_pkg()
{
for i in $@
do
sudo pip3 install $i -U
sudo pip2 install $i -U
done
}
tools_pkgs ()
{
local apt_pkgs="
dos2unix
apt-file
rsync
w3m
w3m-img
libbz2-dev
curl
cscope
ctags
python
python3
python3-pip
exuberant-ctags
universal-ctags
snapd
lfm
plantuml
ccls
libgemplugin-ruby
rubygems
ruby-full
clang-format
p7zip-full
cmake
lynx
ruby
ruby-dev
python-pip
fuse
cargo
cmake
libfreetype6-dev
libfontconfig1-dev
xclip
xsel
libxcb-composite0-dev
bison
flex
pylint
taskwarrior
doxygen
tasksh
timewarrior
zsh
figlet
toilet
ninja-build
ppa-purge
jq
ncdu
ripgrep
"
local gem_pkgs="
nokogiri
"
apt_pkg $apt_pkgs
gen_pkg $gem_pkgs
}
tools_googler_supports ()
{
ce_dir googler
sudo curl -sS -o /usr/bin/googler https://raw.githubusercontent.com/jarun/googler/v4.3.1/googler && sudo chmod +x /usr/bin/googler
sudo apt-get -yqm install googler
wget https://raw.githubusercontent.com/jarun/googler/master/auto-completion/bash/googler-completion.bash
cp googler-completion.bash $builddir/bash_completions/
wget https://raw.githubusercontent.com/jarun/googler/master/auto-completion/googler_at/googler_at
cp googler_at $builddir/bash_completions
}
tools_bat()
{
[ "$FORCE_INSTALL" == "" ] && bat --version|grep 'bat 0.17.1' && echo "bat already installed" && return;
ce_dir bat
wget $(gh_rel sharkdp/bat "bat_.*amd.*deb")
sudo dpkg -i $(/usr/bin/ls -htr bat_*.deb|tail -1)
set +x
}
tools_fzf ()
{
[ "$FORCE_INSTALL" == "" ] && fzf --version && echo "fzf already installed" && return;
echo "fzf installing..."
ce_dir fzf
git clone --depth 1 https://github.com/junegunn/fzf.git fzf
./fzf/install --all
}
tools_ripgrep ()
{
rg -V| grep -E '^ripgrep 11|^ripgrep 13' && echo "ripgrep already installed" && return;
echo "ripgrep installing..."
ce_dir rg
curl -sS -LO https://github.com/BurntSushi/ripgrep/releases/download/11.0.2/ripgrep_11.0.2_amd64.deb
sudo dpkg -i ripgrep_11.0.2_amd64.deb
}
tools_pyenv ()
{
[ "$FORCE_INSTALL" == "" ] && pyenv --version| grep "^pyenv " && echo "pyenv already installed" && return ;
echo "pyenv installing..."
rm -rf ~/.pyenv
ce_dir pyenv
curl -sS -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer |bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"
pyenv install 3.8.5
pyenv global 3.8.5
python3 -m keyring --disable
pip install --upgrade pip
}
tools_yarn()
{
[ "$FORCE_INSTALL" == "" ] && yarn --version| grep "^yarn " && echo "yarn already installed" && return ;
echo "yarn installing..."
ce_dir yarn
rm -rf ~/.yarn
curl -sS -L https://yarnpkg.com/install.sh | bash
}
tools_dotfiles()
{
cp -rf dotfiles/.* ~/
}
tools_uncrustify ()
{
ce_dir uncrustify
git clone --depth=1 https://github.com/uncrustify/uncrustify.git
cd uncrustify
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
if [ ! -d /usr/local/bin ];then
sudo mkdir /usr/local/bin/
fi
sudo ln -s -f $PWD/uncrustify /usr/local/bin
cd $devdir
}
tools_fd ()
{
ce_dir fdfind
wget https://github.com/sharkdp/fd/releases/download/v8.2.1/fd_8.2.1_amd64.deb
sudo dpkg -i fd_8.2.1_amd64.deb
cd $devdir
}
tools_fancydiff ()
{
ce_dir fancydiff
git clone https://github.com/so-fancy/diff-so-fancy.git
cd $devdir
}
tools_gitconfig ()
{
gconfig
}
tools_btoppp()
{
ce_dir btop
wget https://github.com/aristocratos/btop/releases/download/v1.1.3/btop-x86_64-linux-musl.tbz
ex btop-x86_64-linux-musl.tbz
sudo ln -sf $builddir/btop/bin/btop /usr/local/bin/btop
}
install_devtools()
{
pkgs=$(cat $myname|grep "^tools_"|cut -d"(" -f1)
for i in $pkgs
do
$i
done
}
install_gui_albert()
{
ce_dir albert
curl -sS https://build.opensuse.org/projects/home:manuelschneid3r/public_key | sudo apt-key add -
echo 'deb http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_20.04/ /' | sudo tee -a /etc/apt/sources.list.d/home:manuelschneid3r.list
sudo wget -nv https://download.opensuse.org/repositories/home:manuelschneid3r/xUbuntu_20.04/Release.key -O "/etc/apt/trusted.gpg.d/home:manuelschneid3r.asc"
sudo apt update
sudo apt install albert
}
# unused installer
depre_install_gui_alacritty()
{
local apt_pkgs="
libxkbcommon-x11-dev
"
apt_pkg $apt_pkgs
ce_dir alacritty
# sudo curl -sS https://sh.rustup.rs -sSf | sh
git clone https://github.com/jwilm/alacritty.git
cd alacritty
cargo build --release
chmod +x target/release/alacritty
sudo ln -sf $PWD/target/release/alacritty /usr/bin/alacritty
gzip -c extra/alacritty.man | sudo tee -a /usr/local/share/man/man1/alacritty.1.gz > /dev/null
cp extra/completions/alacritty.bash $builddir/bash_completions/
ln -sf $builddir/dotfiles/alacritty.yml ~/.alacritty.yml
}
prv_install_bash_completions()
{
if [ ! -d $builddir/bash_completions ]
then
mkdir $builddir/bash_completions
fi
}
# install bashrc
prv_install_bashrc ()
{
local apt_pkgs="
fonts-powerline
bash-completion
"
apt_pkg $apt_pkgs
if [ "$DEVENV_LOADED" == "" ]
then
echo ". ~/devenv/shell/bash/devenv_bashrc" >> ~/.bashrc
source ~/.bashrc
fi
}
prv_install_zshrc ()
{
ce_dir zsh
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
echo $PWD
ZSH=$PWD/ohmyzsh sh ./install.sh --unattended
echo ". ~/devenv/shell/zsh/devenv_zshrc" >> ~/.zshrc
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions.git
}
install_shell()
{
prv_install_bashrc
prv_install_zshrc
prv_install_bash_completions
}
# install tmux
prv_install_tmux ()
{
local VER="3.2"
[ "$FORCE_INSTALL" == "" ] && tmux -V| grep "^tmux $VER" && echo "tmux already installed" && return ;
echo "tmux installing..."
local apt_pkgs="
libevent-dev
libncurses5-dev
libncursesw5-dev
"
apt_pkg $apt_pkgs
ce_dir tmux
# curl -sS -LO https://github.com/tmux/tmux/releases/download/3.2-rc/tmux-3.2-rc3.tar.gz
curl -sS -LO https://github.com/tmux/tmux/releases/download/$VER/tmux-$VER.tar.gz
tar -xf tmux-$VER.tar.gz
cd tmux-$VER
./configure
sudo make install
sudo ln -sf /usr/local/bin/tmux /usr/bin/tmux
}
# install tmux conf
prv_install_tmux_conf ()
{
ce_dir tmuxconf
git clone https://github.com/gpakosz/.tmux.git
unlink ~/.tmux.conf.local > /dev/null 2>&1
unlink ~/.tmux.conf > /dev/null 2>&1
unlink ~/.mytmux.conf > /dev/null 2>&1
unlink ~/.devenv_tmux.conf > /dev/null 2>&1
ln -s -f $PWD/.tmux/.tmux.conf ~/
ln -s -f $PWD/.tmux/.tmux.conf.local ~/
ln -s -f $devdir/tmux/tmux.conf ~/.devenv_tmux.conf
echo "source-file ~/.devenv_tmux.conf" >> ~/.tmux.conf.local
}
install_tmux()
{
prv_install_tmux
prv_install_tmux_conf
}
prv_install_clangd ()
{
# 10
ce_dir clangd
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo ln -sf $(ls --color=never /usr/bin/clangd-* | tail -1) /usr/bin/clangd
}
prv_install_luals()
{
ce_dir lua_ls
# clone project
git clone https://github.com/sumneko/lua-language-server
cd lua-language-server
git submodule update --init --recursive
cd 3rd/luamake
./compile/install.sh
cd ../..
./3rd/luamake/luamake rebuild
}
prv_install_ls()
{
local apt_pkgs="
lua5.3
"
local pip_pkgs="
jedi
jedi-language-server
python-language-server
cmake-language-server
python-lsp-server[all]
"
local npm_pkgs="
bash-language-server
"
apt_pkg $apt_pkgs
pip_pkg $pip_pkgs
npm_pkg $npm_pkgs
prv_install_luals
prv_install_clangd
}
download_nvim()
{
# curl -sS -LO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage
curl -sS -LO https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod u+x nvim.appimage
sudo ln -sf $PWD/nvim.appimage /usr/local/bin/nvim
}
build_nvim()
{
local apt_pkgs="
ninja-build
gettext
libtool
libtool-bin
autoconf
automake
cmake
g++
pkg-config
unzip
curl
doxygen
"
apt_pkg $apt_pkgs
git clone --depth 1 https://github.com/neovim/neovim
cd neovim && make CMAKE_BUILD_TYPE=RelWithDebInfo -j4
sudo make install
}
prv_install_nvim ()
{
ce_dir nvim
download_nvim
# build_nvim
mkdir -p ~/.config/nvim
touch ~/.config/nvim/init.vim
echo "set runtimepath^=~/.vim runtimepath+=~/.vim/after" > ~/.config/nvim/init.vim
echo "let &packpath = &runtimepath" >> ~/.config/nvim/init.vim
echo "source ~/.vimrc" >> ~/.config/nvim/init.vim
# by this time we should be able to have pyenv
pyenvit
pip3 install pynvim
pip3 install neovim
pip3 install 'python-lsp-server[all]'
sudo gem install neovim
sudo npm install -g neovim
}
prv_install_vim ()
{
if [ "$ubver" != "21" ];then
sudo add-apt-repository -y ppa:jonathonf/vim
sudo apt-get update
sudo apt-get install vim
fi
}
fix_coc_ccls()
{
existing=~/.config/coc/extensions/node_modules/coc-ccls/node_modules/ws/lib/extension.js
missing=~/.config/coc/extensions/node_modules/coc-ccls/lib/extension.js
if [[ -e "$existing" && ! -e "$missing" ]]; then
mkdir -p "$(dirname "$missing")"
ln -s "$existing" "$missing"
fi
}
prv_install_ycm()
{
cd ~/.vim/plugged/YouCompleteMe/
./install.py --clangd-completer --clang-completer
}
prv_install_coc()
{
nvim --headless -c "CocInstall coc-clangd coc-ccls" -c 'qall!'
fix_coc_ccls;
ln -s -f $devdir/vim/coc-settings.json ~/.vim/
ln -s -f $devdir/vim/coc-settings.json ~/.config/nvim/
cd ~/.config/coc/extensions/node_modules/coc-ccls
ln -s node_modules/ws/lib lib
cd -
}
prv_install_plug()
{
curl -sS -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
/usr/bin/vim -c 'PlugInstall!' -c 'qall!'
}
prv_install_packer ()
{
ce_dir packer
rm -rf ~/.local/share/nvim/site/pack/packer
rm -rf ~/.config/nvim/plugin/packer_compiled.lua
git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.vim/pack/packer/start/packer.nvim
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
}
# get vimrc and install plugins
prv_install_vimrc ()
{
ce_dir vimrc
unlink ~/.vimrc > /dev/null 2>&1
ln -s $devdir/vim/devenv.vimrc ~/.vimrc > /dev/null 2>&1
# Install vim plug plugin manager
## remove already installed .vim directory
unlink ~/.vim > /dev/null 2>&1
rm -rf ~/.vim > /dev/null 2>&1
mkdir -p ~/.vim/pack/packer/start/
# prv_install_plug
prv_install_packer
# prv_install_ycm
# prv_install_coc
mkdir ~/.vim/undodir
}
install_vim()
{
# local apt_pkgs="
# vifm
# "
# apt_pkg $apt_pkgs
prv_install_nvim
#prv_install_vim
prv_install_vimrc
# prv_install_ls
}
prv_install_test()
{
echo "This is test function"
}
############################## SCRIPT STARTS HERE ###################################
list_packages ()
{
pkgs=$(cat $myname|grep "^install_"|cut -d"_" -f2-|cut -d"(" -f1)
echo $pkgs
}
usage ()
{
echo "
./install.sh all [OPTIONS] # Install all packages
./install.sh <package_name> [OPTIONS] # Install specific package
OPTIONS :
-f Force install
-j just install - no apt related pre post hooks
<package_name> can be one of
"
echo $(list_packages) | tr ' ' '\n' | sed -e 's/^/\t\t/g'
exit
}
preinst ()
{
[ "$PLAIN_INSTALL" == "y" ] && return;
sudo apt-get -yq autoremove
sudo apt -yq autoremove
sudo apt -yq --fix-broken install
sudo apt-get -yq update && sudo apt-get -yq upgrade
sudo dpkg --configure -a
sudo apt-get -yq install -f
sudo apt-get -yq clean
prv_install_bash_completions;
}
postinst ()
{
[ "$PLAIN_INSTALL" == "y" ] && return;
sudo apt -yq --fix-broken install
sudo apt-get -yq autoremove
sudo apt -yq autoremove
killall tail > /dev/null 2>&1
}
run_ninst_func ()
{
$1 | tee -a $LOGFILE 2>&1
}
run_func ()
{
if [ "$1" == "tools" ]
then
sudo apt-get -yq update
sudo apt-get -yq upgrade
fi
install_$1 2>&1
}
# Check valid params given
[[ $# == 0 ]] && usage
# Check valid package or not
[[ "$1" == "all" || $(list_packages) =~ (^|[[:space:]])"$1"($|[[:space:]]) ]] && echo "Installing $1 ..." || usage
FORCE_INSTALL=""
PLAIN_INSTALL=""
app=""
for var in "$@"
do
case $var in
-f)
export FORCE_INSTALL='y'
;;
-j)
export PLAIN_INSTALL='y'
;;
*)
app="$var"
;;
esac
done
# Main execution
case $app in
help)
usage
;;
all)
run_ninst_func preinst
run_ninst_func clean_dir;
for i in $(list_packages)
do
echo "================================ CHECK AND INSTALL $i ================================"
run_func $i
done
run_ninst_func postinst
;;
fix)
run_ninst_func fix_coc_ccls;
;;
*)
run_ninst_func preinst
echo "================================ CHECK AND INSTALL $1 ================================"
run_func $1
run_ninst_func postinst
;;
esac