-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.sh
181 lines (150 loc) · 4 KB
/
lib.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
#
# Functions
#
#
# Echo on both screen and log
#
function prt {
echo "$1" | tee -a "$LOGFILE" 1>&3
}
function freezeInstall() {
if [ "$freeze" == "" ]; then
prt " * Skipping requirements"
return
fi
if [ ! -f "$freeze" ]; then
prt " * Requirements File NOT FOUND?!"
return
fi
pip install -r "$freeze"
}
function downloadSrc {
what=$1
base=$2
prt " - Checking $SRCDIR/$base"
if [ ! -e "$SRCDIR/$base" ]; then
prt " - Getting it..."
wget -q --no-check-certificate $what -O "$SRCDIR/$base"
fi
}
function unzipSrc {
what=$1
folder=$2
prt " - unzip: $what"
if [ ! -d "$SRCDIR/$folder" ]; then
(cd "$SRCDIR" && unzip "$what")
fi
}
function untarSrc {
what=$1
folder=$2
prt " - untar: $what"
if [ ! -d "$SRCDIR/$folder" ]; then
(cd "$SRCDIR" && tar -xvf "$what")
fi
}
#
# Basic python installation
#
function installPython {
prt " * Installing python $PYVER"
base="Python-$version.tgz"
folder="Python-$version"
file="https://www.python.org/ftp/python/$version/Python-$version.tgz"
downloadSrc "$file" "$base"
untarSrc "$base" "$folder"
p=`pwd`
prt " - Checking $PREFIX/bin/python$PYVER"
if [ -e "$PREFIX/bin/python$PYVER" ]; then
prt " - Python is build... skipping"
return
fi
cd "$SRCDIR/$folder"
make clean 2> $DN
./configure --enable-shared $PREOPT --enable-ipv6 --with-threads
# Take care of cross compile
sed -i "s|/usr/local/lib|$PREFIX/lib|" ./setup.py
sed -i "s|/usr/local/include|$PREFIX/include|" ./setup.py
make -j $cores && make install
# if successfull set the new python
if [ -e "$PREFIX/bin/python$PYVER" ]; then
prt " - Setting new python to \"$PREFIX/bin/python$PYVER\""
PYTHON="$PREFIX/bin/python$PYVER"
fi
cd $p
}
#
# Install a library
#
function installLib {
url="$1"; shift
base="$1"; shift
folder="$1"; shift
checkFile="$1"; shift
type="$1"; shift
opts="$@ $PREOPT --enable-shared"
prt " * Installing lib $base"
if [ -e "$INCDIR/$checkFile" ]; then
prt " - Skipping, seems installed"
return
fi
p=`pwd`
downloadSrc "$url" "$base"
untarSrc "$base" "$folder" 2> $DN
if [ $? -ne 0 ]; then
unzipSrc "$base" "$folder"
fi
if [ $? -ne 0 ]; then
prt " !! FAILED TO EXTRACT"
return
fi
# Get in the folder
cd "$SRCDIR/$folder"
prt " - cd $SRCDIR/$folder"
makeArgs=""
confRC=0
makeRC=0
if [ $type == "autogen" ]; then
prt " - Running: './autogen.sh $opts'"
./autogen.sh $opts
confRC=$?
elif [ $type == "confmake" ]; then
prt " - Running: './configure $opts'"
./configure $opts
confRC=$?
elif [ $type == "confmake_readline" ]; then
# readline needs to be linked against ncurses...
# LD_LIBRARY_PATH is ignored
makeArgs="SHLIB_LIBS=-lncurses"
./configure $opts
confRC=$?
elif [ $type == "confmake_db" ]; then
# DB has multiple build directories...
cd build_unix
../dist/configure $PREOPT $@
confRC=$?
elif [ $type == "confmake_ssl" ]; then
# OpenSSL does not understand --enable-shared
./config $PREOPT $@
confRC=$?
elif [ $type == "confmake_bzlib" ]; then
# bzlib... weird way to set prefix...
makeArgs="PREFIX=$PREFIX"
sed -i "s|CC=gcc|CC=gcc -fPIC|" ./Makefile
fi
if [ $confRC -ne 0 ]; then
prt " !!! ERROR CONFIGURING ($confRC) !!!"
cd "$p"
return $confRC
fi
prt " - Running: 'make $makeArgs && make $makeArgs install'"
make $makeArgs -j $cores && make $makeArgs install
makeRC=$?
cd "$p"
if [ $makeRC -ne 0 ]; then
prt " !!! ERROR MAKING !!!"
cd "$p"
return $makeRC
fi
return 0
}