#!/bin/bash
set -e
function checkPath()
{
if [ ! $# -eq 1 ]; then
return
fi
if [ ! -d $1 ]; then
mkdir -p $1
fi
}
localPath=$(cd "$(dirname "$0")";pwd)
tmpDir=$localPath/tmpDir
buildDir=$tmpDir/build
echo "<------------------mkdir tmp dir------------------->"
checkPath $tmpDir
checkPath $buildDir
echo "<-----------------build sqlite3-------------------->"
tar -xvf $localPath/sqlite-autoconf-3240000.tar -C $tmpDir
cd $buildDir
$tmpDir/sqlite-autoconf-3240000/configure --prefix=/usr/local/sqlite
make -j8
echo "<---------------------sqlite3 complete--------------------->"
make install
echo "<----------------------sqlite3 install--------------------->"
cd $localPath
echo "<-----------------build python-------------------->"
tar -xvf $localPath/Python-3.6.1.tar.xz -C $tmpDir
cd $buildDir
$tmpDir/Python-3.6.1/configure --prefix=/usr/local/python361 --enable-loadable-sqlite-extensions
make -j8
echo "<----------------------python complete--------------------->"
make install
echo "<----------------------python install--------------------->"
cp /usr/bin/python3 /usr/bin/python3_old
ln -fs /usr/local/python361/bin/python3 /usr/bin/python
ln -fs /usr/local/python361/bin/pip3 /usr/bin/pip
rm $tmpDir -rf
echo "<-------------------------------------------------->"