diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -155,6 +155,7 @@ }, "shellcheck": { "type": "shellcheck", + "version": ">=0.7.0", "flags": [ "--external-sources", "--source-path=SCRIPTDIR" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,7 +131,7 @@ On Ubuntu (>= 18.04+updates) or Debian (>= 10): ``` -sudo apt-get install clang-format-8 clang-tidy-8 clang-tools-8 cppcheck python-autopep8 flake8 php-codesniffer shellcheck +sudo apt-get install clang-format-8 clang-tidy-8 clang-tools-8 cppcheck python-autopep8 flake8 php-codesniffer ``` If not available in the distribution, `clang-format-8` and `clang-tidy` can be @@ -144,6 +144,19 @@ ln -s $PWD/clang+llvm-8.0.0-x86_64-apple-darwin/bin/clang-tidy /usr/local/bin/clang-tidy ``` +If you are modifying a shell script, you will need to install the `shellcheck` linter. +A recent version is required and may not be packaged for your distribution. +Standalone binaries are available for download on the project's github release page: +https://github.com/koalaman/shellcheck/releases + +If you are running Debian 10, it is also available in the backports repository: +``` +echo "deb http://deb.debian.org/debian buster-backports main" | sudo tee -a /etc/apt/sources.list +sudo apt-get update +sudo apt-get -t buster-backports install shellcheck +``` + + Working with The Bitcoin ABC Repository --------------------------------------- diff --git a/arcanist/linter/ShellCheckLinter.php b/arcanist/linter/ShellCheckLinter.php --- a/arcanist/linter/ShellCheckLinter.php +++ b/arcanist/linter/ShellCheckLinter.php @@ -48,6 +48,17 @@ return true; } + public function getVersion() { + list($stdout) = execx('%C --version', $this->getExecutableCommand()); + + $regex = '/^version: (?P\d+\.\d+\.\d+)/m'; + if (preg_match($regex, $stdout, $matches)) { + return $matches['version']; + } + + return false; + } + protected function getMandatoryFlags() { return array( '--format=gcc', diff --git a/contrib/teamcity/setup-debian-buster.sh b/contrib/teamcity/setup-debian-buster.sh --- a/contrib/teamcity/setup-debian-buster.sh +++ b/contrib/teamcity/setup-debian-buster.sh @@ -62,7 +62,6 @@ qemu-user-static qttools5-dev qttools5-dev-tools - shellcheck software-properties-common tar wget @@ -78,6 +77,14 @@ apt-get update DEBIAN_FRONTEND=noninteractive apt-get install -y $(join_by ' ' "${PACKAGES[@]}") +BACKPORTS=( + shellcheck +) + +echo "deb http://deb.debian.org/debian buster-backports main" | tee -a /etc/apt/sources.list +apt-get update +DEBIAN_FRONTEND=noninteractive apt-get -t buster-backports install -y $(join_by ' ' "${BACKPORTS[@]}") + TEAMCITY_DIR=$(dirname "$0") # FIXME this should no longer be needed starting with Teamcity 2020.1, which