From 3fb244c63141c2979f78f7bcfd2ca9c313f47ab7 Mon Sep 17 00:00:00 2001 From: Simon Fraser Date: Wed, 24 Jan 2018 12:50:04 +0000 Subject: [PATCH] Bug 1432765 Linting compliance for docker recipes r=jlund MozReview-Commit-ID: KbTLTU87hyI --HG-- extra : rebase_source : a1b433b7874cd7dcf3eee3a6c8328b780153a97d --- .../recipes/centos-install-debug-symbols.sh | 18 +++++++++--------- .../recipes/centos6-build-system-setup.sh | 7 ++++++- .../recipes/debian-build-system-setup.sh | 4 +++- taskcluster/docker/recipes/install-cmake.sh | 7 ++++--- taskcluster/docker/recipes/install-make.sh | 13 +++++++------ .../docker/recipes/install-mercurial.sh | 12 +++++++++--- .../recipes/ubuntu1604-test-system-setup.sh | 9 ++++++--- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/taskcluster/docker/recipes/centos-install-debug-symbols.sh b/taskcluster/docker/recipes/centos-install-debug-symbols.sh index 9095308bd960..b0fb60b98cb9 100644 --- a/taskcluster/docker/recipes/centos-install-debug-symbols.sh +++ b/taskcluster/docker/recipes/centos-install-debug-symbols.sh @@ -17,7 +17,7 @@ install_debuginfo_for_installed_packages() { # Remove arch suffix print gensub(/\.(i.86|x86_64|noarch)/, "", "", $1) }' \ - | xargs $debuginfo_install \ + | xargs "$debuginfo_install" \ || : # ignore errors } @@ -34,7 +34,7 @@ strlen() { LANG=C byteslen=${#1} LANG=$old_lang - echo $byteslen + echo "$byteslen" } echo "Searching for additional debuginfo packages..." @@ -47,14 +47,14 @@ libraries="" # argument length limit. arg_max stores the argument limit in # bytes, discounting the $debuginfo_install command plus one # space. -arg_max=$(( $(getconf ARG_MAX)-$(strlen $debuginfo_install)-$(strlen " ") )) +arg_max=$(( $(getconf ARG_MAX)-$(strlen "$debuginfo_install")-$(strlen " ") )) to_debuginfo() { # extracted from debuginfo-install script if [[ $1 == *-rpms ]]; then - echo ${1%*-rpms}-debug-rpms + echo "${1%*-rpms}-debug-rpms" else - echo $1-debuginfo + echo "$1-debuginfo" fi } @@ -68,7 +68,7 @@ get_debuginfo_package() { package="$package $unversioned_package" fi - echo $package + echo "$package" } walk_dir() { @@ -76,8 +76,8 @@ walk_dir() { for i in $1/*; do # if we found a library... if [[ $i == *.so ]]; then - lib="$(get_debuginfo_package $(basename $i))" - if [ $(strlen "$debuginfo_install $libraries $lib") -ge $arg_max ]; then + lib="$(get_debuginfo_package "$(basename "$i")")" + if [ "$(strlen "$debuginfo_install $libraries $lib")" -ge $arg_max ]; then $debuginfo_install $libraries > /dev/null libraries="" fi @@ -91,5 +91,5 @@ for i in /usr/lib /usr/lib64 /lib /lib64; do done if [ ${#libraries} -gt 0 ]; then - $debuginfo_install $libraries > /dev/null + $debuginfo_install "$libraries" > /dev/null fi diff --git a/taskcluster/docker/recipes/centos6-build-system-setup.sh b/taskcluster/docker/recipes/centos6-build-system-setup.sh index b7592cd34879..02a75fdd6c47 100644 --- a/taskcluster/docker/recipes/centos6-build-system-setup.sh +++ b/taskcluster/docker/recipes/centos6-build-system-setup.sh @@ -3,14 +3,19 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -cd /setup +cd /setup || exit +# shellcheck source=taskcluster/docker/recipes/common.sh . /setup/common.sh +# shellcheck source=taskcluster/docker/recipes/install-mercurial.sh . /setup/install-mercurial.sh +# shellcheck source=taskcluster/docker/recipes/install-make.sh . /setup/install-make.sh +# shellcheck source=taskcluster/docker/recipes/install-cmake.sh . /setup/install-cmake.sh if [ -f /setup/install-debug-symbols.sh ]; then + # shellcheck disable=SC1091 . /setup/install-debug-symbols.sh fi diff --git a/taskcluster/docker/recipes/debian-build-system-setup.sh b/taskcluster/docker/recipes/debian-build-system-setup.sh index bf1d2c78aed0..03acb5ec6a6a 100644 --- a/taskcluster/docker/recipes/debian-build-system-setup.sh +++ b/taskcluster/docker/recipes/debian-build-system-setup.sh @@ -3,9 +3,11 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -cd /setup +cd /setup || exit +# shellcheck source=taskcluster/docker/recipes/common.sh . /setup/common.sh +# shellcheck source=taskcluster/docker/recipes/install-mercurial.sh . /setup/install-mercurial.sh rm -rf /setup diff --git a/taskcluster/docker/recipes/install-cmake.sh b/taskcluster/docker/recipes/install-cmake.sh index 3e6695031c27..cd8d652394f0 100644 --- a/taskcluster/docker/recipes/install-cmake.sh +++ b/taskcluster/docker/recipes/install-cmake.sh @@ -15,7 +15,8 @@ tooltool_fetch <<'EOF' } ] EOF -cd cmake-3.7.1 -./bootstrap && make install -cd .. +( + cd cmake-3.7.1 || exit + ./bootstrap && make install +) rm -rf cmake-3.7.1 diff --git a/taskcluster/docker/recipes/install-make.sh b/taskcluster/docker/recipes/install-make.sh index d99509987099..4d1e55438420 100644 --- a/taskcluster/docker/recipes/install-make.sh +++ b/taskcluster/docker/recipes/install-make.sh @@ -16,12 +16,13 @@ tooltool_fetch <<'EOF' } ] EOF -cd make-4.0 -./configure -make -make install +( + cd make-4.0 || exit + ./configure + make + make install # The build system will find `gmake` ahead of `make`, so make sure it finds # the version we just installed. -ln -s /usr/local/bin/make /usr/local/bin/gmake -cd .. + ln -s /usr/local/bin/make /usr/local/bin/gmake +) rm -rf make-4.0 diff --git a/taskcluster/docker/recipes/install-mercurial.sh b/taskcluster/docker/recipes/install-mercurial.sh index 8f6df958cfb6..ab7048152fcc 100755 --- a/taskcluster/docker/recipes/install-mercurial.sh +++ b/taskcluster/docker/recipes/install-mercurial.sh @@ -9,9 +9,12 @@ set -e # Detect OS. if [ -f /etc/lsb-release ]; then + # Disabled so linting works on Mac + # shellcheck disable=SC1091 . /etc/lsb-release - if [ "${DISTRIB_ID}" = "Ubuntu" -a "${DISTRIB_RELEASE}" = "16.04" ]; then + if [ "${DISTRIB_ID}" = "Ubuntu" ] && [ "${DISTRIB_RELEASE}" = "16.04" ] + then HG_DEB=1 HG_DIGEST=458746bd82b4732c72c611f1041f77a47a683bc75ff3f6ab7ed86ea394f48d94cd7e2d3d1d5b020906318a9a24bea27401a3a63d7e645514dbc2cb581621977f HG_SIZE=193710 @@ -20,7 +23,8 @@ if [ -f /etc/lsb-release ]; then HG_COMMON_DIGEST=8074efbfff974f0bbdd0c3be3d272cc7a634456921e04db31369fbec1c9256ddaf44bdbe120f6f33113d2be9324a1537048028ebaaf205c6659e476a757358fd HG_COMMON_SIZE=2097892 HG_COMMON_FILENAME=mercurial-common_4.4.2_all.deb - elif [ "${DISTRIB_ID}" = "Ubuntu" -a "${DISTRIB_RELEASE}" = "12.04" ]; then + elif [ "${DISTRIB_ID}" = "Ubuntu" ] && [ "${DISTRIB_RELEASE}" = "12.04" ] + then echo "Ubuntu 12.04 not supported" exit 1 fi @@ -28,6 +32,8 @@ if [ -f /etc/lsb-release ]; then CERT_PATH=/etc/ssl/certs/ca-certificates.crt elif [ -f /etc/os-release ]; then + # Disabled so linting works on Mac + # shellcheck disable=SC1091 . /etc/os-release if [ "${ID}" = "debian" ]; then @@ -48,7 +54,7 @@ elif [ -f /etc/os-release ]; then CERT_PATH=/etc/ssl/certs/ca-certificates.crt elif [ -f /etc/centos-release ]; then - CENTOS_VERSION=`rpm -q --queryformat '%{VERSION}' centos-release` + CENTOS_VERSION="$(rpm -q --queryformat '%{VERSION}' centos-release)" if [ "${CENTOS_VERSION}" = "6" ]; then if [ -f /usr/bin/pip2.7 ]; then PIP_PATH=/usr/bin/pip2.7 diff --git a/taskcluster/docker/recipes/ubuntu1604-test-system-setup.sh b/taskcluster/docker/recipes/ubuntu1604-test-system-setup.sh index 0d84e959fdc1..e173ff343eaa 100644 --- a/taskcluster/docker/recipes/ubuntu1604-test-system-setup.sh +++ b/taskcluster/docker/recipes/ubuntu1604-test-system-setup.sh @@ -2,7 +2,7 @@ set -ve -test `whoami` == 'root' +test "$(whoami)" == 'root' mkdir -p /setup cd /setup @@ -87,17 +87,20 @@ apt_packages+=('python-pip') apt-get update # This allows ubuntu-desktop to be installed without human interaction export DEBIAN_FRONTEND=noninteractive -apt-get install -y -f ${apt_packages[@]} +apt-get install -y -f "${apt_packages[@]}" dpkg-reconfigure locales +# shellcheck source=taskcluster/docker/recipes/common.sh . /setup/common.sh +# shellcheck source=taskcluster/docker/recipes/install-mercurial.sh . /setup/install-mercurial.sh pip install --upgrade pip pip install virtualenv +# shellcheck source=taskcluster/docker/recipes/install-node.sh . /setup/install-node.sh # Install custom-built Debian packages. These come from a set of repositories @@ -176,4 +179,4 @@ cd / rm -rf /setup ~/.ccache ~/.cache ~/.npm apt-get clean apt-get autoclean -rm -f $0 +rm -f "$0"