Skip to content

Commit

Permalink
Apply shellcheck all current shellcheck suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
dmp1ce committed Feb 9, 2022
1 parent 07e198b commit e3cf26f
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ check_exists() {
if check_exists gmake; then
make=gmake
else
make=make
make="make"
fi

sha256_verify ()
Expand Down Expand Up @@ -76,29 +76,29 @@ deps_install ()

deb_deps_check ()
{
apt-cache policy ${deb_deps[@]} | grep "Installed.*none"
apt-cache policy "${deb_deps[@]}" | grep "Installed.*none"
}

deb_deps_install ()
{
deb_deps=( ${@} )
deb_deps=( "${@}" )
if deb_deps_check; then
clear
echo "
sudo password required to run :
\`apt-get install ${deb_deps[@]}\`
\`apt-get install " "${deb_deps[@]}" "\`
"
if ! sudo apt-get install ${deb_deps[@]}; then
if ! sudo apt-get install "${deb_deps[@]}"; then
return 1
fi
fi
}

dar_deps_install ()
{
dar_deps=( ${@} )
if ! brew install ${dar_deps[@]}; then
dar_deps=( "${@}" )
if ! brew install "${dar_deps[@]}"; then
return 1
fi
echo "
Expand All @@ -114,7 +114,7 @@ dar_deps_install ()
check_skip_build ()
{
if [[ ${reinstall} == false ]] && [[ -d "$1" ]]; then
read -p "Directory ${1} exists. Remove and recreate? (y/n) " q
read -r -p "Directory ${1} exists. Remove and recreate? (y/n) " q
if [[ "${q}" =~ Y|y ]]; then
rm -rf "./${1}"
mkdir -p "./${1}"
Expand Down Expand Up @@ -145,15 +145,15 @@ dep_get ()
{
pkg_name="$1" pkg_hash="$2" pkg_url="$3"

pushd cache
pushd cache || return 1
if [ ! -f "${pkg_name}" ] || ! sha256_verify "${pkg_hash}" "${pkg_name}"; then
http_get "${pkg_url}/${pkg_name}" "${pkg_name}"
fi
if ! sha256_verify "${pkg_hash}" "${pkg_name}"; then
return 1
fi
tar -xzf "${pkg_name}" -C ../
popd
popd || return 1
}

# add '--disable-docs' to libffi ./configure so makeinfo isn't needed
Expand Down Expand Up @@ -218,7 +218,7 @@ libffi_install ()
if ! dep_get "${libffi_lib_tar}" "${libffi_lib_sha}" "${libffi_url}"; then
return 1
fi
pushd "${libffi_version}"
pushd "${libffi_version}" || return 1
if ! libffi_patch_disable_docs; then
return 1
fi
Expand All @@ -227,7 +227,7 @@ libffi_install ()
else
return 1
fi
popd
popd || return 1
}

libsecp256k1_build()
Expand Down Expand Up @@ -260,13 +260,13 @@ libsecp256k1_install()
if ! dep_get "${secp256k1_lib_tar}.tar.gz" "${secp256k1_lib_sha}" "${secp256k1_lib_url}"; then
return 1
fi
pushd "secp256k1-${secp256k1_lib_tar}"
pushd "secp256k1-${secp256k1_lib_tar}" || return 1
if libsecp256k1_build; then
$make install
else
return 1
fi
popd
popd || return 1
}

libsodium_build ()
Expand Down Expand Up @@ -298,13 +298,13 @@ libsodium_install ()
if ! dep_get "${sodium_lib_tar}" "${sodium_lib_sha}" "${sodium_url}"; then
return 1
fi
pushd "${sodium_version}"
pushd "${sodium_version}" || return 1
if libsodium_build; then
$make install
else
return 1
fi
popd
popd || return 1
}

joinmarket_install ()
Expand All @@ -315,7 +315,7 @@ joinmarket_install ()
reqs+=( 'gui.txt' )
fi

for req in ${reqs[@]}; do
for req in "${reqs[@]}"; do
pip install -r "requirements/${req}" || return 1
done

Expand All @@ -324,7 +324,7 @@ joinmarket_install ()
echo "Installing XDG desktop entry"
cp -f "$(dirname "$0")/docs/images/joinmarket_logo.png" \
~/.local/share/icons/
cat "$(dirname "$0")/joinmarket-qt.desktop" | \
< "$(dirname "$0")/joinmarket-qt.desktop"\
sed "s/\\\$JMHOME/$(dirname "$(realpath "$0")" | sed 's/\//\\\//g')/" > \
~/.local/share/applications/joinmarket-qt.desktop
fi
Expand All @@ -336,7 +336,7 @@ parse_flags ()
while :; do
case $1 in
--develop)
develop_build='1'
# Currently this flag does nothing.
;;
--disable-os-deps-check)
use_os_deps_check='0'
Expand Down Expand Up @@ -371,7 +371,7 @@ parse_flags ()
;;
*)
echo "
Usage: "${0}" [options]
Usage: ${0} [options]
Options:
Expand All @@ -389,7 +389,7 @@ Options:
done

if [[ ${with_qt} == '' ]]; then
read -p "
read -r -p "
INFO: Joinmarket-Qt for GUI Taker and Tumbler modes is available.
Install Qt dependencies (~160mb) ? [y|n] : "
if [[ ${REPLY} =~ y|Y ]]; then
Expand Down Expand Up @@ -434,20 +434,18 @@ main ()
{
jm_source="$PWD"
jm_root="${jm_source}/jmvenv"
jm_deps="${jm_source}/deps"
export PKG_CONFIG_PATH="${jm_root}/lib/pkgconfig:${PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH="${jm_root}/lib:${LD_LIBRARY_PATH}"
export C_INCLUDE_PATH="${jm_root}/include:${C_INCLUDE_PATH}"
export MAKEFLAGS='-j'

# flags
develop_build=''
python='python3'
use_os_deps_check='1'
use_secp_check='1'
with_qt=''
reinstall='false'
if ! parse_flags ${@}; then
if ! parse_flags "${@}"; then
return 1
fi

Expand All @@ -462,9 +460,10 @@ main ()
echo "Joinmarket virtualenv could not be setup. Exiting."
return 1
fi
# shellcheck disable=SC1091
source "${jm_root}/bin/activate"
mkdir -p "deps/cache"
pushd deps
pushd deps || return 1
if ! libsecp256k1_install; then
echo "libsecp256k1 was not built. Exiting."
return 1
Expand All @@ -477,7 +476,7 @@ main ()
echo "Libsodium was not built. Exiting."
return 1
fi
popd
popd || return 1
if ! joinmarket_install; then
echo "Joinmarket was not installed. Exiting."
deactivate
Expand All @@ -491,4 +490,4 @@ main ()
from this directory, to activate virtualenv."
}
main ${@}
main "${@}"

0 comments on commit e3cf26f

Please sign in to comment.