From e4b92352749fd98f3951ad572977fdc7c26fc5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Sat, 13 Feb 2016 04:44:42 +0800 Subject: [PATCH 01/14] autogen.sh: warn about needing autoconf if autoreconf is not found Changes the error message from: ./autogen.sh: 9: ./autogen.sh: autoreconf: not found To: configuration failed, please install autoconf first (cherry picked from commit bitcoin/bitcoin@889426d37e331c9e6c914dae824663a7167effdf) --- autogen.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autogen.sh b/autogen.sh index 69a20dc46..3f3810d80 100755 --- a/autogen.sh +++ b/autogen.sh @@ -13,4 +13,6 @@ if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="$(command -v glibtoolize)"; then LIBTOOLIZE="${GLIBTOOLIZE}" export LIBTOOLIZE fi +which autoreconf >/dev/null || \ + (echo "configuration failed, please install autoconf first" && exit 1) autoreconf --install --force --warnings=all From fad9fba1e150b30242c28a5b0324acd9bf87d003 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 9 Jun 2016 11:09:21 +0200 Subject: [PATCH 02/14] build: Get rid of `CLIENT_DATE` Putting the build date in the executable is a practice that has no place in these days, now that deterministic building is increasingly common. Continues #7732 which did this for the GUI. (cherry picked from commit bitcoin/bitcoin@d096d22446a1d126ea78170f37a148ce0ca43df2) --- share/genbuild.sh | 7 ------- src/clientversion.cpp | 9 --------- src/clientversion.h | 1 - src/init.cpp | 2 +- src/wallet/rpcdump.cpp | 2 +- 5 files changed, 2 insertions(+), 19 deletions(-) diff --git a/share/genbuild.sh b/share/genbuild.sh index 6d35faa97..42b5778c2 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -22,7 +22,6 @@ fi DESC="" SUFFIX="" -LAST_COMMIT_DATE="" if [ -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null @@ -36,9 +35,6 @@ if [ -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/ # otherwise generate suffix from git, i.e. string like "59887e8-dirty" SUFFIX=$(git rev-parse --short HEAD) git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty" - - # get a string like "2012-04-10 16:27:19 +0200" - LAST_COMMIT_DATE="$(git log -n 1 --format="%ci")" fi if [ -n "$DESC" ]; then @@ -52,7 +48,4 @@ fi # only update build.h if necessary if [ "$INFO" != "$NEWINFO" ]; then echo "$NEWINFO" >"$FILE" - if [ -n "$LAST_COMMIT_DATE" ]; then - echo "#define BUILD_DATE \"$LAST_COMMIT_DATE\"" >> "$FILE" - fi fi diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 36dc4b2d4..9b3750140 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -90,16 +90,7 @@ const std::string CLIENT_NAME("MagicBean"); #endif #endif -#ifndef BUILD_DATE -#ifdef GIT_COMMIT_DATE -#define BUILD_DATE GIT_COMMIT_DATE -#else -#define BUILD_DATE __DATE__ ", " __TIME__ -#endif -#endif - const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); -const std::string CLIENT_DATE(BUILD_DATE); std::string FormatVersion(int nVersion) { diff --git a/src/clientversion.h b/src/clientversion.h index 8e52e0e1a..c0af64569 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -60,7 +60,6 @@ static const int CLIENT_VERSION = extern const std::string CLIENT_NAME; extern const std::string CLIENT_BUILD; -extern const std::string CLIENT_DATE; std::string FormatVersion(int nVersion); diff --git a/src/init.cpp b/src/init.cpp index d3dc39c23..ea15d1f1d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1012,7 +1012,7 @@ void InitLogging() fLogTimestamps); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - LogPrintf("Zcash version %s (%s)\n", FormatFullVersion(), CLIENT_DATE); + LogPrintf("Zcash version %s\n", FormatFullVersion()); } [[noreturn]] static void new_handler_terminate() diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 35f4635ca..d8a7a02e5 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -620,7 +620,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fDumpZKeys) KeyIO keyIO(Params()); // produce output - file << strprintf("# Wallet dump created by Zcash %s (%s)\n", CLIENT_BUILD, CLIENT_DATE); + file << strprintf("# Wallet dump created by Zcash %s\n", CLIENT_BUILD); file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime())); file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString()); file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime())); From 0f0ff451b20f00bd93fa0c40809d53e336748530 Mon Sep 17 00:00:00 2001 From: James White Date: Sat, 14 Jan 2017 08:26:31 +0000 Subject: [PATCH 03/14] Add IPv6 support to qos.sh (cherry picked from commit bitcoin/bitcoin@fc089ae47a3773b35111b4abdcac8192aead4578) --- contrib/qos/README.md | 4 ++-- contrib/qos/tc.sh | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/contrib/qos/README.md b/contrib/qos/README.md index c8cbc0264..5e32a2a09 100644 --- a/contrib/qos/README.md +++ b/contrib/qos/README.md @@ -1,5 +1,5 @@ -### Qos ### +### QoS (Quality of service) ### -This is a Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Bitcoin network. It limits outbound TCP traffic with a source or destination port of 8233, but not if the destination IP is within a LAN (defined as 192.168.x.x). +This is a Linux bash script that will set up tc to limit the outgoing bandwidth for connections to the Bitcoin network. It limits outbound TCP traffic with a source or destination port of 8233, but not if the destination IP is within a LAN. This means one can have an always-on bitcoind instance running, and another local bitcoind/bitcoin-qt instance which connects to this node and receives blocks from it. diff --git a/contrib/qos/tc.sh b/contrib/qos/tc.sh index 2376013b5..3c502a236 100644 --- a/contrib/qos/tc.sh +++ b/contrib/qos/tc.sh @@ -11,8 +11,10 @@ IF="eth0" LINKCEIL="1gbit" #limit outbound Bitcoin protocol traffic to this rate LIMIT="160kbit" -#defines the address space for which you wish to disable rate limiting -LOCALNET="192.168.0.0/16" +#defines the IPv4 address space for which you wish to disable rate limiting +LOCALNET_V4="192.168.0.0/16" +#defines the IPv6 address space for which you wish to disable rate limiting +LOCALNET_V6="fe80::/10" #delete existing rules tc qdisc del dev ${IF} root @@ -31,6 +33,12 @@ tc class add dev ${IF} parent 1:1 classid 1:11 htb rate ${LIMIT} ceil ${LIMIT} p tc filter add dev ${IF} parent 1: protocol ip prio 1 handle 1 fw classid 1:10 tc filter add dev ${IF} parent 1: protocol ip prio 2 handle 2 fw classid 1:11 +if [ ! -z "${LOCALNET_V6}" ] ; then + # v6 cannot have the same priority value as v4 + tc filter add dev ${IF} parent 1: protocol ipv6 prio 3 handle 1 fw classid 1:10 + tc filter add dev ${IF} parent 1: protocol ipv6 prio 4 handle 2 fw classid 1:11 +fi + #delete any existing rules #disable for now #ret=0 @@ -40,9 +48,15 @@ tc filter add dev ${IF} parent 1: protocol ip prio 2 handle 2 fw classid 1:11 #done #limit outgoing traffic to and from port 8233. but not when dealing with a host on the local network -# (defined by $LOCALNET) -# --set-mark marks packages matching these criteria with the number "2" -# these packages are filtered by the tc filter with "handle 2" +# (defined by $LOCALNET_V4 and $LOCALNET_V6) +# --set-mark marks packages matching these criteria with the number "2" (v4) +# --set-mark marks packages matching these criteria with the number "4" (v6) +# these packets are filtered by the tc filter with "handle 2" # this filter sends the packages into the 1:11 class, and this class is limited to ${LIMIT} -iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 8233 ! -d ${LOCALNET} -j MARK --set-mark 0x2 -iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 8233 ! -d ${LOCALNET} -j MARK --set-mark 0x2 +iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 8233 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 +iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 8233 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 + +if [ ! -z "${LOCALNET_V6}" ] ; then + ip6tables -t mangle -A OUTPUT -p tcp -m tcp --dport 8233 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 + ip6tables -t mangle -A OUTPUT -p tcp -m tcp --sport 8233 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 +fi From 8dbd2edd9855e0a95e481f3615d9549195c937ad Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 12 Feb 2016 05:36:55 +0000 Subject: [PATCH 04/14] Bugfix: Only use git for build info if the repository is actually the right one Also adds ability to disable check with BITCOIN_GENBUILD_NO_GIT=1 in the environment (cherry picked from commit bitcoin/bitcoin@e98e3dde6a976a2c8f266ee963d6931fd4b37262) --- contrib/gitian-descriptors/gitian-linux.yml | 1 + contrib/gitian-descriptors/gitian-osx.yml | 1 + contrib/gitian-descriptors/gitian-win.yml | 1 + share/genbuild.sh | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index fc7de7de5..98d136cd0 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -97,6 +97,7 @@ script: | create_per-host_faketime_wrappers "${REFERENCE_DATETIME}" # Create the release tarball using (arbitrarily) the first host + export GIT_DIR="$PWD/.git" ./autogen.sh CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/ make dist diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 65533d060..93ecfb14c 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -92,6 +92,7 @@ script: | create_per-host_faketime_wrappers "${REFERENCE_DATETIME}" # Create the release tarball using (arbitrarily) the first host + export GIT_DIR="$PWD/.git" ./autogen.sh CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/ make dist diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index cab6187fa..780a83f3b 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -113,6 +113,7 @@ script: | create_per-host_linker_wrapper "${REFERENCE_DATETIME}" # Create the release tarball using (arbitrarily) the first host + export GIT_DIR="$PWD/.git" ./autogen.sh CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/ make dist diff --git a/share/genbuild.sh b/share/genbuild.sh index 42b5778c2..3df4bcf03 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -22,7 +22,7 @@ fi DESC="" SUFFIX="" -if [ -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" -a "$(git status --porcelain -u no --ignored "$0" | cut -b1)" != "?" ]; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null From 7fa4df7e7a7c74af5b42ca96aaa88eafb9d1846b Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 29 Dec 2016 15:24:38 +0000 Subject: [PATCH 05/14] Bugfix: Detect genbuild.sh in repo correctly (cherry picked from commit bitcoin/bitcoin@ed1fcdcac0b9388b4e50f5e4ca2d5cd963f1ef27) --- share/genbuild.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/genbuild.sh b/share/genbuild.sh index 3df4bcf03..7a3eb4d1a 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -20,9 +20,13 @@ else exit 1 fi +git_check_in_repo() { + ! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?' +} + DESC="" SUFFIX="" -if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" -a "$(git status --porcelain -u no --ignored "$0" | cut -b1)" != "?" ]; then +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null From 606358aae00cd703c5b7a256d5381219ea2f9448 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 29 Apr 2018 18:37:47 -0400 Subject: [PATCH 06/14] Remove script to clean up datadirs This reverts commit 33c055c4f1eca07bd914a5b40a21f92ad82dde9f. (bitcoin/bitcoin#2295) (cherry picked from commit bitcoin/bitcoin@fa85de9ff5cfa85a76026b1b6138ba1d7b54864a) --- contrib/tidy_datadir.sh | 62 ----------------------------------------- 1 file changed, 62 deletions(-) delete mode 100755 contrib/tidy_datadir.sh diff --git a/contrib/tidy_datadir.sh b/contrib/tidy_datadir.sh deleted file mode 100755 index 7861e6e6e..000000000 --- a/contrib/tidy_datadir.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# Copyright (c) 2013 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or https://www.opensource.org/licenses/mit-license.php . - -if [ -d "$1" ]; then - cd "$1" || exit 1 -else - echo "Usage: $0 " >&2 - echo "Removes obsolete Bitcoin database files" >&2 - exit 1 -fi - -LEVEL=0 -if [ -f wallet.dat -a -f addr.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=1; fi -if [ -f wallet.dat -a -f peers.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=2; fi -if [ -f wallet.dat -a -f peers.dat -a -f coins/CURRENT -a -f blktree/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=3; fi -if [ -f wallet.dat -a -f peers.dat -a -f chainstate/CURRENT -a -f blocks/index/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=4; fi - -case $LEVEL in - 0) - echo "Error: no Bitcoin datadir detected." - exit 1 - ;; - 1) - echo "Detected old Bitcoin datadir (before 0.7)." - echo "Nothing to do." - exit 0 - ;; - 2) - echo "Detected Bitcoin 0.7 datadir." - ;; - 3) - echo "Detected Bitcoin pre-0.8 datadir." - ;; - 4) - echo "Detected Bitcoin 0.8 datadir." - ;; -esac - -FILES="" -DIRS="" - -if [ $LEVEL -ge 3 ]; then FILES=$(echo $FILES blk????.dat blkindex.dat); fi -if [ $LEVEL -ge 2 ]; then FILES=$(echo $FILES addr.dat); fi -if [ $LEVEL -ge 4 ]; then DIRS=$(echo $DIRS coins blktree); fi - -for FILE in $FILES; do - if [ -f $FILE ]; then - echo "Deleting: $FILE" - rm -f $FILE - fi -done - -for DIR in $DIRS; do - if [ -d $DIR ]; then - echo "Deleting: $DIR/" - rm -rf $DIR - fi -done - -echo "Done." From 8294e516819d93961bdf83a04ea9f77bca79672f Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 2 Jul 2019 19:48:08 +0300 Subject: [PATCH 07/14] Enable ShellCheck rules Enabled ShellCheck rules: SC1087 SC2001 SC2004 SC2005 SC2006 SC2016 SC2028 SC2048 SC2066 (note that IFS already contains only a line feed) SC2116 SC2166 SC2181 SC2206 SC2207 SC2230 SC2236 (cherry picked from commit bitcoin/bitcoin@1ac454a3844b9b8389de0f660fa9455c0efa7140) Zcash: Applies more of this commit. It was partially backported in zcash/zcash#4827, and is also partially backported here for the scripts we actually have. --- autogen.sh | 2 +- contrib/qos/tc.sh | 4 ++-- share/genbuild.sh | 2 +- test/lint/lint-shell.sh | 16 ---------------- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/autogen.sh b/autogen.sh index 3f3810d80..5b2b84a09 100755 --- a/autogen.sh +++ b/autogen.sh @@ -13,6 +13,6 @@ if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="$(command -v glibtoolize)"; then LIBTOOLIZE="${GLIBTOOLIZE}" export LIBTOOLIZE fi -which autoreconf >/dev/null || \ +command -v autoreconf >/dev/null || \ (echo "configuration failed, please install autoconf first" && exit 1) autoreconf --install --force --warnings=all diff --git a/contrib/qos/tc.sh b/contrib/qos/tc.sh index 3c502a236..1de8473e6 100644 --- a/contrib/qos/tc.sh +++ b/contrib/qos/tc.sh @@ -33,7 +33,7 @@ tc class add dev ${IF} parent 1:1 classid 1:11 htb rate ${LIMIT} ceil ${LIMIT} p tc filter add dev ${IF} parent 1: protocol ip prio 1 handle 1 fw classid 1:10 tc filter add dev ${IF} parent 1: protocol ip prio 2 handle 2 fw classid 1:11 -if [ ! -z "${LOCALNET_V6}" ] ; then +if [ -n "${LOCALNET_V6}" ] ; then # v6 cannot have the same priority value as v4 tc filter add dev ${IF} parent 1: protocol ipv6 prio 3 handle 1 fw classid 1:10 tc filter add dev ${IF} parent 1: protocol ipv6 prio 4 handle 2 fw classid 1:11 @@ -56,7 +56,7 @@ fi iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 8233 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 8233 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 -if [ ! -z "${LOCALNET_V6}" ] ; then +if [ -n "${LOCALNET_V6}" ] ; then ip6tables -t mangle -A OUTPUT -p tcp -m tcp --dport 8233 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 ip6tables -t mangle -A OUTPUT -p tcp -m tcp --sport 8233 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 fi diff --git a/share/genbuild.sh b/share/genbuild.sh index 7a3eb4d1a..d8651030e 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -26,7 +26,7 @@ git_check_in_repo() { DESC="" SUFFIX="" -if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 7fe9aebba..a089e6517 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -24,25 +24,9 @@ fi # Disabled warnings: disabled=( - SC1087 # Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet). - SC2001 # See if you can use ${variable//search/replace} instead. - SC2004 # $/${} is unnecessary on arithmetic variables. - SC2005 # Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. - 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. 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. SC2086 # Double quote to prevent globbing and word splitting. - SC2116 # Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'. SC2162 # read without -r will mangle backslashes. - SC2166 # Prefer [ p ] {&&,||} [ q ] as [ p -{a,o} q ] is not well defined. - SC2181 # Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. - SC2206 # Quote to prevent word splitting, or split robustly with mapfile or read -a. - SC2207 # Prefer mapfile or read -a to split command output (or quote to avoid splitting). - SC2230 # which is non-standard. Use builtin 'command -v' instead. - SC2236 # Don't force -n instead of ! -z. ) shellcheck -e "$(IFS=","; echo "${disabled[*]}")" \ $(git ls-files -- "*.sh") From 3dd142d6058e81c6414a5a40df39786332b7430e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 20 Aug 2022 01:10:34 +0000 Subject: [PATCH 08/14] lint: Fix ShellCheck lints in Zcash scripts --- contrib/docker/entrypoint.sh | 2 +- test/lint/lint-cargo-patches.sh | 2 ++ zcutil/afl/afl-build.sh | 2 +- zcutil/afl/afl-get.sh | 5 ++--- zcutil/build-debian-package.sh | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/contrib/docker/entrypoint.sh b/contrib/docker/entrypoint.sh index 1c9f2adfc..bb1d3a7f6 100755 --- a/contrib/docker/entrypoint.sh +++ b/contrib/docker/entrypoint.sh @@ -11,7 +11,7 @@ fi env | sort | grep ZCASHD || true export ZCASHD_CMD='zcashd -printtoconsole' -if [[ ! -n ${ZCASHD_NETWORK} ]];then +if [[ -z ${ZCASHD_NETWORK} ]];then export ZCASHD_NETWORK=mainnet fi diff --git a/test/lint/lint-cargo-patches.sh b/test/lint/lint-cargo-patches.sh index eef5798ba..6e3252c0d 100755 --- a/test/lint/lint-cargo-patches.sh +++ b/test/lint/lint-cargo-patches.sh @@ -29,7 +29,9 @@ EXIT_CODE=0 # Check that every patch has a matching replacement. for PATCH in $(tail -n+$CARGO_TOML_PATCH_START $CARGO_TOML | sed 's/.*git = "\([^"]*\)", rev = "\([^"]*\)".*/\1#\2/' | sort | uniq) do + # shellcheck disable=SC2001 PATCH_GIT=$(echo $PATCH | sed 's/#.*//') + # shellcheck disable=SC2001 PATCH_REV=$(echo $PATCH | sed 's/.*#//') # Canonicalize the git URL (matching how Cargo treats them, so we don't over-lint). diff --git a/zcutil/afl/afl-build.sh b/zcutil/afl/afl-build.sh index 7562518c5..b1f2fcffe 100755 --- a/zcutil/afl/afl-build.sh +++ b/zcutil/afl/afl-build.sh @@ -11,7 +11,7 @@ export AFL_LOG_DIR for d in src/fuzzing/*/ ; do fuzz_cases+="$(basename "$d"), " - fuzz_cases_choices=("${fuzz_cases_choices[@]}" $(basename "$d")) + fuzz_cases_choices=("${fuzz_cases_choices[@]}" "$(basename "$d")") done FUZZ_OPTIONS_STRING="Options are: ${fuzz_cases::-2}" diff --git a/zcutil/afl/afl-get.sh b/zcutil/afl/afl-get.sh index 93740b66a..04e8e01b6 100755 --- a/zcutil/afl/afl-get.sh +++ b/zcutil/afl/afl-get.sh @@ -55,7 +55,7 @@ fi mkdir -p "$AFL_INSTALL_DIR" cd "$AFL_INSTALL_DIR" -if [ ! -z "$(ls -A .)" ]; then +if [ -n "$(ls -A .)" ]; then echo "$1 is not empty. This script will only attempt to build AFL in an empty directory." exit 1 fi @@ -63,8 +63,7 @@ fi # Get the AFL source rm -f afl-latest.tgz wget https://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz -sha256sum afl-latest.tgz | grep '43614b4b91c014d39ef086c5cc84ff5f068010c264c2c05bf199df60898ce045' -if [ "$?" != "0" ] +if ! sha256sum afl-latest.tgz | grep '43614b4b91c014d39ef086c5cc84ff5f068010c264c2c05bf199df60898ce045'; then echo "Wrong SHA256 hash for afl" exit diff --git a/zcutil/build-debian-package.sh b/zcutil/build-debian-package.sh index 6fadf85f9..5c231cfc4 100755 --- a/zcutil/build-debian-package.sh +++ b/zcutil/build-debian-package.sh @@ -8,7 +8,7 @@ set -x BUILD_PATH="/tmp/zcbuild" PACKAGE_NAME="zcash" -SRC_PATH=`pwd` +SRC_PATH=$(pwd) SRC_DEB=$SRC_PATH/contrib/debian SRC_DOC=$SRC_PATH/doc From 3cf26a1c4f096b998fc52e9687dbd46493113fd0 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 3 Nov 2019 20:55:06 +0200 Subject: [PATCH 09/14] script: Lint Gitian descriptors with ShellCheck (cherry picked from commit bitcoin/bitcoin@14aded46df289e2d05f9fd79c81f2e8ed68a1487) Zcash: Applies CI change to GitHub Actions workflow. --- .github/workflows/lints.yml | 2 ++ test/lint/lint-shell.sh | 48 ++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml index ecb4bb5ee..3cecedb12 100644 --- a/.github/workflows/lints.yml +++ b/.github/workflows/lints.yml @@ -20,6 +20,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo python3 -m pip install yq - name: Cargo patches run: ./test/lint/lint-cargo-patches.sh diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index a089e6517..5af031045 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (c) 2018 The Bitcoin Core developers +# Copyright (c) 2018-2019 The Bitcoin Core developers # Copyright (c) 2020-2022 The Zcash developers # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php . @@ -17,16 +17,48 @@ if [ "$TRAVIS" = "true" ]; then unset LC_ALL fi -if ! command -v shellcheck > /dev/null; then - echo "Skipping shell linting since shellcheck is not installed." - exit 0 -fi - # Disabled warnings: disabled=( SC2046 # Quote this to prevent word splitting. SC2086 # Double quote to prevent globbing and word splitting. SC2162 # read without -r will mangle backslashes. ) -shellcheck -e "$(IFS=","; echo "${disabled[*]}")" \ - $(git ls-files -- "*.sh") +disabled_gitian=( + SC2001 # See if you can use ${variable//search/replace} instead. + SC2006 # Use $(...) notation instead of legacy backticked `...`. + SC2094 # Make sure not to read and write the same file in the same pipeline. + SC2129 # Consider using { cmd1; cmd2; } >> file instead of individual redirects. + SC2155 # Declare and assign separately to avoid masking return values. + SC2230 # which is non-standard. Use builtin 'command -v' instead. +) + +EXIT_CODE=0 + +if ! command -v shellcheck > /dev/null; then + echo "Skipping shell linting since shellcheck is not installed." + exit $EXIT_CODE +fi + +EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")" +if ! shellcheck "$EXCLUDE" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|univalue)/'); then + EXIT_CODE=1 +fi + +if ! command -v yq > /dev/null; then + echo "Skipping Gitian desriptor scripts checking since yq is not installed." + exit $EXIT_CODE +fi + +EXCLUDE_GITIAN=${EXCLUDE}",$(IFS=','; echo "${disabled_gitian[*]}")" +for descriptor in $(git ls-files -- 'contrib/gitian-descriptors/*.yml') +do + echo + echo "$descriptor" + # Use #!/bin/bash as gitian-builder/bin/gbuild does to complete a script. + SCRIPT=$'#!/bin/bash\n'$(yq -r .script "$descriptor") + if ! echo "$SCRIPT" | shellcheck "$EXCLUDE_GITIAN" -; then + EXIT_CODE=1 + fi +done + +exit $EXIT_CODE From 0f8449955607da1aa636f8d3e56cde808a48bd25 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 20 Aug 2022 01:37:27 +0000 Subject: [PATCH 10/14] lint: Disable some ShellChecks on Gitian descriptors These trigger because our Gitian descriptors are out-of-sync with upstream. --- test/lint/lint-shell.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 5af031045..5f5493432 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -26,9 +26,12 @@ disabled=( disabled_gitian=( SC2001 # See if you can use ${variable//search/replace} instead. SC2006 # Use $(...) notation instead of legacy backticked `...`. + SC2035 # Use ./*glob* or -- *glob* so names with dashes won't become options. + SC2043 # This loop will only ever run once for a constant value. Did you perhaps mean to loop over dir/*, $var or $(cmd)? SC2094 # Make sure not to read and write the same file in the same pipeline. SC2129 # Consider using { cmd1; cmd2; } >> file instead of individual redirects. SC2155 # Declare and assign separately to avoid masking return values. + SC2164 # Use 'cd ... || exit' or 'cd ... || return' in case cd fails. SC2230 # which is non-standard. Use builtin 'command -v' instead. ) From fa3abe8819cd58392cc2b65344ae978fcdeb0385 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 3 Nov 2019 21:39:19 +0200 Subject: [PATCH 11/14] script: Enable SC2006 rule for Gitian scripts (cherry picked from commit bitcoin/bitcoin@577682d9e8cc07a8db9459a47b01f6c18decba7c) --- contrib/gitian-descriptors/gitian-linux.yml | 12 ++++++------ contrib/gitian-descriptors/gitian-osx-signer.yml | 2 +- contrib/gitian-descriptors/gitian-osx.yml | 12 ++++++------ contrib/gitian-descriptors/gitian-win-signer.yml | 6 +++--- contrib/gitian-descriptors/gitian-win.yml | 13 ++++++------- test/lint/lint-shell.sh | 1 - 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index 98d136cd0..fc323fede 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -47,7 +47,7 @@ script: | export GZIP="-9n" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TZ="UTC" - export BUILD_DIR=`pwd` + export BUILD_DIR=$(pwd) mkdir -p ${WRAP_DIR} if test -n "$GBUILD_CACHE_ENABLED"; then export SOURCES_PATH=${GBUILD_COMMON_CACHE} @@ -86,7 +86,7 @@ script: | create_per-host_faketime_wrappers "2000-01-01 12:00:00" cd zcash - BASEPREFIX=`pwd`/depends + BASEPREFIX=$(pwd)/depends # Build dependencies for each host for i in $HOSTS; do make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" @@ -99,10 +99,10 @@ script: | # Create the release tarball using (arbitrarily) the first host export GIT_DIR="$PWD/.git" ./autogen.sh - CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/ + CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ make dist - SOURCEDIST=`echo zcash-*.tar.gz` - DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` + SOURCEDIST=$(echo zcash-*.tar.gz) + DISTNAME=$(echo ${SOURCEDIST} | sed 's/.tar.*//') # Correct tar file order mkdir -p temp pushd temp @@ -116,7 +116,7 @@ script: | export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} - INSTALLPATH=`pwd`/installed/${DISTNAME} + INSTALLPATH=$(pwd)/installed/${DISTNAME} mkdir -p ${INSTALLPATH} tar --strip-components=1 -xf ../$SOURCEDIST diff --git a/contrib/gitian-descriptors/gitian-osx-signer.yml b/contrib/gitian-descriptors/gitian-osx-signer.yml index 73a2f12f3..fb5a056c5 100644 --- a/contrib/gitian-descriptors/gitian-osx-signer.yml +++ b/contrib/gitian-descriptors/gitian-osx-signer.yml @@ -15,7 +15,7 @@ files: script: | WRAP_DIR=$HOME/wrapped mkdir -p ${WRAP_DIR} - export PATH=`pwd`:$PATH + export PATH=$(pwd):$PATH FAKETIME_PROGS="dmg genisoimage" # Create global faketime wrappers diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 93ecfb14c..55d6dc187 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -36,7 +36,7 @@ script: | export GZIP="-9n" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TZ="UTC" - export BUILD_DIR=`pwd` + export BUILD_DIR=$(pwd) mkdir -p ${WRAP_DIR} if test -n "$GBUILD_CACHE_ENABLED"; then export SOURCES_PATH=${GBUILD_COMMON_CACHE} @@ -77,7 +77,7 @@ script: | create_per-host_faketime_wrappers "2000-01-01 12:00:00" cd bitcoin - BASEPREFIX=`pwd`/depends + BASEPREFIX=$(pwd)/depends mkdir -p ${BASEPREFIX}/SDKs tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz @@ -94,10 +94,10 @@ script: | # Create the release tarball using (arbitrarily) the first host export GIT_DIR="$PWD/.git" ./autogen.sh - CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/ + CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ make dist - SOURCEDIST=`echo bitcoin-*.tar.gz` - DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` + SOURCEDIST=$(echo bitcoin-*.tar.gz) + DISTNAME=$(echo ${SOURCEDIST} | sed 's/.tar.*//') # Correct tar file order mkdir -p temp @@ -112,7 +112,7 @@ script: | export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} - INSTALLPATH=`pwd`/installed/${DISTNAME} + INSTALLPATH=$(pwd)/installed/${DISTNAME} mkdir -p ${INSTALLPATH} tar --strip-components=1 -xf ../$SOURCEDIST diff --git a/contrib/gitian-descriptors/gitian-win-signer.yml b/contrib/gitian-descriptors/gitian-win-signer.yml index 6b53b89b6..d874a6b16 100644 --- a/contrib/gitian-descriptors/gitian-win-signer.yml +++ b/contrib/gitian-descriptors/gitian-win-signer.yml @@ -15,7 +15,7 @@ files: - "osslsigncode-Backports-to-1.7.1.patch" - "bitcoin-win-unsigned.tar.gz" script: | - BUILD_DIR=`pwd` + BUILD_DIR=$(pwd) SIGDIR=${BUILD_DIR}/signature/win UNSIGNED_DIR=${BUILD_DIR}/unsigned @@ -32,7 +32,7 @@ script: | ./configure --without-gsf --without-curl --disable-dependency-tracking make find ${UNSIGNED_DIR} -name "*-unsigned.exe" | while read i; do - INFILE="`basename "${i}"`" - OUTFILE="`echo "${INFILE}" | sed s/-unsigned//`" + INFILE="$(basename "${i}")" + OUTFILE="$(echo "${INFILE}" | sed s/-unsigned//)" ./osslsigncode attach-signature -in "${i}" -out "${OUTDIR}/${OUTFILE}" -sigin "${SIGDIR}/${INFILE}.pem" done diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index 780a83f3b..acc338ade 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -37,7 +37,7 @@ script: | export GZIP="-9n" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TZ="UTC" - export BUILD_DIR=`pwd` + export BUILD_DIR=$(pwd) mkdir -p ${WRAP_DIR} if test -n "$GBUILD_CACHE_ENABLED"; then export SOURCES_PATH=${GBUILD_COMMON_CACHE} @@ -101,7 +101,7 @@ script: | create_per-host_linker_wrapper "2000-01-01 12:00:00" cd bitcoin - BASEPREFIX=`pwd`/depends + BASEPREFIX=$(pwd)/depends # Build dependencies for each host for i in $HOSTS; do make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" @@ -115,11 +115,10 @@ script: | # Create the release tarball using (arbitrarily) the first host export GIT_DIR="$PWD/.git" ./autogen.sh - CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/ + CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ make dist - SOURCEDIST=`echo bitcoin-*.tar.gz` - DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` - + SOURCEDIST=$(echo bitcoin-*.tar.gz) + DISTNAME=$(echo ${SOURCEDIST} | sed 's/.tar.*//') # Correct tar file order mkdir -p temp pushd temp @@ -135,7 +134,7 @@ script: | export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} - INSTALLPATH=`pwd`/installed/${DISTNAME} + INSTALLPATH=$(pwd)/installed/${DISTNAME} mkdir -p ${INSTALLPATH} tar --strip-components=1 -xf ../$SOURCEDIST diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 5f5493432..6206b4215 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -25,7 +25,6 @@ disabled=( ) disabled_gitian=( SC2001 # See if you can use ${variable//search/replace} instead. - SC2006 # Use $(...) notation instead of legacy backticked `...`. SC2035 # Use ./*glob* or -- *glob* so names with dashes won't become options. SC2043 # This loop will only ever run once for a constant value. Did you perhaps mean to loop over dir/*, $var or $(cmd)? SC2094 # Make sure not to read and write the same file in the same pipeline. From f620206f036a10210d1aaf6e3884a34b9aa83c34 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 3 Nov 2019 21:57:11 +0200 Subject: [PATCH 12/14] script: Enable SC2155 rule for Gitian scripts Also pwd command is replaced with $PWD variable everywhere for consistency. (cherry picked from commit bitcoin/bitcoin@61bb21b4181c06b5956b5d6f2f7831e56e4f1cf6) --- contrib/gitian-descriptors/gitian-linux.yml | 6 +++--- contrib/gitian-descriptors/gitian-osx-signer.yml | 2 +- contrib/gitian-descriptors/gitian-osx.yml | 6 +++--- contrib/gitian-descriptors/gitian-win-signer.yml | 2 +- contrib/gitian-descriptors/gitian-win.yml | 6 +++--- test/lint/lint-shell.sh | 1 - 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index fc323fede..c70900a8e 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -47,7 +47,7 @@ script: | export GZIP="-9n" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TZ="UTC" - export BUILD_DIR=$(pwd) + export BUILD_DIR="$PWD" mkdir -p ${WRAP_DIR} if test -n "$GBUILD_CACHE_ENABLED"; then export SOURCES_PATH=${GBUILD_COMMON_CACHE} @@ -86,7 +86,7 @@ script: | create_per-host_faketime_wrappers "2000-01-01 12:00:00" cd zcash - BASEPREFIX=$(pwd)/depends + BASEPREFIX="${PWD}/depends" # Build dependencies for each host for i in $HOSTS; do make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" @@ -116,7 +116,7 @@ script: | export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} - INSTALLPATH=$(pwd)/installed/${DISTNAME} + INSTALLPATH="${PWD}/installed/${DISTNAME}" mkdir -p ${INSTALLPATH} tar --strip-components=1 -xf ../$SOURCEDIST diff --git a/contrib/gitian-descriptors/gitian-osx-signer.yml b/contrib/gitian-descriptors/gitian-osx-signer.yml index fb5a056c5..4c2a2dd83 100644 --- a/contrib/gitian-descriptors/gitian-osx-signer.yml +++ b/contrib/gitian-descriptors/gitian-osx-signer.yml @@ -15,7 +15,7 @@ files: script: | WRAP_DIR=$HOME/wrapped mkdir -p ${WRAP_DIR} - export PATH=$(pwd):$PATH + export PATH="$PWD":$PATH FAKETIME_PROGS="dmg genisoimage" # Create global faketime wrappers diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 55d6dc187..8b7f37baa 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -36,7 +36,7 @@ script: | export GZIP="-9n" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TZ="UTC" - export BUILD_DIR=$(pwd) + export BUILD_DIR="$PWD" mkdir -p ${WRAP_DIR} if test -n "$GBUILD_CACHE_ENABLED"; then export SOURCES_PATH=${GBUILD_COMMON_CACHE} @@ -77,7 +77,7 @@ script: | create_per-host_faketime_wrappers "2000-01-01 12:00:00" cd bitcoin - BASEPREFIX=$(pwd)/depends + BASEPREFIX="${PWD}/depends" mkdir -p ${BASEPREFIX}/SDKs tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz @@ -112,7 +112,7 @@ script: | export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} - INSTALLPATH=$(pwd)/installed/${DISTNAME} + INSTALLPATH="${PWD}/installed/${DISTNAME}" mkdir -p ${INSTALLPATH} tar --strip-components=1 -xf ../$SOURCEDIST diff --git a/contrib/gitian-descriptors/gitian-win-signer.yml b/contrib/gitian-descriptors/gitian-win-signer.yml index d874a6b16..4cad8e306 100644 --- a/contrib/gitian-descriptors/gitian-win-signer.yml +++ b/contrib/gitian-descriptors/gitian-win-signer.yml @@ -15,7 +15,7 @@ files: - "osslsigncode-Backports-to-1.7.1.patch" - "bitcoin-win-unsigned.tar.gz" script: | - BUILD_DIR=$(pwd) + BUILD_DIR="$PWD" SIGDIR=${BUILD_DIR}/signature/win UNSIGNED_DIR=${BUILD_DIR}/unsigned diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index acc338ade..bf79abc16 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -37,7 +37,7 @@ script: | export GZIP="-9n" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TZ="UTC" - export BUILD_DIR=$(pwd) + export BUILD_DIR="$PWD" mkdir -p ${WRAP_DIR} if test -n "$GBUILD_CACHE_ENABLED"; then export SOURCES_PATH=${GBUILD_COMMON_CACHE} @@ -101,7 +101,7 @@ script: | create_per-host_linker_wrapper "2000-01-01 12:00:00" cd bitcoin - BASEPREFIX=$(pwd)/depends + BASEPREFIX="${PWD}/depends" # Build dependencies for each host for i in $HOSTS; do make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" @@ -134,7 +134,7 @@ script: | export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} - INSTALLPATH=$(pwd)/installed/${DISTNAME} + INSTALLPATH="${PWD}/installed/${DISTNAME}" mkdir -p ${INSTALLPATH} tar --strip-components=1 -xf ../$SOURCEDIST diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 6206b4215..5b3f61d63 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -29,7 +29,6 @@ disabled_gitian=( SC2043 # This loop will only ever run once for a constant value. Did you perhaps mean to loop over dir/*, $var or $(cmd)? SC2094 # Make sure not to read and write the same file in the same pipeline. SC2129 # Consider using { cmd1; cmd2; } >> file instead of individual redirects. - SC2155 # Declare and assign separately to avoid masking return values. SC2164 # Use 'cd ... || exit' or 'cd ... || return' in case cd fails. SC2230 # which is non-standard. Use builtin 'command -v' instead. ) From c23889a1506744a51b00c66572cfa2875b392dd5 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 3 Nov 2019 22:32:50 +0200 Subject: [PATCH 13/14] script: Enable SC2001 rule for Gitian scripts (cherry picked from commit bitcoin/bitcoin@17f81e96486780df5d464487975ecb11b278ec8d) --- contrib/gitian-descriptors/gitian-linux.yml | 3 ++- contrib/gitian-descriptors/gitian-osx.yml | 2 +- contrib/gitian-descriptors/gitian-win-signer.yml | 2 +- contrib/gitian-descriptors/gitian-win.yml | 3 ++- test/lint/lint-shell.sh | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index c70900a8e..3e5b385f4 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -102,7 +102,8 @@ script: | CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ make dist SOURCEDIST=$(echo zcash-*.tar.gz) - DISTNAME=$(echo ${SOURCEDIST} | sed 's/.tar.*//') + DISTNAME=${SOURCEDIST/%.tar.gz} + # Correct tar file order mkdir -p temp pushd temp diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 8b7f37baa..cb0a968c9 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -97,7 +97,7 @@ script: | CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ make dist SOURCEDIST=$(echo bitcoin-*.tar.gz) - DISTNAME=$(echo ${SOURCEDIST} | sed 's/.tar.*//') + DISTNAME=${SOURCEDIST/%.tar.gz} # Correct tar file order mkdir -p temp diff --git a/contrib/gitian-descriptors/gitian-win-signer.yml b/contrib/gitian-descriptors/gitian-win-signer.yml index 4cad8e306..3f2c540ae 100644 --- a/contrib/gitian-descriptors/gitian-win-signer.yml +++ b/contrib/gitian-descriptors/gitian-win-signer.yml @@ -33,6 +33,6 @@ script: | make find ${UNSIGNED_DIR} -name "*-unsigned.exe" | while read i; do INFILE="$(basename "${i}")" - OUTFILE="$(echo "${INFILE}" | sed s/-unsigned//)" + OUTFILE="${INFILE/%-unsigned}" ./osslsigncode attach-signature -in "${i}" -out "${OUTDIR}/${OUTFILE}" -sigin "${SIGDIR}/${INFILE}.pem" done diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index bf79abc16..9ae0f21fb 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -118,7 +118,8 @@ script: | CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ make dist SOURCEDIST=$(echo bitcoin-*.tar.gz) - DISTNAME=$(echo ${SOURCEDIST} | sed 's/.tar.*//') + DISTNAME=${SOURCEDIST/%.tar.gz} + # Correct tar file order mkdir -p temp pushd temp diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 5b3f61d63..0c45d2413 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -24,7 +24,6 @@ disabled=( SC2162 # read without -r will mangle backslashes. ) disabled_gitian=( - SC2001 # See if you can use ${variable//search/replace} instead. SC2035 # Use ./*glob* or -- *glob* so names with dashes won't become options. SC2043 # This loop will only ever run once for a constant value. Did you perhaps mean to loop over dir/*, $var or $(cmd)? SC2094 # Make sure not to read and write the same file in the same pipeline. From dd84f66600745a87b4e9377139903d43202a9360 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Mon, 2 Mar 2020 22:58:57 -0800 Subject: [PATCH 14/14] doc: Correct spelling errors in comments And ci script output. Identified via test/lint/lint-spelling (cherry picked from commit bitcoin/bitcoin@9b0e16226e6c1fb6a3550d635339f1bbb49a852f) Zcash: Only the change to `test/lint/lint-shell.sh` --- test/lint/lint-shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 0c45d2413..ba0c906de 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -45,7 +45,7 @@ if ! shellcheck "$EXCLUDE" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|sec fi if ! command -v yq > /dev/null; then - echo "Skipping Gitian desriptor scripts checking since yq is not installed." + echo "Skipping Gitian descriptor scripts checking since yq is not installed." exit $EXIT_CODE fi