1 changed files with 292 additions and 131 deletions
@ -1,132 +1,293 @@ |
|||||||
#!/bin/bash |
#!/bin/bash |
||||||
set -e |
|
||||||
clear |
# jm_source="$PWD/.." |
||||||
|
# jm_root="${jm_source}/jmvenv" |
||||||
#Adapted from https://github.com/tailsjoin/tailsjoin/blob/master/tailsjoin-fullnode.sh |
# jm_deps="${jm_source}/deps" |
||||||
|
|
||||||
# Check for root. |
gpg_verify_key () |
||||||
if [[ $(id -u) = "0" ]]; then |
{ |
||||||
echo " |
gpg --keyid-format long <"$1" | grep "$2" |
||||||
YOU SHOULD NOT RUN THIS SCRIPT AS ROOT! |
} |
||||||
YOU WILL BE PROMPTED FOR THE ADMIN PASS WHEN NEEDED. |
|
||||||
" |
gpg_add_to_keyring () |
||||||
read -p "PRESS ENTER TO EXIT SCRIPT, AND RUN AGAIN AS NON-ROOT USER. " |
{ |
||||||
exit 0 |
gpg --dearmor <"$1" >>"${jm_deps}/keyring.gpg" |
||||||
fi |
} |
||||||
|
|
||||||
|
gpg_verify_sig () |
||||||
# Make sure user has chosen the correct script. |
{ |
||||||
echo " |
gpg --no-default-keyring --keyring "${jm_deps}/keyring.gpg" --verify "$1" |
||||||
THIS SCRIPT WILL INSTALL JOINMARKET-CS AND DEPENDENCIES. |
} |
||||||
ADMIN PASS WILL BE REQUIRED MULTIPLE TIMES. |
|
||||||
" |
deb_deps_check () |
||||||
read -p "PRESS ENTER TO CONTINUE. " |
{ |
||||||
clear |
apt-cache policy ${deb_deps[@]} |
||||||
|
} |
||||||
# Update apt-get sources. |
|
||||||
echo " |
deb_deps_install () |
||||||
ENTER PASSWORD TO UPDATE SOURCES. |
{ |
||||||
" |
deb_deps=( 'python-virtualenv' 'curl' 'python-dev' 'python-pip' 'build-essential' 'automake' 'pkg-config' 'libtool' ) |
||||||
sudo apt-get update |
if ! deb_deps_check; then |
||||||
clear |
clear |
||||||
|
echo " |
||||||
|
sudo password required to run : |
||||||
# Install dependencies for building libsodium. |
|
||||||
echo " |
\`apt-get install ${deb_deps[@]}\` |
||||||
ENTER PASSWORD TO INSTALL: python-virtualenv curl python-dev python-pip git build-essential automake pkg-config libtool libffi-dev libssl-dev |
" |
||||||
" |
if ! sudo apt-get install ${deb_deps[@]}; then |
||||||
sudo apt-get install -y python-virtualenv curl python-dev python-pip git build-essential automake pkg-config libtool libffi-dev libssl-dev |
return 1 |
||||||
clear |
fi |
||||||
|
fi |
||||||
# Get libsodium, sig, and import key. |
} |
||||||
echo " |
|
||||||
DOWNLOADING LIBSODIUM SOURCE AND SIGNING KEY... |
check_skip_build () |
||||||
" |
{ |
||||||
gpg --keyserver pgp.mit.edu --recv-keys 54A2B8892CC3D6A597B92B6C210627AABA709FE1 |
if ! mkdir "$1"; then |
||||||
echo "54A2B8892CC3D6A597B92B6C210627AABA709FE1:6" | gpg --import-ownertrust - |
read -p "Directory ${1} exists. Remove and recreate? (y/n) " q |
||||||
curl -L -O http://download.libsodium.org/libsodium/releases/libsodium-1.0.12.tar.gz -O http://download.libsodium.org/libsodium/releases/libsodium-1.0.12.tar.gz.sig |
if [[ "${q}" =~ Y|y ]]; then |
||||||
clear |
rm -rf "./${1}" |
||||||
|
return 1 |
||||||
|
else |
||||||
# Verify download. |
echo "skipping ${1}..." |
||||||
echo " |
return 0 |
||||||
VERIFYING THE DOWNLOAD... |
fi |
||||||
" |
fi |
||||||
gpg --verify libsodium-1.0.12.tar.gz.sig libsodium-1.0.12.tar.gz |
return 1 |
||||||
echo " |
} |
||||||
PLEASE REVIEW THE TEXT ABOVE. |
|
||||||
IT WILL EITHER SAY GOOD SIG OR BAD SIG. |
venv_setup () |
||||||
" |
{ |
||||||
read -p "IS IT A GOOD SIG? (y/n) " x |
if check_skip_build 'jmvenv'; then |
||||||
if [[ "$x" = "n" || "$x" = "N" ]]; then |
return 0 |
||||||
echo " |
fi |
||||||
YOU REJECTED THE LIBSODIUM SIGNATURE, GIVING UP... |
virtualenv -p python2 jmvenv |
||||||
" |
} |
||||||
srm -drv libsodium* |
|
||||||
exit 0 |
openssl_get () |
||||||
fi |
{ |
||||||
clear |
for file in "${openssl_lib_tar}" "${openssl_lib_sha}" "${openssl_lib_sig}"; do |
||||||
|
curl -L -O "${openssl_url}/${file}" |
||||||
|
done |
||||||
# Build and install libsodium. |
curl -L "${openssl_signer_key_url}" -o openssl_signer.key |
||||||
tar xf libsodium*.tar.gz |
} |
||||||
rm -rf libsodium*.tar.gz* |
|
||||||
|
openssl_build () |
||||||
echo " |
{ |
||||||
BUILDING LIBSODIUM... |
./config shared --prefix="${jm_root}" |
||||||
" |
make -j |
||||||
cd libsodium-1.0.12/ && ./configure && make |
if ! make test; then |
||||||
echo " |
return 1 |
||||||
LIBSODIUM SUCCESSFULLY BUILT. ENTER PASSWORD TO INSTALL. |
fi |
||||||
" |
} |
||||||
sudo make install |
|
||||||
cd .. |
openssl_install () |
||||||
rm -rf libsodium* |
{ |
||||||
clear |
openssl_version='openssl-1.0.2l' |
||||||
|
openssl_lib_tar="${openssl_version}.tar.gz" |
||||||
# Verify the signature on joinmarket-clientserver |
openssl_lib_sha="${openssl_lib_tar}.sha256" |
||||||
# Currently commented out - doesn't apply if you've already downloaded the repo |
openssl_lib_sig="${openssl_lib_tar}.asc" |
||||||
# either as zip or clone; can check valid signature on github (OK?) |
openssl_url='https://www.openssl.org/source' |
||||||
#gpg --keyserver pgp.mit.edu --recv-keys 46689728A9F64B391FA871B7B3AE09F1E9A3197A |
openssl_signer_key_url='https://pgp.mit.edu/pks/lookup?op=get&search=0xD9C4D26D0E604491' |
||||||
#echo "46689728A9F64B391FA871B7B3AE09F1E9A3197A:6" | gpg --import-ownertrust - |
openssl_signer_key_id='2048R/D9C4D26D0E604491' |
||||||
#Todo: handle signing by another key and check the release tag, not commit. |
openssl_root="${jm_deps}/openssl" |
||||||
#git verify-commit HEAD || { |
|
||||||
# echo 'Latest code commit does not have a valid signature; quitting' |
if check_skip_build 'openssl'; then |
||||||
# exit 0 |
return 0 |
||||||
#} |
fi |
||||||
|
pushd openssl |
||||||
#Run the python installation of joinmarket-clientserver; |
openssl_get |
||||||
#note that this is a 'full' installation, which is the default |
if ! grep $(sha256sum "${openssl_lib_tar}") "${openssl_lib_sha}"; then |
||||||
#for an ordinary user; this should be enhanced to allow custom |
return 1 |
||||||
#installation styles. |
fi |
||||||
#Installs into a virtualenv, so instructions to run must be included. |
if gpg_verify_key openssl_signer.key "${openssl_signer_key_id}"; then |
||||||
if ! mkdir venv; then |
gpg_add_to_keyring openssl_signer.key |
||||||
echo "virtualenv directory already exists; assuming valid." |
else |
||||||
fi |
return 1 |
||||||
virtualenv jmvenv |
fi |
||||||
source jmvenv/bin/activate |
if gpg_verify_sig "${openssl_lib_sig}"; then |
||||||
#required for older pips, e.g. on Ubuntu 14.04 |
tar xaf "${openssl_lib_tar}" |
||||||
pip install --upgrade setuptools |
else |
||||||
#Doing manually instead of as in setupall.py |
return 1 |
||||||
cd jmbase |
fi |
||||||
pip install . |
pushd "${openssl_version}" |
||||||
cd .. |
if openssl_build; then |
||||||
cd jmdaemon |
make install |
||||||
pip install . |
else |
||||||
cd .. |
return 1 |
||||||
cd jmbitcoin |
fi |
||||||
pip install . |
popd |
||||||
cd .. |
popd |
||||||
cd jmclient |
} |
||||||
pip install . |
|
||||||
cd .. |
# add '--disable-docs' to libffi ./configure so makeinfo isn't needed |
||||||
|
# https://github.com/libffi/libffi/pull/190/commits/fa7a257113e2cfc963a0be9dca5d7b4c73999dcc |
||||||
# Final notes. |
libffi_patch_disable_docs () |
||||||
echo " |
{ |
||||||
JOINMARKET SUCCESSFULLY INSTALLED. |
cat <<'EOF' > Makefile.am.patch |
||||||
BEFORE RUNNING SCRIPTS, TYPE: |
56c56,59 |
||||||
source jmvenv/bin/activate |
< info_TEXINFOS = doc/libffi.texi |
||||||
FROM THIS DIRECTORY, TO ACTIVATE THE VIRTUALENV. |
--- |
||||||
" |
> info_TEXINFOS = |
||||||
read -p "PRESS ENTER TO EXIT SCRIPT. " |
> if BUILD_DOCS |
||||||
exit 0; |
> #info_TEXINFOS += doc/libffi.texi |
||||||
|
> endif |
||||||
|
EOF |
||||||
|
|
||||||
|
cat <<'EOF' > configure.ac.patch |
||||||
|
545a546,552 |
||||||
|
> AC_ARG_ENABLE(docs, |
||||||
|
> AC_HELP_STRING([--disable-docs], |
||||||
|
> [Disable building of docs (default: no)]), |
||||||
|
> [enable_docs=no], |
||||||
|
> [enable_docs=yes]) |
||||||
|
> AM_CONDITIONAL(BUILD_DOCS, [test x$enable_docs = xyes]) |
||||||
|
> |
||||||
|
EOF |
||||||
|
patch Makefile.am Makefile.am.patch |
||||||
|
patch configure.ac configure.ac.patch |
||||||
|
} |
||||||
|
|
||||||
|
libffi_build () |
||||||
|
{ |
||||||
|
./autogen.sh |
||||||
|
./configure --disable-docs --enable-shared --prefix="${jm_root}" |
||||||
|
make -j |
||||||
|
if ! make check; then |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
libffi_install () |
||||||
|
{ |
||||||
|
libffi_version='libffi-3.2.1' |
||||||
|
libffi_lib_tar="v3.2.1.tar.gz" |
||||||
|
libffi_lib_sha='96d08dee6f262beea1a18ac9a3801f64018dc4521895e9198d029d6850febe23' |
||||||
|
libffi_url="https://github.com/libffi/libffi/archive" |
||||||
|
|
||||||
|
if check_skip_build 'libffi'; then |
||||||
|
return 0 |
||||||
|
fi |
||||||
|
pushd libffi |
||||||
|
curl -L -O "${libffi_url}/${libffi_lib_tar}" |
||||||
|
if sha256sum -c <<<"${libffi_lib_sha} ${libffi_lib_tar}"; then |
||||||
|
tar xaf "${libffi_lib_tar}" |
||||||
|
else |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
pushd "${libffi_version}" |
||||||
|
if ! libffi_patch_disable_docs; then |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
if libffi_build; then |
||||||
|
make install |
||||||
|
else |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
popd |
||||||
|
popd |
||||||
|
} |
||||||
|
|
||||||
|
libsodium_get () |
||||||
|
{ |
||||||
|
for file in "${sodium_lib_tar}" "${sodium_lib_sig}"; do |
||||||
|
curl -L -O "${sodium_url}/${file}" |
||||||
|
done |
||||||
|
curl -L "${sodium_signer_key_url}" -o libsodium_signer.key |
||||||
|
} |
||||||
|
|
||||||
|
libsodium_build () |
||||||
|
{ |
||||||
|
./autogen.sh |
||||||
|
./configure --enable-shared --prefix="${jm_root}" |
||||||
|
make -j |
||||||
|
if ! make check; then |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
libsodium_install () |
||||||
|
{ |
||||||
|
sodium_version='libsodium-1.0.13' |
||||||
|
sodium_lib_tar="${sodium_version}.tar.gz" |
||||||
|
sodium_lib_sig="${sodium_lib_tar}.sig" |
||||||
|
sodium_url='https://download.libsodium.org/libsodium/releases' |
||||||
|
sodium_signer_key_url='https://pgp.mit.edu/pks/lookup?op=get&search=0x210627AABA709FE1' |
||||||
|
sodium_signer_key_id='4096R/62F25B592B6F76DA' |
||||||
|
|
||||||
|
if check_skip_build 'libsodium'; then |
||||||
|
return 0 |
||||||
|
fi |
||||||
|
pushd libsodium |
||||||
|
libsodium_get |
||||||
|
if gpg_verify_key libsodium_signer.key "${sodium_signer_key_id}"; then |
||||||
|
gpg_add_to_keyring libsodium_signer.key |
||||||
|
else |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
if gpg_verify_sig "${sodium_lib_sig}"; then |
||||||
|
tar xaf "${sodium_lib_tar}" |
||||||
|
else |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
pushd "${sodium_version}" |
||||||
|
if libsodium_build; then |
||||||
|
make install |
||||||
|
else |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
popd |
||||||
|
popd |
||||||
|
} |
||||||
|
|
||||||
|
joinmarket_install () |
||||||
|
{ |
||||||
|
jm_pkgs=( 'jmbase' 'jmdaemon' 'jmbitcoin' 'jmclient' ) |
||||||
|
for pkg in ${jm_pkgs[@]}; do |
||||||
|
pushd "${pkg}" |
||||||
|
pip install . |
||||||
|
popd |
||||||
|
done |
||||||
|
} |
||||||
|
|
||||||
|
main () |
||||||
|
{ |
||||||
|
jm_source="$PWD" |
||||||
|
jm_root="${jm_source}/jmvenv" |
||||||
|
jm_deps="${jm_source}/deps" |
||||||
|
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:${jm_root}/lib/pkgconfig" |
||||||
|
|
||||||
|
if ! deb_deps_install; then |
||||||
|
echo "Dependecies could not be installed. Exiting." |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
if ! venv_setup; then |
||||||
|
echo "Joinmarket virtualenv could not be setup. Exiting." |
||||||
|
fi |
||||||
|
source "${jm_root}/bin/activate" |
||||||
|
mkdir -p deps |
||||||
|
pushd deps |
||||||
|
rm -f ./keyring.gpg |
||||||
|
if ! openssl_install; then |
||||||
|
echo "Openssl was not built. Exiting." |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
if ! libffi_install; then |
||||||
|
echo "Libffi was not built. Exiting." |
||||||
|
return 1 |
||||||
|
fi |
||||||
|
if ! libsodium_install; then |
||||||
|
echo "Libsodium was not built. Exiting." |
||||||
|
fi |
||||||
|
popd |
||||||
|
if ! joinmarket_install; then |
||||||
|
echo "Joinmarket was not installed. Exiting." |
||||||
|
fi |
||||||
|
deactivate |
||||||
|
echo "Joinmarket successfully installed |
||||||
|
Before executing scripts or tests, run: |
||||||
|
|
||||||
|
\`source jmvenv/bin/activate\` |
||||||
|
|
||||||
|
from this directiry, to acticate virtualenv." |
||||||
|
} |
||||||
|
main |
||||||
|
|||||||
Loading…
Reference in new issue