Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit 6d30196

Browse files
committed
Fix shellcheck
1 parent 4f2d830 commit 6d30196

12 files changed

+44
-38
lines changed

bin/build-on-aws

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ echo "ONE STATE MACHINE TO RULE THEM ALL"
1010
echo "Runs any subset of build steps for any combination of versions + distros."
1111
echo
1212

13-
if [ -z "$1" -o "$1" == "--help" ]; then
13+
if [ -z "$1" ] || [ "$1" == "--help" ]; then
1414
echo "Usage: $0 [--skip-ec2|--fake-ec2] <versions> <distros> <steps>"
1515
echo
1616
echo "Each version will be built for each specified distro that it supports."
@@ -22,6 +22,7 @@ if [ -z "$1" -o "$1" == "--help" ]; then
2222
echo " --fake-ec2 launched EC2 instances will succeed without doing anything"
2323
echo
2424
echo "Available steps:"
25+
#shellcheck disable=SC2038
2526
find "$(dirname "$0")/../" -name activities.py \
2627
| xargs grep '^class [a-zA-Z]*.Activity.:$' \
2728
| grep -o ' [a-zA-Z]*'

bin/deploy-lambda

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
set -e
1010

11-
ROOT="$(realpath "$(dirname $0)/..")"
11+
ROOT="$(realpath "$(dirname "$0")/..")"
1212

1313
LAMBDA="$1"
1414
if [ -z "$LAMBDA" ]; then
@@ -21,17 +21,17 @@ if [ ! -d "$LAMBDA_ROOT" ]; then
2121
echo "Usage: $0 LAMBDA"
2222
exit 1
2323
fi
24-
cd $LAMBDA_ROOT
24+
cd "$LAMBDA_ROOT"
2525

26-
INPUTS=index.js
26+
INPUTS=(index.js)
2727
if [ -e package.json ]; then
2828
yarn
2929
if [ -e .babelrc ]; then
3030
yarn build
31-
INPUTS=build-out/index.js
31+
INPUTS+=(build-out/index.js)
3232
fi
33-
INPUTS="$INPUTS node_modules"
33+
INPUTS+=(node_modules)
3434
fi
3535
rm -f lambda.zip
36-
zip -r lambda.zip $INPUTS
36+
zip -r lambda.zip "${INPUTS[@]}"
3737
aws lambda update-function-code --function-name "$LAMBDA" --zip-file "fileb://$(pwd)/lambda.zip" --publish --region us-west-2

bin/fetch-build-log

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if [ -z "${STREAM}" ]; then
1313
echo "Usage: $0 LOG_NAME"
1414
exit 1
1515
fi
16-
LIMIT="${2:-100}"
1716

1817
aws logs get-log-events \
1918
--log-group-name hhvm-binary-package-builds/cloud-init-output.log \

bin/hhvm-tag-and-push

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if [ -z "$VERSION" ]; then
3232
VERSION="${INFERRED_VERSION}"
3333
echo "It looks like you want to tag >>> $VERSION <<<"
3434
echo "Hit ^C to cancel, or enter to continue"
35-
read
35+
read -r
3636
elif [ "$VERSION" != "${INFERRED_VERSION}" ]; then
3737
echo "Requested version ($VERSION) does not match expected ($INFERRED_VERSION)."
3838
exit 1
@@ -45,15 +45,16 @@ if [ "$(< .git/HEAD)" != "ref: refs/heads/HHVM-$(echo "$VERSION" | cut -f1-2 -d.
4545
fi
4646

4747
SED=$(if [ "$(uname -s)" == "Darwin" ]; then echo gsed; else echo sed; fi)
48-
49-
NEXT="$(echo "$VERSION" | $SED -E 's/(^.+\.)([0-9]+)$/echo "\1$((\2 + 1))"/e')"
48+
#shellcheck disable=SC2016
49+
NEXT="$(echo "$VERSION" | "$SED" -E 's/(^.+\.)([0-9]+)$/echo "\1$((\2 + 1))"/e')"
5050

5151
$SED -i 's/HHVM_VERSION_SUFFIX "-dev"$/HHVM_VERSION_SUFFIX ""/' \
5252
hphp/runtime/version.h
5353
git commit hphp/runtime/version.h -m "Releasing $VERSION"
54-
git tag HHVM-$VERSION
54+
git tag "HHVM-$VERSION"
5555
$SED -i 's/HHVM_VERSION_SUFFIX ""$/HHVM_VERSION_SUFFIX "-dev"/' \
5656
hphp/runtime/version.h
57+
#shellcheck disable=SC2016
5758
$SED -i -E 's/^(.+HHVM_VERSION_PATCH )([0-9]+)$/echo "\1$((\2+1))"/e' \
5859
hphp/runtime/version.h
5960
git commit hphp/runtime/version.h -m "Targetting $NEXT"

bin/list-build-images

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function dump_builds() {
1919
--query 'imageDetails[*].[imagePushedAt,imageTags[0]]' \
2020
--output text \
2121
| sort -r \
22-
| awk '{ print "\t"$1"\t'${IMAGE_NAME}':"$2 }'
22+
| awk '{ print "\t"$1"\t'"${IMAGE_NAME}"':"$2 }'
2323
}
2424

2525
echo "Failed builds:"
@@ -39,6 +39,7 @@ echo "$SUCCEEDED" | grep :backup || true
3939

4040
echo "To use an image:"
4141

42+
#shellcheck disable=SC2016
4243
echo ' $(aws ecr get-login --no-include-email)'
4344
echo ' docker pull IMAGE_NAME'
4445
echo ' docker run -it IMAGE_NAME /bin/bash -l'

bin/make-debianish-package

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
set -ex
1010

1111
export DEBIAN_FRONTEND=noninteractive
12-
export DEB_BUILD_OPTIONS="parallel=$(egrep -c '^processor' /proc/cpuinfo)"
12+
DEB_BUILD_OPTIONS="parallel=$(grep -E -c '^processor' /proc/cpuinfo)"
13+
export DEB_BUILD_OPTIONS
1314

1415
if $IS_NIGHTLY; then
1516
PKGBASE="hhvm-nightly"
@@ -34,23 +35,23 @@ apt-get clean
3435
apt-get install -y devscripts equivs
3536

3637
# Source extraction
37-
cp /var/out/${PKGBASE}-$VERSION.tar.gz ${PKGBASE}_$VERSION.orig.tar.gz
38-
tar zxf ${PKGBASE}_$VERSION.orig.tar.gz
39-
cd ${PKGBASE}-$VERSION
40-
cp -R $DISTRO_ROOT/debian/ debian/
38+
cp "/var/out/${PKGBASE}-$VERSION.tar.gz" "${PKGBASE}_$VERSION.orig.tar.gz"
39+
tar zxf "${PKGBASE}_$VERSION.orig.tar.gz"
40+
cd "${PKGBASE}-$VERSION"
41+
cp -R "$DISTRO_ROOT/debian/" debian/
4142
cp -R /opt/hhvm-packaging/skeleton/ debian/skeleton
4243

4344
if ! $IS_NIGHTLY; then
4445
sed -i '/^Conflicts: hhvm$/d' debian/control
4546
sed -i 's/hhvm-nightly/hhvm/' debian/control
4647
sed -i 's/hhvm-nightly/hhvm/' debian/rules
4748
for file in debian/hhvm-nightly*; do
48-
mv "$file" "$(echo $file | sed 's/hhvm-nightly/hhvm/')"
49+
mv "$file" "${$file//hhvm-nightly/hhvm}"
4950
done
5051
fi
5152

5253
# Add debian changelog entry
53-
dch --create -v $VERSION-$PKGVER --package ${PKGBASE} --controlmaint --distribution "$DISTRIBUTION" --force-distribution --empty
54+
dch --create -v "$VERSION-$PKGVER" --package ${PKGBASE} --controlmaint --distribution "$DISTRIBUTION" --force-distribution --empty
5455

5556
# Build debian package that depends on build-depends, and install it
5657
mk-build-deps
@@ -61,15 +62,18 @@ mv "$BUILD_DEPS_NEW" "$OUT" || rm "$BUILD_DEPS_OLD"
6162
# Build the actual debian packages
6263
PREBUILD="$DISTRO_ROOT/make-package.prebuild"
6364
if [ -x "$PREBUILD" ]; then
65+
#shellcheck disable=SC1090
6466
source $PREBUILD
6567
fi
6668
debuild -us -uc
6769
cd ..
68-
FILES=$(awk '/^Files:/ { files=1; next } /^[^ ]/ { files=0; next } files==1 { print $NF }' *.changes)
70+
FILES=$(awk '/^Files:/ { files=1; next } /^[^ ]/ { files=0; next } files==1 { print $NF }' ./*.changes)
6971
if [ -z "$FILES" ]; then
7072
echo "Failed to identify neccessary files"
7173
exit 1
7274
fi
73-
cp *.changes $FILES "$OUT"
75+
# FILES is one-per-line, but SC2086 wants to disable that expansion
76+
#shellcheck disable=SC2086
77+
cp ./*.changes $FILES "$OUT"
7478
set +ex
7579
echo "Build tree: $TEMP"

bin/make-interactive-container

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# This source code is licensed under the MIT license found in the
77
# LICENSE file in the root directory of this source tree.
88

9-
ROOT="$(realpath "$(dirname $0)/..")"
9+
ROOT="$(realpath "$(dirname "$0")/..")"
1010
OUT="$ROOT/out/"
1111
NODIST="$ROOT/nodist/"
1212
DISTRO=${1:-"debian-8-jessie"}

bin/make-multiple-releases-on-azure

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
set -e
1010

11-
ROOT="$(realpath "$(dirname $0)/..")"
12-
1311
VERSION=$1
1412
if [ -z "$VERSION" ]; then
1513
echo "Usage: $0 [-r|--rebuild REBUILD_NUM] VERSION1 [VERSION2 [VERSION3 ...]]"
@@ -39,7 +37,7 @@ echo "Rebuild number: $REBUILD_NUM"
3937
echo "Version(s): ${VERSIONS[*]}"
4038
echo
4139

42-
if ! which az >/dev/null; then
40+
if ! command -v az >/dev/null; then
4341
echo "Install 'az' (usually from the 'azure-cli' package) and try again."
4442
exit 1
4543
fi

bin/make-source-tarball

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
set -ex
1010

11-
ROOT="$(realpath "$(dirname $0)/..")"
11+
ROOT="$(realpath "$(dirname "$0")/..")"
1212
if [ "$ROOT" == "/opt/hhvm-packaging" ]; then
1313
OUT=/var/out
1414
else
@@ -22,13 +22,15 @@ TAR=${TAR:-tar}
2222
cd "$TEMPDIR"
2323

2424
if "${IS_AWS:-false}"; then
25+
# Intentionally doing unsafe (and potentially multiple) things with this eval
26+
#shellcheck disable=SC2046
2527
eval $(ssh-agent)
2628
KEYFILE=$(mktemp)
2729
aws kms decrypt \
2830
--region us-west-2 \
2931
--ciphertext-blob "fileb://${ROOT}/aws/staging-repo-key.kms-ciphertext" \
3032
--query Plaintext --output text \
31-
| base64 --decode > $KEYFILE
33+
| base64 --decode > "$KEYFILE"
3234
ssh-add "$KEYFILE"
3335

3436
echo "github.com,192.30.253.113 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
@@ -44,9 +46,9 @@ else
4446
HEAD=HHVM-${VERSION}
4547
fi
4648

47-
git clone ${REPO} ${PREFIX}-${VERSION}
48-
cd ${PREFIX}-$VERSION
49-
git checkout $HEAD
49+
git clone ${REPO} "${PREFIX}-${VERSION}"
50+
cd "${PREFIX}-$VERSION"
51+
git checkout "$HEAD"
5052
if "${IS_AWS:-false}" && $IS_NIGHTLY; then
5153
TAG="nightly-${VERSION}"
5254
# Tag may already exist from previous failed runs.

bin/promote-nightly-to-release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fi
9595
NIGHTLY="${POSITIONAL_ARGUMENTS[0]}"
9696
VERSION="${POSITIONAL_ARGUMENTS[1]}"
9797

98-
if [ -z "$NIGHTLY" -o -z "$VERSION" ]; then
98+
if [ -z "$NIGHTLY" ] || [ -z "$VERSION" ]; then
9999
echo "Missing nightly $NIGHTLY or version $VERSION"
100100
show_help
101101
exit 1
@@ -171,7 +171,7 @@ fi
171171

172172
SED=$(if [ "$(uname -s)" == "Darwin" ]; then echo gsed; else echo sed; fi)
173173

174-
if ! which "$SED" >/dev/null; then
174+
if ! command -v "$SED" >/dev/null; then
175175
echo "'$SED' is required."
176176
if [ "$SED" == "gsed" ]; then
177177
echo "Try: brew install gnu-sed"

0 commit comments

Comments
 (0)