-
Notifications
You must be signed in to change notification settings - Fork 34
/
bash_readline_setup.sh
executable file
·128 lines (118 loc) · 3.83 KB
/
bash_readline_setup.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
#!/bin/bash
# bash_readline_setup.sh -- Full vim integration for your shell.
#
# Copyright (C) 2015 James Kolb
#
# This file is part of Athame.
#
# Athame is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Athame is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Athame. If not, see <http://www.gnu.org/licenses/>.
patches=19
redownload=0
build=1
dirty=0
sudo=""
destdir=""
prefix="/"
use_readline=""
for arg in "$@"
do
case "$arg" in
"--redownload" ) redownload=1;;
"--nobuild" ) build=0;;
"--dirty" ) dirty=1;;
"--use_sudo" ) sudo="sudo ";;
--destdir=*) destdir="${arg#*=}";;
--prefix=*) prefix="${arg#*=}";;
--use_readline=*) use_readline="${arg#*=}";;
"--help" ) echo -e " --redownload: redownload bash and patches\n" \
"--nobuild: stop before actually building src\n" \
"--prefix: set prefix for configure\n"\
"--use_readline: set where to look for readline\n"\
"--destdir: set DESTDIR for install\n"\
"--dirty: don't run the whole build process,\n" \
" just make and install changes\n" \
" (only use after a successful build)\n" \
"--help: display this message"; exit;;
* ) echo Unknown flag "$arg" >&2; exit 1;;
esac
done
#Download bash
if [ $redownload = 1 ]; then
rm -r bash-4.4.tar.gz
fi
if [ ! -f bash-4.4.tar.gz ]; then
curl -O https://ftp.gnu.org/gnu/bash/bash-4.4.tar.gz
fi
mkdir -p bash_patches
cd bash_patches
for (( patch=1; patch <= patches; patch++ )); do
if [ $redownload = 1 ]; then
rm -r bash44-$(printf "%03d" $patch)
fi
if [ ! -f bash44-$(printf "%03d" $patch) ]; then
curl -O https://ftp.gnu.org/gnu/bash/bash-4.4-patches/bash44-$(printf "%03d" $patch)
fi
done
cd ..
if [ ! -d bash-4.4_tmp ]; then
dirty=0
fi
#Unpack bash dir
if [ $dirty = 0 ]; then
rm -rf bash-4.4_tmp
tar -xf bash-4.4.tar.gz
mv bash-4.4 bash-4.4_tmp
fi
#Move into bash directory
cd bash-4.4_tmp
if [ $dirty = 0 ]; then
#Patch bash with bash patches
for (( patch=1; patch <= patches; patch++ )); do
echo Patching with standard bash patch $patch
patch -p0 < ../bash_patches/bash44-$(printf "%03d" $patch)
done
fi
readline_configure_flag="--with-installed-readline"
readline_make_flag=""
if [ -n "$use_readline" ]; then
readline_configure_flag="--with-installed-readline=$use_readline"
readline_make_flag="READLINE_LDFLAGS=-Wl,-rpath,$use_readline/lib/"
fi
#Build and install bash
if [ $build = 1 ]; then
if [ ! -f Makefile ]; then
ac_cv_rl_version=8.0 ./configure \
"--prefix=$prefix" \
--docdir=${prefix}/usr/share/doc/bash-4.4 \
--without-bash-malloc \
--enable-readline \
"$readline_configure_flag" \
|| exit 1
fi
if [ -n "$use_readline" ]; then
make LOCAL_LIBS=-lutil "$readline_make_flag"
else
make LOCAL_LIBS=-lutil
fi
if [ $? != 0 ]; then
printf "\n\e[1;31mMake failed:\e[0m Are you sure you have readline 8 installed? readline_athame_setup.sh installs readline 8 patched with athame. You may want to run it first.\nThis may also fail if you have a versionless libreadline.so symlinked to libreadline.so.7\n"
exit 1
fi
if [ -n "$destdir" ]; then
mkdir -p "$destdir"
fi
${sudo}make install DESTDIR="$destdir"
fi
#Leave bash dir
cd ..