From 995edd3864f792c93980549fdd6e402d36d88fd5 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Tue, 16 Aug 2022 11:16:51 +0200 Subject: [PATCH] Fix: sourced files w/o arg bashisms The "source" command is only supported by a limited number of shells. It is normally equivalent to the POSIX "." (pronounced "dot") command. Contrary to sourced files, dotted files in bash does not allow any extra argument since it is normally not supported in POSIX. If no argument is specified, "source" and "." are strictly equivalent. And sourced files can be straightforward migrated to the dot syntax. Signed-off-by: guillaume.lambert Change-Id: Id902674c3eef31ce9633c2fc4fc2678da428f832 --- jenkins-init-scripts/local-init.sh | 2 +- jjb/autorelease/autorelease-macros.yaml | 2 +- jjb/autorelease/branch-cut.sh | 2 +- jjb/autorelease/generate-release-notes.sh | 2 +- jjb/autorelease/version-bump.sh | 2 +- jjb/docs/docs_version_bump.sh | 2 +- jjb/docs/docs_version_bump_projects.sh | 2 +- jjb/integration/common-functions.sh | 2 +- jjb/integration/integration-apex-run-tests.sh | 4 ++-- jjb/integration/integration-configure-clustering.sh | 2 +- jjb/integration/integration-deploy-controller-run-test.sh | 2 +- jjb/integration/integration-deploy-openstack-run-test.sh | 4 ++-- jjb/integration/integration-run-test.sh | 2 +- jjb/integration/integration-start-cluster-run-test.sh | 2 +- jjb/netvirt/quagga-build.sh | 3 +-- jjb/packaging/helm-repo-init.sh | 2 +- jjb/packaging/helm.yaml | 2 +- jjb/packaging/openstack-k8s-cluster-delete.sh | 2 +- jjb/packaging/openstack-k8s-config-export.sh | 2 +- jjb/packaging/openstack-k8s-create-with-template.sh | 2 +- jjb/packaging/openstack-k8s-deploy-helm.sh | 2 +- 21 files changed, 23 insertions(+), 24 deletions(-) diff --git a/jenkins-init-scripts/local-init.sh b/jenkins-init-scripts/local-init.sh index d55974cae..ff15325be 100755 --- a/jenkins-init-scripts/local-init.sh +++ b/jenkins-init-scripts/local-init.sh @@ -12,5 +12,5 @@ INIT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" "${INIT_DIR}/system_type.sh" # shellcheck disable=SC1091 -source /tmp/system_type.sh +. /tmp/system_type.sh "${INIT_DIR}/${SYSTEM_TYPE}.sh" diff --git a/jjb/autorelease/autorelease-macros.yaml b/jjb/autorelease/autorelease-macros.yaml index cdfe01cdc..2cc67e01d 100644 --- a/jjb/autorelease/autorelease-macros.yaml +++ b/jjb/autorelease/autorelease-macros.yaml @@ -46,7 +46,7 @@ #!/bin/bash -l set -xe -o pipefail python3 -m venv $WORKSPACE/venv - source $WORKSPACE/venv/bin/activate + . $WORKSPACE/venv/bin/activate PYTHON="$WORKSPACE/venv/bin/python" $PYTHON -m pip install --upgrade networkx $PYTHON -m pip freeze diff --git a/jjb/autorelease/branch-cut.sh b/jjb/autorelease/branch-cut.sh index 0c24b27c9..6d458b509 100644 --- a/jjb/autorelease/branch-cut.sh +++ b/jjb/autorelease/branch-cut.sh @@ -29,7 +29,7 @@ LOG_FILE="$WORKSPACE/archives/branch-cut.log" set -eu -o pipefail # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh lf-activate-venv "git-review==1.28" diff --git a/jjb/autorelease/generate-release-notes.sh b/jjb/autorelease/generate-release-notes.sh index 6f42692cf..48bd517d5 100644 --- a/jjb/autorelease/generate-release-notes.sh +++ b/jjb/autorelease/generate-release-notes.sh @@ -14,7 +14,7 @@ set -x # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh lf-activate-venv "git-review==1.28" diff --git a/jjb/autorelease/version-bump.sh b/jjb/autorelease/version-bump.sh index f54e0a3e8..a95f9b32f 100644 --- a/jjb/autorelease/version-bump.sh +++ b/jjb/autorelease/version-bump.sh @@ -27,7 +27,7 @@ BRANCH="$GERRIT_BRANCH" set -eu -o pipefail # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh lf-activate-venv "git-review==1.28" diff --git a/jjb/docs/docs_version_bump.sh b/jjb/docs/docs_version_bump.sh index 90021ed03..54b241ec3 100644 --- a/jjb/docs/docs_version_bump.sh +++ b/jjb/docs/docs_version_bump.sh @@ -31,7 +31,7 @@ done set +u # Allow unbound variables for virtualenv virtualenv --quiet "/tmp/v/git-review" # shellcheck source=/tmp/v/git-review/bin/activate disable=SC1091 -source "/tmp/v/git-review/bin/activate" +. "/tmp/v/git-review/bin/activate" pip install --quiet --upgrade "pip==9.0.3" setuptools pip install --quiet --upgrade git-review git config --global --add gitreview.username "jenkins-$SILO" diff --git a/jjb/docs/docs_version_bump_projects.sh b/jjb/docs/docs_version_bump_projects.sh index 31cb15994..05a2b8b00 100644 --- a/jjb/docs/docs_version_bump_projects.sh +++ b/jjb/docs/docs_version_bump_projects.sh @@ -30,7 +30,7 @@ while getopts :h: opts; do done # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh lf-activate-venv "git-review==1.28" diff --git a/jjb/integration/common-functions.sh b/jjb/integration/common-functions.sh index 801aa9c84..6c967d0cb 100644 --- a/jjb/integration/common-functions.sh +++ b/jjb/integration/common-functions.sh @@ -279,7 +279,7 @@ function run_plan() { for line in $( grep -E -v '(^[[:space:]]*#|^[[:space:]]*$)' "${type}plan.txt" ); do printf "Executing %s...\\n" "${line}" # shellcheck source=${line} disable=SC1091 - source "${line}" + . "${line}" done fi printf "Finished running %s plans\\n" "${type}" diff --git a/jjb/integration/integration-apex-run-tests.sh b/jjb/integration/integration-apex-run-tests.sh index 84d06e59a..980f590a0 100644 --- a/jjb/integration/integration-apex-run-tests.sh +++ b/jjb/integration/integration-apex-run-tests.sh @@ -3,7 +3,7 @@ # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091 -source "${ROBOT_VENV}/bin/activate" +. "${ROBOT_VENV}/bin/activate" source /tmp/common-functions.sh "${BUNDLEFOLDER}" # Ensure we fail the job if any steps fail. set -ex -o pipefail @@ -45,7 +45,7 @@ ssh "$OPENSTACK_COMPUTE_NODE_2_IP" "sudo bash /tmp/extra_node_configs.sh" USER=heat-admin openstack object save OPNFV-APEX-SNAPSHOTS overcloudrc -source overcloudrc +. overcloudrc cat overcloudrc openstack hypervisor list diff --git a/jjb/integration/integration-configure-clustering.sh b/jjb/integration/integration-configure-clustering.sh index 0fdcb9c58..42f73e40a 100644 --- a/jjb/integration/integration-configure-clustering.sh +++ b/jjb/integration/integration-configure-clustering.sh @@ -4,7 +4,7 @@ # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. # shellcheck disable=SC1090,SC1091 -source "${ROBOT_VENV}/bin/activate" +. "${ROBOT_VENV}/bin/activate" source /tmp/common-functions.sh "${BUNDLEFOLDER}" echo "#################################################" diff --git a/jjb/integration/integration-deploy-controller-run-test.sh b/jjb/integration/integration-deploy-controller-run-test.sh index 825194e9c..ee5e91fc7 100755 --- a/jjb/integration/integration-deploy-controller-run-test.sh +++ b/jjb/integration/integration-deploy-controller-run-test.sh @@ -9,7 +9,7 @@ fi # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091 -source "${ROBOT_VENV}/bin/activate" +. "${ROBOT_VENV}/bin/activate" source /tmp/common-functions.sh "${BUNDLEFOLDER}" diff --git a/jjb/integration/integration-deploy-openstack-run-test.sh b/jjb/integration/integration-deploy-openstack-run-test.sh index 3520c7baf..25bd8ecc4 100644 --- a/jjb/integration/integration-deploy-openstack-run-test.sh +++ b/jjb/integration/integration-deploy-openstack-run-test.sh @@ -3,7 +3,7 @@ # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091 -source "${ROBOT_VENV}/bin/activate" +. "${ROBOT_VENV}/bin/activate" source /tmp/common-functions.sh "${BUNDLEFOLDER}" # Ensure we fail the job if any steps fail. set -ex -o pipefail @@ -1148,7 +1148,7 @@ export OS_TENANT_NAME=admin unset OS_CLOUD EOF -source /tmp/os_netvirt_client_rc +. /tmp/os_netvirt_client_rc echo "Get all versions before executing robot" echo "openstack --version" diff --git a/jjb/integration/integration-run-test.sh b/jjb/integration/integration-run-test.sh index fa9db1204..d1277b2b2 100755 --- a/jjb/integration/integration-run-test.sh +++ b/jjb/integration/integration-run-test.sh @@ -8,7 +8,7 @@ fi # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091 -source "${ROBOT_VENV}/bin/activate" +. "${ROBOT_VENV}/bin/activate" source /tmp/common-functions.sh "${BUNDLEFOLDER}" echo "#################################################" echo "## invoke Tests for non-karaf Controllers ##" diff --git a/jjb/integration/integration-start-cluster-run-test.sh b/jjb/integration/integration-start-cluster-run-test.sh index 03c2335fb..81c30c927 100644 --- a/jjb/integration/integration-start-cluster-run-test.sh +++ b/jjb/integration/integration-start-cluster-run-test.sh @@ -4,7 +4,7 @@ # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091 -source "${ROBOT_VENV}/bin/activate" +. "${ROBOT_VENV}/bin/activate" source /tmp/common-functions.sh "${BUNDLEFOLDER}" # Ensure we fail the job if any steps fail. set -ex -o pipefail diff --git a/jjb/netvirt/quagga-build.sh b/jjb/netvirt/quagga-build.sh index ca46597d1..294601ebd 100644 --- a/jjb/netvirt/quagga-build.sh +++ b/jjb/netvirt/quagga-build.sh @@ -40,7 +40,6 @@ esac popd -# todo: remove below lines once the scripts in zrpcd repos build the -# source packages. +# todo: remove below lines once the scripts in zrpcd repos build the src packages. # Ref: https://lists.opendaylight.org/pipermail/integration-dev/2018-July/012330.html tar cvzf "$WORKSPACE/upload_files/zrpcd.$(date +%F).tar.gz" "$(pwd)/zrpcd" diff --git a/jjb/packaging/helm-repo-init.sh b/jjb/packaging/helm-repo-init.sh index 60ef63524..5d584d2db 100644 --- a/jjb/packaging/helm-repo-init.sh +++ b/jjb/packaging/helm-repo-init.sh @@ -15,7 +15,7 @@ set -e -o pipefail mkdir -p ".chartstorage" chartmuseum --port=6464 --storage="local" --storage-local-rootdir=".chartstorage" &> /dev/null & -source helm.prop +. helm.prop $HELM_BIN plugin install --version v0.9.0 https://github.com/chartmuseum/helm-push.git || true $HELM_BIN repo add local http://localhost:6464 $HELM_BIN repo add opendaylight http://localhost:6464 diff --git a/jjb/packaging/helm.yaml b/jjb/packaging/helm.yaml index 5726b36d6..9d95315a3 100644 --- a/jjb/packaging/helm.yaml +++ b/jjb/packaging/helm.yaml @@ -296,7 +296,7 @@ helm_build_script: | #!/bin/bash set -x - source helm.prop + . helm.prop set -e -o pipefail cd helm/opendaylight helm3.7 version diff --git a/jjb/packaging/openstack-k8s-cluster-delete.sh b/jjb/packaging/openstack-k8s-cluster-delete.sh index 7550ded66..a43a457e3 100644 --- a/jjb/packaging/openstack-k8s-cluster-delete.sh +++ b/jjb/packaging/openstack-k8s-cluster-delete.sh @@ -13,7 +13,7 @@ echo "---> Delete K8S cluster" set -eux -o pipefail # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh os_cloud="${OS_CLOUD:-vex}" cluster_name="${CLUSTER_NAME}" diff --git a/jjb/packaging/openstack-k8s-config-export.sh b/jjb/packaging/openstack-k8s-config-export.sh index 883df0014..5f834c7ab 100644 --- a/jjb/packaging/openstack-k8s-config-export.sh +++ b/jjb/packaging/openstack-k8s-config-export.sh @@ -13,7 +13,7 @@ echo "---> Export K8S cluster config and view nodes" set -eux -o pipefail # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh OS_TIMEOUT=5 # Wait time in minutes for OpenStack cluster nodes to come up. CLUSTER_NODE_RETRIES=15 # Number of times to retry waiting for a cluster nodes. diff --git a/jjb/packaging/openstack-k8s-create-with-template.sh b/jjb/packaging/openstack-k8s-create-with-template.sh index 7513c9f5e..4adcf8f91 100644 --- a/jjb/packaging/openstack-k8s-create-with-template.sh +++ b/jjb/packaging/openstack-k8s-create-with-template.sh @@ -13,7 +13,7 @@ echo "---> Create K8S cluster with pre-existing template" set -eux -o pipefail # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh lf-activate-venv python-openstackclient python-magnumclient OS_TIMEOUT=20 # Wait time in minutes for OpenStack cluster to come up. diff --git a/jjb/packaging/openstack-k8s-deploy-helm.sh b/jjb/packaging/openstack-k8s-deploy-helm.sh index d41816893..cf27ce409 100644 --- a/jjb/packaging/openstack-k8s-deploy-helm.sh +++ b/jjb/packaging/openstack-k8s-deploy-helm.sh @@ -15,7 +15,7 @@ set -eux -o pipefail set -x # shellcheck disable=SC1090 -source ~/lf-env.sh +. ~/lf-env.sh K8S_DEPLOY_LOG="$WORKSPACE/archives/k8s-kubectl-file.log" mkdir -p "$WORKSPACE/archives" -- 2.36.6