Skip to content

Commit

Permalink
[CI] Enable shellcheck linting
Browse files Browse the repository at this point in the history
Adds a linter script to check shell script files for known errors using
the shellcheck program. Also checks the shell scripts in the gitian
descriptors using the yq program.
  • Loading branch information
Fuzzbawls committed Oct 11, 2021
1 parent f70c72d commit fa302a9
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 116 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]
jobs:
lint:
env:
SHELLCHECK_VERSION: v0.6.0
SHELLCHECK_VERSION: v0.7.1
LC_ALL: C
runs-on: ubuntu-18.04
defaults:
Expand All @@ -27,17 +27,19 @@ jobs:
pip install codespell==1.13.0
pip install flake8==3.8.3
pip install vulture==0.29
pip install yq
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/
export PATH="/tmp/shellcheck-${SHELLCHECK_VERSION}:${PATH}"
echo $PATH
- name: Set TRAVIS_BRANCH workaround env variable
if: github.event_name == 'pull_request'
run: echo "TRAVIS_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV

- name: Lint
run: |
export PATH="/tmp/shellcheck-${SHELLCHECK_VERSION}:${PATH}"
echo $PATH
git checkout -qf -B master refs/remotes/origin/master
git checkout -qf $GITHUB_SHA
test/lint/git-subtree-check.sh src/secp256k1
Expand Down
4 changes: 2 additions & 2 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export LC_ALL=C
set -e
srcdir="$(dirname $0)"
cd "$srcdir"
if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then
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
2 changes: 1 addition & 1 deletion contrib/devtools/gen-manpages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BITCOINQT=${BITCOINQT:-$BINDIR/qt/pivx-qt}
[ ! -x $BITCOIND ] && echo "$BITCOIND not found or not executable." && exit 1

# The autodetected version git tag can screw up manpage output a little bit
BTCVER=($($BITCOINCLI --version | head -n1 | awk -F'[ -]' '{ print $6, $7 }'))
read -r -a BTCVER <<< "$($BITCOINCLI --version | head -n1 | awk -F'[ -]' '{ print $6, $7 }')"

# Create a footer file with copyright content.
# This gets autodetected fine for bitcoind if --version-string is not set,
Expand Down
14 changes: 7 additions & 7 deletions contrib/gitian-descriptors/gitian-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ script: |
export QT_RCC_TEST=1
export QT_RCC_SOURCE_DATE_OVERRIDE=1
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}
Expand Down Expand Up @@ -107,7 +107,7 @@ script: |
rm -f ${WRAP_DIR}/${prog}
cat << EOF > ${WRAP_DIR}/${prog}
#!/usr/bin/env bash
REAL="`which -a ${prog}-8 | grep -v ${WRAP_DIR}/${prog} | head -1`"
REAL="$(which -a ${prog}-8 | grep -v ${WRAP_DIR}/${prog} | head -1)"
for var in "\$@"
do
if [ "\$var" = "-m32" ]; then
Expand All @@ -122,7 +122,7 @@ script: |
done
cd pivx
BASEPREFIX=`pwd`/depends
BASEPREFIX="${PWD}/depends"
# Build dependencies for each host
for i in $HOSTS; do
EXTRA_INCLUDES="$EXTRA_INCLUDES_BASE/$i"
Expand All @@ -142,10 +142,10 @@ script: |
# Create the release tarball using (arbitrarily) the first host
git update-index --assume-unchanged src/chiabls/contrib/relic/include/relic_conf.h.in
./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 pivx-*.tar.gz`
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'`
SOURCEDIST=$(echo pivx-*.tar.gz)
DISTNAME=${SOURCEDIST/%.tar.gz}
# Correct tar file order
mkdir -p temp
pushd temp
Expand All @@ -162,7 +162,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
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-osx-signer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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
Expand Down
12 changes: 6 additions & 6 deletions contrib/gitian-descriptors/gitian-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ script: |
export QT_RCC_TEST=1
export QT_RCC_SOURCE_DATE_OVERRIDE=1
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}
Expand Down Expand Up @@ -86,7 +86,7 @@ script: |
export PATH=${WRAP_DIR}:${PATH}
cd pivx
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
Expand All @@ -105,10 +105,10 @@ script: |
# Create the release tarball using (arbitrarily) the first host
git update-index --assume-unchanged src/chiabls/contrib/relic/include/relic_conf.h.in
./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 pivx-*.tar.gz`
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'`
SOURCEDIST=$(echo pivx-*.tar.gz)
DISTNAME=${SOURCEDIST/%.tar.gz}
# Correct tar file order
mkdir -p temp
Expand All @@ -126,7 +126,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
Expand Down
6 changes: 3 additions & 3 deletions contrib/gitian-descriptors/gitian-win-signer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ files:
script: |
set -e -o pipefail
BUILD_DIR=`pwd`
BUILD_DIR="$PWD"
SIGDIR=${BUILD_DIR}/signature/win
UNSIGNED_DIR=${BUILD_DIR}/unsigned
Expand All @@ -35,7 +35,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="${INFILE/%-unsigned}"
./osslsigncode attach-signature -in "${i}" -out "${OUTDIR}/${OUTFILE}" -sigin "${SIGDIR}/${INFILE}.pem"
done
12 changes: 6 additions & 6 deletions contrib/gitian-descriptors/gitian-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ script: |
export QT_RCC_TEST=1
export QT_RCC_SOURCE_DATE_OVERRIDE=1
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}
Expand Down Expand Up @@ -96,7 +96,7 @@ script: |
export PATH=${WRAP_DIR}:${PATH}
cd pivx
BASEPREFIX=`pwd`/depends
BASEPREFIX="${PWD}/depends"
# Build dependencies for each host
for i in $HOSTS; do
make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}"
Expand All @@ -112,10 +112,10 @@ script: |
# Create the release tarball using (arbitrarily) the first host
git update-index --assume-unchanged src/chiabls/contrib/relic/include/relic_conf.h.in
./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 pivx-*.tar.gz`
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'`
SOURCEDIST=$(echo pivx-*.tar.gz)
DISTNAME=${SOURCEDIST/%.tar.gz}
# Correct tar file order
mkdir -p temp
pushd temp
Expand All @@ -132,7 +132,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
Expand Down
6 changes: 4 additions & 2 deletions contrib/install_db4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -z "${1}" ]; then
fi

expand_path() {
echo "$(cd "${1}" && pwd -P)"
cd "${1}" && pwd -P
}

BDB_PREFIX="$(expand_path ${1})/db4"; shift;
Expand All @@ -23,7 +23,7 @@ BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"

check_exists() {
which "$1" >/dev/null 2>&1
command -v "$1" >/dev/null 2>&1
}

sha256_check() {
Expand Down Expand Up @@ -95,7 +95,9 @@ make install
echo
echo "db4 build complete."
echo
# shellcheck disable=SC2016
echo 'When compiling pivxd, run `./configure` in the following way:'
echo
echo " export BDB_PREFIX='${BDB_PREFIX}'"
# shellcheck disable=SC2016
echo ' ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" ...'
6 changes: 3 additions & 3 deletions contrib/macdeploy/detached-sig-apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ if [ -z "${CODESIGN_ALLOCATE}" ]; then
fi

find ${TEMPDIR} -name "*.sign" | while read i; do
SIZE=`stat -c %s "${i}"`
TARGET_FILE="`echo "${i}" | sed 's/\.sign$//'`"
SIZE=$(stat -c %s "${i}")
TARGET_FILE="$(echo "${i}" | sed 's/\.sign$//')"

echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}"
${CODESIGN_ALLOCATE} -i "${TARGET_FILE}" -a ${ARCH} ${SIZE} -o "${i}.tmp"

OFFSET=`${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
OFFSET=$(${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g')
if [ -z ${QUIET} ]; then
echo "Attaching signature at offset ${OFFSET}"
fi
Expand Down
14 changes: 7 additions & 7 deletions contrib/macdeploy/detached-sig-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TEMPLIST=${TEMPDIR}/signatures.txt
OUT=signature-osx.tar.gz
OUTROOT=osx

if [ ! -n "$1" ]; then
if [ -z "$1" ]; then
echo "usage: $0 <codesign args>"
echo "example: $0 -s MyIdentity"
exit 1
Expand All @@ -26,20 +26,20 @@ mkdir -p ${TEMPDIR}
${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}"

grep -v CodeResources < "${TEMPLIST}" | while read i; do
TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
SIZE=`pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g'`
OFFSET=`pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
TARGETFILE="${BUNDLE}/$(echo "${i}" | sed "s|.*${BUNDLE}/||")"
SIZE=$(pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g')
OFFSET=$(pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g')
SIGNFILE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}.sign"
DIRNAME="`dirname "${SIGNFILE}"`"
DIRNAME="$(dirname "${SIGNFILE}")"
mkdir -p "${DIRNAME}"
echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}"
dd if="$i" of="${SIGNFILE}" bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null
done

grep CodeResources < "${TEMPLIST}" | while read i; do
TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
TARGETFILE="${BUNDLE}/$(echo "${i}" | sed "s|.*${BUNDLE}/||")"
RESOURCE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}"
DIRNAME="`dirname "${RESOURCE}"`"
DIRNAME="$(dirname "${RESOURCE}")"
mkdir -p "${DIRNAME}"
echo "Adding resource for: \"${TARGETFILE}\""
cp "${i}" "${RESOURCE}"
Expand Down
7 changes: 7 additions & 0 deletions contrib/qos/tc.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/usr/bin/env bash
#
# Copyright (c) 2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

export LC_ALL=C
#network interface on which to limit traffic
IF="eth0"
#limit of the network interface in question
Expand Down
59 changes: 0 additions & 59 deletions contrib/tidy_datadir.sh

This file was deleted.

Loading

0 comments on commit fa302a9

Please sign in to comment.