2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-13 07:10:49 +00:00
Comrad/script/install

470 lines
9.9 KiB
Plaintext
Raw Normal View History

2020-09-14 15:59:11 +00:00
#!/bin/bash
2020-09-14 13:38:27 +00:00
2020-09-26 13:22:08 +00:00
# funcs (mac doesnt have realpath)
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
2020-09-28 12:59:24 +00:00
echo "$1 $2 $3"
2020-09-26 13:24:53 +00:00
2020-09-26 13:22:08 +00:00
2020-09-14 15:59:11 +00:00
# install pyenv?
2020-09-14 14:40:40 +00:00
2020-09-14 15:59:11 +00:00
echo "
2020-10-02 17:49:17 +00:00
### ## # # ### ## ###
# # # #### # # # # # #
# # # #### ### # # # #
# # # # # # # #### # #
### ## # # # # # # ###
2020-09-14 13:38:27 +00:00
2020-10-02 17:49:17 +00:00
2020-09-14 13:38:27 +00:00
installing...
2020-09-14 16:01:38 +00:00
2020-09-14 15:59:11 +00:00
"
2020-09-14 16:01:38 +00:00
echo '
1) setting up folder...
2020-09-14 15:59:11 +00:00
'
# install dir?
2020-09-29 13:09:56 +00:00
echo "Where should comrad live on your device?"
path_comrad_default="`realpath ~/comrad`"
2020-09-28 12:42:29 +00:00
2020-09-28 12:59:24 +00:00
if [ "$1" = "-n" ]
2020-09-28 12:42:29 +00:00
then
2020-09-29 13:09:56 +00:00
read -p "[$path_comrad_default] " path_comrad
2020-09-28 12:42:29 +00:00
else
2020-09-29 13:09:56 +00:00
path_comrad=$path_comrad_default
2020-09-28 12:42:29 +00:00
fi
2020-09-29 13:09:56 +00:00
if [ -z "$path_comrad" ]
2020-09-14 15:59:11 +00:00
then
2020-09-29 13:09:56 +00:00
path_comrad=$path_comrad_default
2020-09-14 15:59:11 +00:00
fi
2020-09-22 13:36:20 +00:00
2020-09-29 13:09:56 +00:00
if [ ! -d "$path_comrad" ]
2020-09-14 15:59:11 +00:00
then
2020-09-29 13:09:56 +00:00
mkdir -p $path_comrad
echo "created $path_comrad"
2020-09-14 15:59:11 +00:00
fi
2020-09-29 13:09:56 +00:00
path_lib="$path_comrad/lib"
if [ ! -d "$path_lib" ]
then
mkdir -p $path_lib
echo "created $path_lib"
fi
2020-09-28 13:22:47 +00:00
2020-09-29 13:09:56 +00:00
path_bin="$path_comrad/code/bin"
2020-09-28 13:20:49 +00:00
# if [ ! -d "$path_bin" ]
# then
# mkdir -p $path_bin
# echo "created $path_bin"
# fi
2020-09-27 12:08:32 +00:00
2020-09-14 16:42:03 +00:00
2020-09-14 15:59:11 +00:00
echo '
2020-09-14 16:01:38 +00:00
2020-09-29 13:09:56 +00:00
2) downloading Comrad...
2020-09-14 16:01:38 +00:00
2020-09-14 15:59:11 +00:00
'
2020-09-29 13:09:56 +00:00
path_repo="$path_comrad/code"
2020-09-14 16:56:54 +00:00
if command -v git &> /dev/null
2020-09-14 15:59:11 +00:00
then
2020-09-14 17:01:36 +00:00
echo "using git..."
2020-09-14 16:52:59 +00:00
if [ -d "$path_repo" ]
2020-09-14 15:59:11 +00:00
then
cd $path_repo
git pull
else
2020-09-29 13:09:56 +00:00
cd $path_comrad
2020-09-14 18:49:14 +00:00
2020-09-28 12:59:24 +00:00
if [ "$1" = "-n" ]
2020-09-28 12:42:29 +00:00
then
echo "Use HTTPS or SSH for git?"
read -p "[HTTPS/ssh] " git_method
else
git_method="https"
fi
2020-09-17 05:01:59 +00:00
if [ "$git_method" = "ssh" ]
2020-09-14 18:49:14 +00:00
then
echo "using ssh..."
2020-09-29 16:05:19 +00:00
git clone git@github.com:ComradOrg/Comrad.git
2020-10-02 17:48:26 +00:00
#git checkout installer
2020-09-14 18:49:14 +00:00
else
2020-09-29 16:05:19 +00:00
git clone https://github.com/ComradOrg/Comrad.git
2020-10-02 17:48:26 +00:00
#git checkout installer
2020-09-14 18:49:14 +00:00
fi
2020-09-29 13:09:56 +00:00
mv Comrad code
2020-09-14 15:59:11 +00:00
fi
else
2020-09-29 13:09:56 +00:00
cd $path_comrad
2020-09-29 16:05:19 +00:00
curl -s -LO https://github.com/ComradOrg/Comrad/archive/installer.zip
2020-10-02 21:06:02 +00:00
unzip -q -o installer.zip
2020-09-22 13:38:52 +00:00
rm installer.zip
2020-09-29 13:09:56 +00:00
cp -rT Comrad-installer code
rm -r Comrad-installer
2020-09-14 15:59:11 +00:00
fi
2020-09-22 13:27:34 +00:00
2020-09-22 12:54:50 +00:00
#########################################################
##########################################################
2020-09-14 16:42:03 +00:00
2020-09-14 16:01:38 +00:00
echo '
4) setting up python...
2020-09-14 16:01:38 +00:00
2020-09-22 11:13:48 +00:00
# '
2020-09-14 15:59:11 +00:00
2020-09-14 16:42:03 +00:00
2020-09-29 13:09:56 +00:00
cd $path_comrad
2020-09-22 13:26:18 +00:00
2020-09-29 13:09:56 +00:00
path_conda="$path_comrad/lib/miniconda3"
2020-09-22 13:27:34 +00:00
# ### Detect if python 3.7?
# pyv="$(python3 -c 'import sys; print(sys.version_info[0:2])')"
# if [ ! "$pyv" = "(3, 7)" ]
2020-09-22 13:26:18 +00:00
# then
2020-09-22 13:27:34 +00:00
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
2020-10-02 19:02:40 +00:00
MSYS*) machine=MinGw;;
2020-09-22 13:27:34 +00:00
*) machine="UNKNOWN:${unameOut}"
esac
2020-10-02 18:57:13 +00:00
# echo ${machine}
2020-10-02 18:58:34 +00:00
echo "Machine $machine detected."
2020-09-22 13:27:34 +00:00
if [ "$machine" = "Linux" ]
then
2020-09-25 11:50:43 +00:00
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
2020-09-25 11:44:39 +00:00
./miniconda.sh -b -f -p "$path_conda"
2020-09-25 11:50:43 +00:00
#rm miniconda.sh
2020-09-27 12:08:32 +00:00
### 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
2020-10-02 17:46:48 +00:00
#git clone https://github.com/cossacklabs/themis.git
curl https://codeload.github.com/cossacklabs/themis/zip/master -o themis.zip
2020-10-02 21:06:02 +00:00
unzip -q -o themis.zip
2020-10-02 17:58:53 +00:00
#mv themis-master themis
cd themis-master
2020-09-27 12:08:32 +00:00
make
sudo make install
fi
fi
### install zbar library
2020-10-04 18:14:23 +00:00
# sudo apt install zbar-tools
2020-09-27 12:08:32 +00:00
2020-10-02 20:32:41 +00:00
condaexec="conda"
2020-09-22 13:36:20 +00:00
fi
if [ "$machine" = "Mac" ]
2020-09-22 13:27:34 +00:00
then
2020-09-25 11:50:43 +00:00
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
2020-09-25 11:44:39 +00:00
./miniconda.sh -b -f -p "$path_conda"
2020-09-25 11:50:43 +00:00
# rm miniconda.sh
2020-09-27 12:08:32 +00:00
2020-09-28 12:56:29 +00:00
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
2020-09-27 12:08:32 +00:00
# brew install
2020-09-28 12:56:29 +00:00
/usr/local/bin/brew tap cossacklabs/tap
/usr/local/bin/brew install libthemis
2020-09-27 12:08:32 +00:00
# install zbar library
2020-10-04 18:14:23 +00:00
# /usr/local/bin/brew install zbar
2020-09-27 12:08:32 +00:00
2020-10-02 20:32:41 +00:00
condaexec="conda"
2020-09-27 12:08:32 +00:00
2020-09-22 13:36:20 +00:00
fi
2020-10-02 22:14:33 +00:00
if [ "$machine" = "MinGw" ]
2020-09-22 13:27:34 +00:00
then
2020-10-02 22:14:33 +00:00
# make sure packages installed
2020-10-04 18:14:23 +00:00
# pacman -S mingw-w64-x86_64-zbar curl wget unzip gcc make openssl-devel
pacman -S curl wget unzip gcc make openssl-devel
2020-10-02 22:14:33 +00:00
2020-10-04 08:27:31 +00:00
if [ ! -f "miniconda.exe" ]
2020-10-04 08:30:33 +00:00
then
2020-10-04 08:27:31 +00:00
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
2020-09-22 13:27:34 +00:00
fi
2020-10-02 19:48:53 +00:00
# ./miniconda.exe -b -f -p "$path_conda"
# rm miniconda.exe
2020-10-02 20:14:17 +00:00
# cmd "miniconda.exe /InstallationType=JustMe /RegisterPython=0 /S /D=$path_conda"
2020-10-02 22:14:33 +00:00
2020-10-02 20:20:54 +00:00
path_conda_windows="${path_conda//\//\\}"
2020-10-02 20:14:17 +00:00
wincmd="miniconda.exe /S /D=C:\\msys64$path_conda_windows"
echo "executing! $wincmd"
cmd //c "$wincmd"
2020-10-02 22:14:33 +00:00
2020-10-04 10:13:42 +00:00
export PATH="$path_conda/condabin:$path_conda/Library/bin:$path_conda:$PATH"
2020-10-04 10:04:48 +00:00
# export PATH="$path_conda/Library/bin:$path_conda/Scripts:$path_conda:$PATH"
2020-10-04 08:17:12 +00:00
2020-10-04 09:09:27 +00:00
## looks like we really do need visual studi c++ tools?
2020-10-04 09:49:12 +00:00
# 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
2020-10-04 09:24:12 +00:00
2020-09-27 12:08:32 +00:00
2020-10-04 10:52:04 +00:00
2020-10-04 10:27:50 +00:00
condaexec="conda" #$path_conda/condabin/conda.bat"
2020-10-02 20:32:41 +00:00
2020-10-03 17:45:31 +00:00
# cd $path_lib
2020-10-02 21:24:49 +00:00
# curl http://go.microsoft.com/fwlink/?LinkId=691126\&fixForIE=.exe. -o visualcppbuildtools_full.exe
2020-10-03 17:45:31 +00:00
# wget -O visualcppbuildtools_full.exe http://go.microsoft.com/fwlink/?LinkId=691126\&fixForIE=.exe.
# cmd //c "visualcppbuildtools_full.exe"
2020-09-27 12:08:32 +00:00
### install zbar using apt-cyg
# installing apt-cyg
2020-10-02 17:46:48 +00:00
# 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
2020-09-22 13:27:34 +00:00
fi
2020-09-22 13:36:20 +00:00
2020-10-02 20:32:41 +00:00
echo "path_conda = $path_conda"
2020-09-25 13:17:03 +00:00
2020-09-25 11:44:39 +00:00
# activate conda
2020-09-25 11:50:43 +00:00
export PATH="$path_conda/bin:$PATH"
2020-09-25 13:17:03 +00:00
2020-10-03 18:17:49 +00:00
# $condaexec init bash
# source "`realpath ~/.bashrc`"
2020-10-03 18:07:24 +00:00
2020-09-25 13:17:03 +00:00
source "$path_conda/etc/profile.d/conda.sh"
2020-10-04 10:44:13 +00:00
if [ "$machine" = "MinGw" ]
then
cmd //c call "$path_conda/Scripts/activate"
fi
2020-09-25 13:17:03 +00:00
2020-10-04 10:13:42 +00:00
# condaexec="conda"
2020-09-25 11:50:43 +00:00
pythonexec="python"
2020-09-22 13:26:18 +00:00
2020-10-03 18:17:49 +00:00
$condaexec
2020-10-04 08:50:22 +00:00
2020-09-22 13:27:34 +00:00
echo '
2020-09-22 13:26:18 +00:00
5) creating virtual environment...
2020-09-22 13:26:18 +00:00
2020-09-22 13:27:34 +00:00
'
2020-09-25 12:37:13 +00:00
path_venv="$path_repo/venv"
2020-09-22 13:26:18 +00:00
2020-09-29 13:09:56 +00:00
# cd $path_comrad
2020-09-25 11:33:02 +00:00
cd $path_repo
2020-10-02 18:27:27 +00:00
echo "Now using python (t1): `which python`"
2020-10-04 18:14:23 +00:00
$condaexec create -y -p "$path_venv" python=3.7 cartopy pip virtualenv rtree pyzbar
2020-09-25 13:17:03 +00:00
2020-10-03 17:58:55 +00:00
source "$path_conda/etc/profile.d/conda.sh"
2020-10-04 10:44:13 +00:00
cd $path_venv
if [ "$machine" = "MinGw" ]
then
cmd //c call "$path_conda/Scripts/activate"
fi
2020-10-03 17:58:55 +00:00
2020-10-03 17:51:54 +00:00
$condaexec activate "$path_venv"
2020-09-25 13:17:03 +00:00
2020-10-04 10:44:13 +00:00
$condaexec
2020-10-04 18:14:23 +00:00
# if [ "$machine" = "MinGw" ]
# then
# $condaexec install libpython m2w64-toolchain -c msys2
# fi
2020-10-04 09:49:12 +00:00
2020-09-25 13:17:03 +00:00
2020-10-04 10:13:42 +00:00
cd $path_lib
git clone https://github.com/seppo0010/rlite.git
cd rlite
make
make install
sudo make install
2020-10-04 10:52:04 +00:00
### install themis from source
if [ "$machine" = "MinGw" ]
then
if [ ! -f "/usr/local/lib/libthemis.so" ]
then
if [ ! -f "/usr/lib/libthemis.so" ]
then
echo '
2020-10-04 10:13:42 +00:00
2020-10-04 10:52:04 +00:00
Building Themis, cryptography backend...
2020-10-04 10:13:42 +00:00
2020-10-04 10:52:04 +00:00
'
cd "$path_lib"
# pwd
curl https://codeload.github.com/cossacklabs/themis/zip/master -o themis.zip
unzip -q -o themis.zip
#mv themis-master themis
cd themis-master
make
make install
fi
fi
fi
2020-10-04 10:13:42 +00:00
2020-10-02 18:27:27 +00:00
echo "Now using python (t2): `which python`"
2020-09-25 11:33:02 +00:00
# $pythonexec -m pip install virtualenv
2020-09-25 12:10:13 +00:00
# $pythonexec -m virtualenv venv
# . venv/bin/activate
2020-10-02 18:27:27 +00:00
echo "Now using python (t3): `which python`"
2020-10-04 09:24:12 +00:00
python -m pip install -U setuptools
2020-10-01 16:26:35 +00:00
2020-10-04 09:09:27 +00:00
# cd $path_lib
# git clone https://github.com/seppo0010/rlite-py.git
# cd rlite-py
# python setup.py install
2020-10-04 08:55:14 +00:00
2020-10-04 08:55:46 +00:00
2020-10-04 10:13:42 +00:00
2020-10-04 08:55:46 +00:00
cd $path_repo
2020-10-03 17:45:31 +00:00
if [ "$machine" = "MinGw" ]
then
2020-10-04 08:55:14 +00:00
#python -m pip install --only-binary :all: hirlite
2020-10-04 08:27:31 +00:00
# env CC=/usr/bin/gcc python -m pip install -r requirements.txt
2020-10-04 08:35:09 +00:00
python -m pip install -r requirements.txt
2020-10-03 17:45:31 +00:00
else
python -m pip install -r requirements.txt
fi
2020-10-01 16:26:35 +00:00
if [ "$machine" = "Mac" ]
then
python -m pip install git+https://github.com/kivy/pyobjus
else
$condaexec install wxpython
fi
2020-09-22 13:23:49 +00:00
echo '
2020-09-22 10:02:40 +00:00
2020-09-29 13:09:56 +00:00
6) adding comrad bin folder to path
2020-09-22 10:02:40 +00:00
2020-09-22 13:23:49 +00:00
'
2020-09-14 15:59:11 +00:00
2020-09-27 12:08:32 +00:00
commands_app="
2020-09-28 13:17:52 +00:00
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
2020-09-29 13:09:56 +00:00
python $path_repo/comrad/app/main.py\n
2020-09-27 12:08:32 +00:00
"
export PATH="$path_bin:$PATH"
2020-09-29 13:09:56 +00:00
bashline="export PATH=\"$path_bin:\$PATH\" # comrad installation"
2020-09-29 15:35:33 +00:00
bashfn="`realpath ~/.bashrc`"
2020-09-27 12:08:32 +00:00
# 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
2020-09-22 10:02:40 +00:00
2020-09-22 13:36:20 +00:00
2020-09-29 13:09:56 +00:00
echo -e "Now run Comrad with:
2020-09-22 10:02:40 +00:00
2020-09-29 13:09:56 +00:00
comrad-app [GUI interface -- alpha]
2020-09-22 11:16:30 +00:00
If that doesn't work, try running this series of comands:
2020-09-27 12:08:32 +00:00
$commands_app
2020-09-22 13:23:49 +00:00
"
2020-09-28 13:17:52 +00:00
if [ "$machine" = "Mac" ]
then
2020-09-28 13:55:01 +00:00
cd /Applications
2020-10-02 21:06:02 +00:00
unzip -q -o "$path_bin/Comrad.app.zip"
2020-09-29 13:09:56 +00:00
# cp "$path_bin/Comrad.app" /Applications/
2020-09-28 13:17:52 +00:00
2020-09-29 13:09:56 +00:00
echo "You may run the app by looking for 'Comrad.app' in your /Applications folder."
2020-09-29 06:14:13 +00:00
fi
2020-10-04 10:44:13 +00:00
2020-09-29 06:14:13 +00:00
# run?
2020-09-29 13:09:56 +00:00
. $path_bin/comrad-app
2020-09-29 06:14:13 +00:00
if [ "$machine" = "Mac" ]
then
2020-09-29 13:09:56 +00:00
echo "You may run the app by looking for 'Comrad.app' in your /Applications folder."
2020-09-28 13:17:52 +00:00
fi