merge #17361: Lint Gitian descriptors with ShellCheck

This commit is contained in:
Kittywhiskers Van Gogh 2021-08-25 20:31:44 +05:30
parent fd3db69ed8
commit 056590a1da
8 changed files with 64 additions and 32 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright (c) 2018 The Bitcoin Core developers # Copyright (c) 2018-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -9,3 +9,4 @@ export LC_ALL=C
travis_retry pip install codespell==1.13.0 travis_retry pip install codespell==1.13.0
travis_retry pip install flake8==3.5.0 travis_retry pip install flake8==3.5.0
travis_retry pip install vulture==0.29 travis_retry pip install vulture==0.29
travis_retry pip3 install yq

View File

@ -18,6 +18,7 @@ RUN pip3 install jinja2
RUN pip3 install flake8==3.5.0 RUN pip3 install flake8==3.5.0
RUN pip3 install codespell==1.13.0 RUN pip3 install codespell==1.13.0
RUN pip3 install vulture==0.29 RUN pip3 install vulture==0.29
RUN pip3 install yq
# dash_hash # dash_hash
RUN git clone https://github.com/dashpay/dash_hash RUN git clone https://github.com/dashpay/dash_hash

View File

@ -50,7 +50,7 @@ script: |
export GZIP="-9n" export GZIP="-9n"
export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME""
export TZ="UTC" export TZ="UTC"
export BUILD_DIR=`pwd` export BUILD_DIR="$PWD"
mkdir -p ${WRAP_DIR} mkdir -p ${WRAP_DIR}
if test -n "$GBUILD_CACHE_ENABLED"; then if test -n "$GBUILD_CACHE_ENABLED"; then
export SOURCES_PATH=${GBUILD_COMMON_CACHE} export SOURCES_PATH=${GBUILD_COMMON_CACHE}
@ -128,7 +128,7 @@ script: |
cat << EOF > ${WRAP_DIR}/${prog} cat << EOF > ${WRAP_DIR}/${prog}
#!/usr/bin/env bash #!/usr/bin/env bash
# GCCVERSION=${GCCVERSION} # GCCVERSION=${GCCVERSION}
REAL="`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1`" REAL="$(which -a ${prog}-8 | grep -v ${WRAP_DIR}/${prog} | head -1)"
for var in "\$@" for var in "\$@"
do do
if [ "\$var" = "-m32" ]; then if [ "\$var" = "-m32" ]; then
@ -144,7 +144,7 @@ script: |
done done
cd dash cd dash
BASEPREFIX=`pwd`/depends BASEPREFIX="${PWD}/depends"
# Build dependencies for each host # Build dependencies for each host
for i in $HOSTS; do for i in $HOSTS; do
EXTRA_INCLUDES="$EXTRA_INCLUDES_BASE/$i" EXTRA_INCLUDES="$EXTRA_INCLUDES_BASE/$i"
@ -163,10 +163,11 @@ script: |
# Create the release tarball using (arbitrarily) the first host # Create the release tarball using (arbitrarily) the first host
./autogen.sh ./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 make dist
SOURCEDIST=`echo dashcore-*.tar.gz` SOURCEDIST=$(echo dashcore-*.tar.gz)
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` DISTNAME=${SOURCEDIST/%.tar.gz}
# Correct tar file order # Correct tar file order
mkdir -p temp mkdir -p temp
pushd temp pushd temp
@ -183,7 +184,7 @@ script: |
export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
mkdir -p distsrc-${i} mkdir -p distsrc-${i}
cd distsrc-${i} cd distsrc-${i}
INSTALLPATH=`pwd`/installed/${DISTNAME} INSTALLPATH="${PWD}/installed/${DISTNAME}"
mkdir -p ${INSTALLPATH} mkdir -p ${INSTALLPATH}
tar --strip-components=1 -xf ../$SOURCEDIST tar --strip-components=1 -xf ../$SOURCEDIST

View File

@ -16,7 +16,7 @@ script: |
WRAP_DIR=$HOME/wrapped WRAP_DIR=$HOME/wrapped
mkdir -p ${WRAP_DIR} mkdir -p ${WRAP_DIR}
export PATH=`pwd`:$PATH export PATH="$PWD":$PATH
FAKETIME_PROGS="dmg genisoimage" FAKETIME_PROGS="dmg genisoimage"
# Create global faketime wrappers # Create global faketime wrappers

View File

@ -46,7 +46,7 @@ script: |
export GZIP="-9n" export GZIP="-9n"
export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME""
export TZ="UTC" export TZ="UTC"
export BUILD_DIR=`pwd` export BUILD_DIR="$PWD"
mkdir -p ${WRAP_DIR} mkdir -p ${WRAP_DIR}
if test -n "$GBUILD_CACHE_ENABLED"; then if test -n "$GBUILD_CACHE_ENABLED"; then
export SOURCES_PATH=${GBUILD_COMMON_CACHE} export SOURCES_PATH=${GBUILD_COMMON_CACHE}
@ -104,7 +104,7 @@ script: |
export PATH=${WRAP_DIR}:${PATH} export PATH=${WRAP_DIR}:${PATH}
cd dash cd dash
BASEPREFIX=`pwd`/depends BASEPREFIX="${PWD}/depends"
mkdir -p ${BASEPREFIX}/SDKs mkdir -p ${BASEPREFIX}/SDKs
tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz
@ -122,10 +122,10 @@ script: |
# Create the release tarball using (arbitrarily) the first host # Create the release tarball using (arbitrarily) the first host
./autogen.sh ./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 make dist
SOURCEDIST=`echo dashcore-*.tar.gz` SOURCEDIST=$(echo dashcore-*.tar.gz)
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` DISTNAME=${SOURCEDIST/%.tar.gz}
# Correct tar file order # Correct tar file order
mkdir -p temp mkdir -p temp
@ -143,7 +143,7 @@ script: |
export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
mkdir -p distsrc-${i} mkdir -p distsrc-${i}
cd distsrc-${i} cd distsrc-${i}
INSTALLPATH=`pwd`/installed/${DISTNAME} INSTALLPATH="${PWD}/installed/${DISTNAME}"
mkdir -p ${INSTALLPATH} mkdir -p ${INSTALLPATH}
tar --strip-components=1 -xf ../$SOURCEDIST tar --strip-components=1 -xf ../$SOURCEDIST

View File

@ -19,7 +19,7 @@ files:
script: | script: |
set -e -o pipefail set -e -o pipefail
BUILD_DIR=`pwd` BUILD_DIR="$PWD"
SIGDIR=${BUILD_DIR}/signature/win SIGDIR=${BUILD_DIR}/signature/win
UNSIGNED_DIR=${BUILD_DIR}/unsigned UNSIGNED_DIR=${BUILD_DIR}/unsigned
@ -35,7 +35,7 @@ script: |
./configure --without-gsf --without-curl --disable-dependency-tracking ./configure --without-gsf --without-curl --disable-dependency-tracking
make make
find ${UNSIGNED_DIR} -name "*-unsigned.exe" | while read i; do find ${UNSIGNED_DIR} -name "*-unsigned.exe" | while read i; do
INFILE="`basename "${i}"`" INFILE="$(basename "${i}")"
OUTFILE="`echo "${INFILE}" | sed s/-unsigned//`" OUTFILE="${INFILE/%-unsigned}"
./osslsigncode attach-signature -in "${i}" -out "${OUTDIR}/${OUTFILE}" -sigin "${SIGDIR}/${INFILE}.pem" ./osslsigncode attach-signature -in "${i}" -out "${OUTDIR}/${OUTFILE}" -sigin "${SIGDIR}/${INFILE}.pem"
done done

View File

@ -43,7 +43,7 @@ script: |
export GZIP="-9n" export GZIP="-9n"
export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME""
export TZ="UTC" export TZ="UTC"
export BUILD_DIR=`pwd` export BUILD_DIR="$PWD"
mkdir -p ${WRAP_DIR} mkdir -p ${WRAP_DIR}
if test -n "$GBUILD_CACHE_ENABLED"; then if test -n "$GBUILD_CACHE_ENABLED"; then
export SOURCES_PATH=${GBUILD_COMMON_CACHE} export SOURCES_PATH=${GBUILD_COMMON_CACHE}
@ -137,7 +137,7 @@ script: |
export PATH=${WRAP_DIR}:${PATH} export PATH=${WRAP_DIR}:${PATH}
cd dash cd dash
BASEPREFIX=`pwd`/depends BASEPREFIX="${PWD}/depends"
# Build dependencies for each host # Build dependencies for each host
for i in $HOSTS; do for i in $HOSTS; do
make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}"
@ -152,10 +152,10 @@ script: |
# Create the release tarball using (arbitrarily) the first host # Create the release tarball using (arbitrarily) the first host
./autogen.sh ./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 make dist
SOURCEDIST=`echo dashcore-*.tar.gz` SOURCEDIST=$(echo dashcore-*.tar.gz)
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` DISTNAME=${SOURCEDIST/%.tar.gz}
# Correct tar file order # Correct tar file order
mkdir -p temp mkdir -p temp
@ -175,7 +175,7 @@ script: |
export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
mkdir -p distsrc-${i} mkdir -p distsrc-${i}
cd distsrc-${i} cd distsrc-${i}
INSTALLPATH=`pwd`/installed/${DISTNAME} INSTALLPATH="${PWD}/installed/${DISTNAME}"
mkdir -p ${INSTALLPATH} mkdir -p ${INSTALLPATH}
tar --strip-components=1 -xf ../$SOURCEDIST tar --strip-components=1 -xf ../$SOURCEDIST

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright (c) 2018 The Bitcoin Core developers # Copyright (c) 2018-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
# #
@ -16,11 +16,6 @@ if [ "$TRAVIS" = "true" ]; then
unset LC_ALL unset LC_ALL
fi fi
if ! command -v shellcheck > /dev/null; then
echo "Skipping shell linting since shellcheck is not installed."
exit 0
fi
# Disabled warnings: # Disabled warnings:
disabled=( disabled=(
SC1087 # Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet). SC1087 # Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).
@ -46,5 +41,39 @@ disabled=(
SC2230 # which is non-standard. Use builtin 'command -v' instead. SC2230 # which is non-standard. Use builtin 'command -v' instead.
SC2236 # Don't force -n instead of ! -z. SC2236 # Don't force -n instead of ! -z.
) )
shellcheck -e "$(IFS=","; echo "${disabled[*]}")" \ disabled_gitian=(
$(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/') 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.
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