-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·114 lines (97 loc) · 2.2 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
#!/bin/bash
ENVDIR="$(pwd)"
for i in diffs/*.diff;
do
patch -f -p1 --dry-run < $i &> /dev/null
if [[ $? == 0 ]];
then
patch -p1 < $i
fi
# patch -R -p1 < $i
done
for cmd in bat gdb vim git git ctags;
do
x=$(which $cmd 2>/dev/null)
if [[ -z "$x" ]];
then
echo "Need to install ${cmd}"
fi
done
# Build a few different things
cd "${ENVDIR}/git/fzf"
make bin/fzf
cd "${ENVDIR}/.vim/bundle/YouCompleteMe/"
./install.py --all --clangd-completer
cd "${ENVDIR}"
function install()
{
SRC="$1"
DST="$2"
# echo "SRC=$SRC"
# echo "DST=$DST"
cp -v "${SRC}" "${DST}"
sed -i "${DST}" -e "s|{ENVDIR}|${ENVDIR}|g"
}
function insert( )
{
FILE="$1"
LINE="$2"
# echo "FILE=$FILE"
# echo "LINE=$LINE"
if grep -q "^${LINE}$" "${FILE}" 2>/dev/null;
then
echo "${LINE} already in ${FILE}"
else
echo "${LINE} >> ${FILE}"
echo "${LINE}" >> ${FILE}
fi
}
function append( )
{
FILE="$1"
shift
ENTRY="$@"
cp "${FILE}" "${FILE}.tmp"
echo "${ENTRY}" >> "${FILE}.tmp"
sort -u "${FILE}.tmp" > "${FILE}"
}
cd "${ENVDIR}"
install .gdbinit ~/.gdbinit.env
install .bashrc ~/.bashrc.env
install .alias ~/.alias.env
install .tmux.conf ~/.tmux.env.conf
install .tmux.vim.conf ~/.tmux.vim.conf
insert ~/.gdbinit "source ~/.gdbinit.env"
insert ~/.bashrc "source ~/.bashrc.env"
insert ~/.tmux.conf "source ~/.tmux.env.conf"
git config --global --add include.path ${ENVDIR}/.gitconfig
append ~/.gitignore ".*.swp"
append ~/.gitignore "doc/tags"
cd ~/
ln -sf "${ENVDIR}/.vimrc" .
ln -sf "${ENVDIR}/.vim" .
pushd .
cd "${ENVDIR}/.vim/bundle"
for d in */doc;
do
echo "Generating vim helptags for $d"
/usr/bin/vim -X -u NORC "+helptags $d | q "
done
popd
cd ~/bin/
ln -sf ${ENVDIR}/bin/* .
# TODO
# ~/.vim cannot be overwritten when directory
# ~/.gitignore gives an error when not there already
# Before doing enything check prerequisites:
# - go (min 1.23?)
# - python devel (min 3.11?)
# - make
# - cmake
# Check for the mistake of having submodules not cloned recursively and do it automagically
#
# Unknown errors yet:
# - fatal: ref HEAD is not a symbolic ref (from make bin/fzf)
# Features:
# - collect result of everything and output in a table which went fine and which failed?
# vim: tabstop=4 shiftwidth=4 noexpandtab