You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Comrad/script/install

446 lines
9.6 KiB
Plaintext

4 years ago
#!/bin/bash
4 years ago
# funcs (mac doesnt have realpath)
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
4 years ago
echo "$1 $2 $3"
4 years ago
# install pyenv?
4 years ago
4 years ago
echo "
4 years ago
### ## # # ### ## ###
# # # #### # # # # # #
# # # #### ### # # # #
# # # # # # # #### # #
### ## # # # # # # ###
4 years ago
4 years ago
4 years ago
installing...
4 years ago
4 years ago
"
4 years ago
echo '
1) setting up folder...
4 years ago
'
# install dir?
echo "Where should comrad live on your device?"
path_comrad_default="`realpath ~/comrad`"
4 years ago
4 years ago
if [ "$1" = "-n" ]
4 years ago
then
read -p "[$path_comrad_default] " path_comrad
4 years ago
else
path_comrad=$path_comrad_default
4 years ago
fi
if [ -z "$path_comrad" ]
4 years ago
then
path_comrad=$path_comrad_default
4 years ago
fi
4 years ago
if [ ! -d "$path_comrad" ]
4 years ago
then
mkdir -p $path_comrad
echo "created $path_comrad"
4 years ago
fi
path_lib="$path_comrad/lib"
if [ ! -d "$path_lib" ]
then
mkdir -p $path_lib
echo "created $path_lib"
fi
4 years ago
path_bin="$path_comrad/code/bin"
4 years ago
# if [ ! -d "$path_bin" ]
# then
# mkdir -p $path_bin
# echo "created $path_bin"
# fi
4 years ago
4 years ago
4 years ago
echo '
4 years ago
2) downloading Comrad...
4 years ago
4 years ago
'
path_repo="$path_comrad/code"
4 years ago
if command -v git &> /dev/null
4 years ago
then
4 years ago
echo "using git..."
4 years ago
if [ -d "$path_repo" ]
4 years ago
then
cd $path_repo
git pull
else
cd $path_comrad
4 years ago
4 years ago
if [ "$1" = "-n" ]
4 years ago
then
echo "Use HTTPS or SSH for git?"
read -p "[HTTPS/ssh] " git_method
else
git_method="https"
fi
4 years ago
if [ "$git_method" = "ssh" ]
4 years ago
then
echo "using ssh..."
4 years ago
git clone git@github.com:ComradOrg/Comrad.git
4 years ago
#git checkout installer
4 years ago
else
4 years ago
git clone https://github.com/ComradOrg/Comrad.git
4 years ago
#git checkout installer
4 years ago
fi
mv Comrad code
4 years ago
fi
else
cd $path_comrad
4 years ago
curl -s -LO https://github.com/ComradOrg/Comrad/archive/installer.zip
4 years ago
unzip -q -o installer.zip
4 years ago
rm installer.zip
cp -rT Comrad-installer code
rm -r Comrad-installer
4 years ago
fi
4 years ago
4 years ago
#########################################################
##########################################################
4 years ago
4 years ago
echo '
4) setting up python...
4 years ago
4 years ago
# '
4 years ago
4 years ago
cd $path_comrad
path_conda="$path_comrad/lib/miniconda3"
4 years ago
# ### Detect if python 3.7?
# pyv="$(python3 -c 'import sys; print(sys.version_info[0:2])')"
# if [ ! "$pyv" = "(3, 7)" ]
# then
4 years ago
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
4 years ago
MSYS*) machine=MinGw;;
4 years ago
*) machine="UNKNOWN:${unameOut}"
esac
4 years ago
# echo ${machine}
4 years ago
echo "Machine $machine detected."
4 years ago
if [ "$machine" = "Linux" ]
then
4 years ago
if [ ! -f "miniconda.sh" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh -o miniconda.sh
chmod +x miniconda.sh
fi
4 years ago
./miniconda.sh -b -f -p "$path_conda"
4 years ago
#rm miniconda.sh
4 years ago
### install themis from source
if [ ! -f "/usr/local/lib/libthemis.so" ]
then
if [ ! -f "/usr/lib/libthemis.so" ]
then
echo '
3) building Themis, cryptography backend...
'
cd "$path_lib"
# pwd
#git clone https://github.com/cossacklabs/themis.git
curl https://codeload.github.com/cossacklabs/themis/zip/master -o themis.zip
4 years ago
unzip -q -o themis.zip
4 years ago
#mv themis-master themis
cd themis-master
4 years ago
make
sudo make install
fi
fi
### install zbar library
sudo apt install zbar-tools
4 years ago
condaexec="conda"
4 years ago
fi
if [ "$machine" = "Mac" ]
4 years ago
then
4 years ago
if [ ! -f "miniconda.sh" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-MacOSX-x86_64.sh -o miniconda.sh
chmod +x miniconda.sh
fi
4 years ago
./miniconda.sh -b -f -p "$path_conda"
4 years ago
# rm miniconda.sh
4 years ago
4 years ago
if command -v /usr/local/bin/brew &> /dev/null
then
cd "$path_lib"
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
fi
4 years ago
# brew install
4 years ago
/usr/local/bin/brew tap cossacklabs/tap
/usr/local/bin/brew install libthemis
4 years ago
# install zbar library
4 years ago
/usr/local/bin/brew install zbar
4 years ago
4 years ago
condaexec="conda"
4 years ago
4 years ago
fi
4 years ago
if [ "$machine" = "MinGw" ]
4 years ago
then
4 years ago
# make sure packages installed
pacman -S mingw-w64-x86_64-zbar curl wget unzip gcc make openssl-devel
4 years ago
if [ ! -f "miniconda.exe" ]
4 years ago
then
4 years ago
arch="$(uname -m)"
if [ "$arch" = "x86_64" ]
then
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Windows-x86_64.exe -o miniconda.exe
else
curl https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.3-Windows-x86.exe -o miniconda.exe
fi
4 years ago
fi
4 years ago
# ./miniconda.exe -b -f -p "$path_conda"
# rm miniconda.exe
4 years ago
# cmd "miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=$path_conda"
4 years ago
4 years ago
path_conda_windows="${path_conda//\//\\}"
4 years ago
wincmd="miniconda.exe /S /D=C:\\msys64$path_conda_windows"
echo "executing! $wincmd"
cmd //c "$wincmd"
4 years ago
4 years ago
export PATH="$path_conda/condabin:$path_conda/Library/bin:$path_conda:$PATH"
4 years ago
# export PATH="$path_conda/Library/bin:$path_conda/Scripts:$path_conda:$PATH"
4 years ago
4 years ago
## looks like we really do need visual studi c++ tools?
4 years ago
# cd $path_lib
# if [ ! -f "vs_BuildTools.exe" ]
# then
# wget https://download.visualstudio.microsoft.com/download/pr/e8bc3741-cb70-42aa-9b4e-2bd497de85dd/c180e363efb5c653acd515349e76c4bd5f60526478d5f71d0907294210978d9f/vs_BuildTools.exe
# cmd //c vs_BuildTools.exe
# fi
4 years ago
4 years ago
### install themis from source
if [ ! -f "/usr/local/lib/libthemis.so" ]
then
if [ ! -f "/usr/lib/libthemis.so" ]
then
echo '
3) building Themis, cryptography backend...
'
cd "$path_lib"
# pwd
curl https://codeload.github.com/cossacklabs/themis/zip/master -o themis.zip
4 years ago
unzip -q -o themis.zip
4 years ago
#mv themis-master themis
cd themis-master
4 years ago
make
make install
4 years ago
fi
fi
4 years ago
condaexec="conda" #$path_conda/condabin/conda.bat"
4 years ago
4 years ago
# cd $path_lib
4 years ago
# curl http://go.microsoft.com/fwlink/?LinkId=691126\&fixForIE=.exe. -o visualcppbuildtools_full.exe
4 years ago
# wget -O visualcppbuildtools_full.exe http://go.microsoft.com/fwlink/?LinkId=691126\&fixForIE=.exe.
# cmd //c "visualcppbuildtools_full.exe"
4 years ago
### install zbar using apt-cyg
# installing apt-cyg
# if ! command -v apt-cyg &> /dev/null
# then
# echo "installing apt-cyg"
# lynx -source https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
# install apt-cyg /bin
# fi
# # installing zbar
# apt-cyg install zbar
4 years ago
fi
4 years ago
4 years ago
echo "path_conda = $path_conda"
4 years ago
4 years ago
# activate conda
4 years ago
export PATH="$path_conda/bin:$PATH"
4 years ago
4 years ago
# $condaexec init bash
# source "`realpath ~/.bashrc`"
4 years ago
4 years ago
source "$path_conda/etc/profile.d/conda.sh"
4 years ago
# condaexec="conda"
4 years ago
pythonexec="python"
4 years ago
$condaexec
4 years ago
4 years ago
echo '
5) creating virtual environment...
4 years ago
'
4 years ago
path_venv="$path_repo/venv"
# cd $path_comrad
4 years ago
cd $path_repo
4 years ago
echo "Now using python (t1): `which python`"
$condaexec create -y -p "$path_venv" python=3.7 cartopy pip virtualenv rtree
4 years ago
4 years ago
source "$path_conda/etc/profile.d/conda.sh"
4 years ago
$condaexec activate "$path_venv"
4 years ago
4 years ago
if [ "$machine" = "MinGw" ]
then
$condaexec install libpython m2w64-toolchain -c msys2
fi
4 years ago
4 years ago
cd $path_lib
git clone https://github.com/seppo0010/rlite.git
cd rlite
make
make install
sudo make install
4 years ago
echo "Now using python (t2): `which python`"
4 years ago
# $pythonexec -m pip install virtualenv
4 years ago
# $pythonexec -m virtualenv venv
# . venv/bin/activate
4 years ago
echo "Now using python (t3): `which python`"
4 years ago
python -m pip install -U setuptools
4 years ago
# cd $path_lib
# git clone https://github.com/seppo0010/rlite-py.git
# cd rlite-py
# python setup.py install
4 years ago
4 years ago
4 years ago
4 years ago
cd $path_repo
4 years ago
if [ "$machine" = "MinGw" ]
then
4 years ago
#python -m pip install --only-binary :all: hirlite
4 years ago
# env CC=/usr/bin/gcc python -m pip install -r requirements.txt
4 years ago
python -m pip install -r requirements.txt
4 years ago
else
python -m pip install -r requirements.txt
fi
if [ "$machine" = "Mac" ]
then
python -m pip install git+https://github.com/kivy/pyobjus
else
$condaexec install wxpython
fi
4 years ago
echo '
4 years ago
6) adding comrad bin folder to path
4 years ago
4 years ago
'
4 years ago
4 years ago
commands_app="
4 years ago
source $path_conda/etc/profile.d/conda.sh\n
export PATH=\"$path_conda/bin:\$PATH\"\n
conda activate $path_venv\n
python -m pip install -r $path_repo/requirements.txt\n
python $path_repo/comrad/app/main.py\n
4 years ago
"
export PATH="$path_bin:$PATH"
bashline="export PATH=\"$path_bin:\$PATH\" # comrad installation"
4 years ago
bashfn="`realpath ~/.bashrc`"
4 years ago
# add to bashrc?
if grep -Fxq "$bashline" "$bashfn"
then
# code if found
echo "setting already in $bashfn: $bashline"
else
# code if not found
echo "$bashline" >> "$bashfn"
fi
4 years ago
4 years ago
echo -e "Now run Comrad with:
4 years ago
comrad-app [GUI interface -- alpha]
4 years ago
If that doesn't work, try running this series of comands:
4 years ago
$commands_app
4 years ago
"
4 years ago
if [ "$machine" = "Mac" ]
then
4 years ago
cd /Applications
4 years ago
unzip -q -o "$path_bin/Comrad.app.zip"
# cp "$path_bin/Comrad.app" /Applications/
4 years ago
echo "You may run the app by looking for 'Comrad.app' in your /Applications folder."
4 years ago
fi
# run?
. $path_bin/comrad-app
4 years ago
if [ "$machine" = "Mac" ]
then
echo "You may run the app by looking for 'Comrad.app' in your /Applications folder."
4 years ago
fi