removed bashisms from build scripts
Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
parent
49d76cf3f6
commit
762f643613
|
@ -30,6 +30,7 @@ disabled=(
|
|||
SC2006 # Use $(..) instead of legacy `..`.
|
||||
SC2016 # Expressions don't expand in single quotes, use double quotes for that.
|
||||
SC2028 # echo won't expand escape sequences. Consider printf.
|
||||
SC2039 # In POSIX sh, 'local' is undefined.
|
||||
SC2046 # Quote this to prevent word splitting.
|
||||
SC2048 # Use "$@" (with quotes) to prevent whitespace problems.
|
||||
SC2066 # Since you double quoted this, it will not word split, and the loop will only run once.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=C
|
||||
set -eu -o pipefail
|
||||
set -eu
|
||||
set +x
|
||||
|
||||
function cmd_pref() {
|
||||
if type -p "$2" > /dev/null; then
|
||||
cmd_pref() {
|
||||
if command -v "$2" >/dev/null; then
|
||||
eval "$1=$2"
|
||||
else
|
||||
eval "$1=$3"
|
||||
|
@ -13,7 +13,7 @@ function cmd_pref() {
|
|||
}
|
||||
|
||||
# If a g-prefixed version of the command exists, use it preferentially.
|
||||
function gprefix() {
|
||||
gprefix() {
|
||||
cmd_pref "$1" "g$2" "$2"
|
||||
}
|
||||
|
||||
|
@ -22,21 +22,21 @@ cd "$(dirname "$("$READLINK" -f "$0")")/.."
|
|||
|
||||
# Allow user overrides to $MAKE. Typical usage for users who need it:
|
||||
# MAKE=gmake ./zcutil/build.sh -j$(nproc)
|
||||
if [[ -z "${MAKE-}" ]]; then
|
||||
if [ -z "${MAKE-}" ]; then
|
||||
MAKE=make
|
||||
fi
|
||||
|
||||
# Allow overrides to $BUILD and $HOST for porters. Most users will not need it.
|
||||
# BUILD=i686-pc-linux-gnu ./zcutil/build.sh
|
||||
if [[ -z "${BUILD-}" ]]; then
|
||||
if [ -z "${BUILD-}" ]; then
|
||||
BUILD="$(./depends/config.guess)"
|
||||
fi
|
||||
if [[ -z "${HOST-}" ]]; then
|
||||
if [ -z "${HOST-}" ]; then
|
||||
HOST="$BUILD"
|
||||
fi
|
||||
|
||||
# Allow users to set arbitrary compile flags. Most users will not need this.
|
||||
if [[ -z "${CONFIGURE_FLAGS-}" ]]; then
|
||||
if [ -z "${CONFIGURE_FLAGS-}" ]; then
|
||||
CONFIGURE_FLAGS=""
|
||||
fi
|
||||
|
||||
|
@ -69,13 +69,13 @@ set -x
|
|||
eval "$MAKE" --version
|
||||
as --version
|
||||
|
||||
ENABLE_DEBUG_REGEX='^(.*\s)?--enable-debug(\s.*)?$'
|
||||
if [[ "$CONFIGURE_FLAGS" =~ $ENABLE_DEBUG_REGEX ]]
|
||||
then
|
||||
case "$CONFIGURE_FLAGS" in
|
||||
(*"--enable-debug"*)
|
||||
DEBUG=1
|
||||
else
|
||||
;;
|
||||
(*)
|
||||
DEBUG=
|
||||
fi
|
||||
;;esac
|
||||
|
||||
HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ DEBUG="$DEBUG"
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=C
|
||||
set -eu
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
uname_S=$(uname -s 2>/dev/null || echo not)
|
||||
|
||||
if [ "$uname_S" = "Darwin" ]; then
|
||||
PARAMS_DIR="$HOME/Library/Application Support/ZcashParams"
|
||||
else
|
||||
PARAMS_DIR="$HOME/.zcash-params"
|
||||
|
@ -30,7 +32,7 @@ ZC_DISABLE_WGET="${ZC_DISABLE_WGET:-}"
|
|||
ZC_DISABLE_IPFS="${ZC_DISABLE_IPFS:-}"
|
||||
ZC_DISABLE_CURL="${ZC_DISABLE_CURL:-}"
|
||||
|
||||
function fetch_wget {
|
||||
fetch_wget() {
|
||||
if [ -z "$WGETCMD" ] || ! [ -z "$ZC_DISABLE_WGET" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
@ -51,7 +53,7 @@ EOF
|
|||
"$DOWNLOAD_URL/$filename"
|
||||
}
|
||||
|
||||
function fetch_ipfs {
|
||||
fetch_ipfs() {
|
||||
if [ -z "$IPFSCMD" ] || ! [ -z "$ZC_DISABLE_IPFS" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
@ -67,7 +69,7 @@ EOF
|
|||
ipfs get --output "$dlname" "$IPFS_HASH/$filename"
|
||||
}
|
||||
|
||||
function fetch_curl {
|
||||
fetch_curl() {
|
||||
if [ -z "$CURLCMD" ] || ! [ -z "$ZC_DISABLE_CURL" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
@ -87,7 +89,7 @@ EOF
|
|||
|
||||
}
|
||||
|
||||
function fetch_failure {
|
||||
fetch_failure() {
|
||||
cat >&2 <<EOF
|
||||
|
||||
Failed to fetch the Zcash zkSNARK parameters!
|
||||
|
@ -101,7 +103,7 @@ EOF
|
|||
exit 1
|
||||
}
|
||||
|
||||
function fetch_params {
|
||||
fetch_params() {
|
||||
local filename="$1"
|
||||
local output="$2"
|
||||
local dlname="${output}.dl"
|
||||
|
@ -146,9 +148,9 @@ EOF
|
|||
}
|
||||
|
||||
# Use flock to prevent parallel execution.
|
||||
function lock() {
|
||||
lock() {
|
||||
local lockfile=/tmp/fetch_params.lock
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if [ "$uname_S" = "Darwin" ]; then
|
||||
if shlock -f ${lockfile} -p $$; then
|
||||
return 0
|
||||
else
|
||||
|
@ -156,20 +158,20 @@ function lock() {
|
|||
fi
|
||||
else
|
||||
# create lock file
|
||||
eval "exec 200>$lockfile"
|
||||
eval "exec 9>$lockfile"
|
||||
# acquire the lock
|
||||
flock -n 200 \
|
||||
flock -n 9 \
|
||||
&& return 0 \
|
||||
|| return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function exit_locked_error {
|
||||
exit_locked_error() {
|
||||
echo "Only one instance of fetch-params.sh can be run at a time." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function main() {
|
||||
main() {
|
||||
|
||||
lock fetch-params.sh \
|
||||
|| exit_locked_error
|
||||
|
|
Loading…
Reference in New Issue