diff --git a/hack/all-in-one/build-aio-dev.sh b/hack/all-in-one/build-aio-dev.sh index a104bae20b..4bce93b800 100755 --- a/hack/all-in-one/build-aio-dev.sh +++ b/hack/all-in-one/build-aio-dev.sh @@ -1,8 +1,9 @@ +#!/bin/bash # This script runs hack/all-in-one/Dockerfile # to build a dev microshift-aio image with GPU support and kubectl installed # FROM_SOURCE="true" ./build-aio-dev.sh # to build image with locally built binary # ./build-aio-dev.sh # to build image with latest released binary -#!/bin/bash + cleanup () { rm -f unit crio-bridge.conf kubelet-cgroups.conf microshift @@ -17,15 +18,15 @@ cp ../../packaging/images/microshift-aio/unit ../../packaging/images/microshift- ARCH=$(uname -m |sed -e "s/x86_64/amd64/" |sed -e "s/aarch64/arm64/") if [ "$FROM_SOURCE" == "true" ]; then \ - pushd ../../ && \ + pushd ../../ && \ make && \ mv microshift hack/all-in-one/. && \ popd; \ fi podman build \ - --build-arg IMAGE_NAME=${IMAGE_NAME} \ - --build-arg FROM_SOURCE=${FROM_SOURCE} \ - --build-arg HOST=${HOST} \ - --build-arg ARCH=${ARCH} \ - -t ${TAG} . + --build-arg IMAGE_NAME="${IMAGE_NAME}" \ + --build-arg FROM_SOURCE="${FROM_SOURCE}" \ + --build-arg HOST="${HOST}" \ + --build-arg ARCH="${ARCH}" \ + -t "${TAG}" . diff --git a/hack/all-in-one/build-images.sh b/hack/all-in-one/build-images.sh index d906fa2151..a10eac9795 100755 --- a/hack/all-in-one/build-images.sh +++ b/hack/all-in-one/build-images.sh @@ -9,13 +9,13 @@ cp ../../packaging/images/microshift-aio/unit ../../packaging/images/microshift- ARCH=$(uname -m |sed -e "s/x86_64/amd64/" |sed -e "s/aarch64/arm64/") TAG="${TAG:-quay.io/microshift/microshift-aio:$(date +%Y-%m-%d-%H-%M)}" for img in "registry.access.redhat.com/ubi8/ubi-init:8.4" "docker.io/nvidia/cuda:11.4.2-base-ubi8"; do - echo "build microshift aio image using base image "${i} + echo "build microshift aio image using base image ""${img}" tag=$(echo ${img} |awk -F"/" '{print $NF}'| sed -e 's/:/-/g') - echo ${tag} + echo "${tag}" for host in "rhel7" "rhel8"; do host_tag="" [ "${host}" == "rhel7" ] && host_tag="-rhel7" - podman build --build-arg ARCH=${ARCH} --build-arg IMAGE_NAME=${img} --build-arg HOST=${host} -t ${TAG}-${tag}${host_tag} . + podman build --build-arg ARCH="${ARCH}" --build-arg IMAGE_NAME=${img} --build-arg HOST=${host} -t "${TAG}"-"${tag}"${host_tag} . done done diff --git a/hack/verify.sh b/hack/verify.sh index 56e04cf880..facef5a3c5 100755 --- a/hack/verify.sh +++ b/hack/verify.sh @@ -1,6 +1,5 @@ #!/bin/bash - set -x set -o errexit set -o nounset @@ -9,7 +8,7 @@ set -o pipefail REPO_ROOT=$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..) ( - cd $REPO_ROOT + cd "$REPO_ROOT" GOPKG=go/pkg GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) @@ -17,9 +16,8 @@ REPO_ROOT=$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..) go get -u golang.org/x/lint/golint - test -z $(gofmt -s -l -e $GO_FILES) + test -z $(gofmt -s -l -e "$GO_FILES") go vet -v $(go list ./... | grep -v /vendor/) cd ${GOPKG}; go test ) - diff --git a/packaging/images/components/build.sh b/packaging/images/components/build.sh index 8600694f05..70c2c59508 100755 --- a/packaging/images/components/build.sh +++ b/packaging/images/components/build.sh @@ -27,12 +27,12 @@ function source_image { function build_component { local component=$1 - SRC_REPO=$(source_repo $component) - SRC_COMMIT=$(source_commit $component) - OKD_IMG=$(source_image $component) + SRC_REPO=$(source_repo "$component") + SRC_COMMIT=$(source_commit "$component") + OKD_IMG=$(source_image "$component") - [ -z "$SRC_REPO" ] && SRC_REPO=$(cat components/$component/repo || :) - [ -z "$SRC_COMMIT" ] && SRC_COMMIT=$(cat components/$component/commit || :) + [ -z "$SRC_REPO" ] && SRC_REPO=$(cat components/"$component"/repo || :) + [ -z "$SRC_COMMIT" ] && SRC_COMMIT=$(cat components/"$component"/commit || :) echo "" echo -e "${GREEN}building component: $component${CLEAR}" @@ -40,14 +40,14 @@ function build_component { echo " Source Commit: $SRC_COMMIT" echo " Source Image: $OKD_IMG" - pushd components/$component >/dev/null + pushd components/"$component" >/dev/null if [ ! -z "${SRC_REPO}" ]; then - checkout_component $SRC_REPO $SRC_COMMIT + checkout_component "$SRC_REPO" "$SRC_COMMIT" build_cross_binaries fi - build_multiarch_image $component $OKD_IMG + build_multiarch_image "$component" "$OKD_IMG" popd if [ "${PUSH}" == "yes" ]; then @@ -59,23 +59,23 @@ function build_component { function checkout_component { echo "" echo -e "${GRAY}> making sure we have the source code for $1, at commit $2${CLEAR}" - [ ! -d src ] && git clone $1 src + [ ! -d src ] && git clone "$1" src cd src git fetch -a git stash >/dev/null # just in case we had patches applied in last run git clean -f # remove any out-of-tree files (from patches) - echo git checkout $2 -B building-side-images - git checkout $2 -B building-side-images + echo git checkout "$2" -B building-side-images + git checkout "$2" -B building-side-images cd .. } function build_cross_binaries { for ARCH in ${ARCHITECTURES} do - if [ -f Dockerfile.$ARCH ] || [ -f Dockerfile ] && [ ! -f ImageSource.$ARCH ] && [ -x ./build_binaries ]; then + if [ -f Dockerfile."$ARCH" ] || [ -f Dockerfile ] && [ ! -f ImageSource."$ARCH" ] && [ -x ./build_binaries ]; then echo "" echo -e "${GRAY}> building binaries for architecture ${ARCH} ${CLEAR}" - ./build_binaries $ARCH + ./build_binaries "$ARCH" fi done } @@ -158,28 +158,28 @@ function build_using_dockerfile { BUILD_ARGS="${BUILD_ARGS} --build-arg REGISTRY=${DEST_REGISTRY} --build-arg OKD_TAG=${OKD_BASE_TAG}" - buildah build-using-dockerfile --override-arch "${ARCH}" $BUILD_ARGS . || \ - if [ ${ARCH} == arm ]; then # fedora registry uses armhfp instead for arm (arm32 with floating point) - buildah build-using-dockerfile --override-arch "armhfp" $BUILD_ARGS . + buildah build-using-dockerfile --override-arch "${ARCH}" "$BUILD_ARGS" . || \ + if [ "${ARCH}" == arm ]; then # fedora registry uses armhfp instead for arm (arm32 with floating point) + buildah build-using-dockerfile --override-arch "armhfp" "$BUILD_ARGS" . fi } function build_using_image { - IMG_REF=$(get_image_ref $1 "${OKD_IMG}") + IMG_REF=$(get_image_ref "$1" "${OKD_IMG}") buildah pull --arch "${ARCH}" "${IMG_REF}" buildah tag "${IMG_REF}" "${ARCH_IMAGE}" } function get_image_ref { - IMG=$(cat $1) + IMG=$(cat "$1") # check if we must use the one captured from oc adm image-releases if [ "${IMG}" == "\$OKD_IMAGE_AMD64" ]; then - echo $2 + echo "$2" else - echo ${IMG} + echo "${IMG}" fi } @@ -199,5 +199,5 @@ fi for component in $COMPONENTS do - build_component $component + build_component "$component" done diff --git a/packaging/images/components/components/coredns/build_binaries b/packaging/images/components/components/coredns/build_binaries index ab0a4440cb..c8090f3e3c 100755 --- a/packaging/images/components/components/coredns/build_binaries +++ b/packaging/images/components/components/coredns/build_binaries @@ -7,7 +7,4 @@ cd src set -x GOOS=linux GOARCH=$1 CGO_ENABLED=0 \ GO111MODULE=on GOFLAGS=-mod=vendor \ -go build -o ../bin/coredns-$1 . - - - +go build -o ../bin/coredns-"$1" . diff --git a/packaging/images/components/components/flannel/build_binaries b/packaging/images/components/components/flannel/build_binaries index 18c9e25189..eec433f39e 100755 --- a/packaging/images/components/components/flannel/build_binaries +++ b/packaging/images/components/components/flannel/build_binaries @@ -2,6 +2,5 @@ mkdir -p bin -cd src -GOOS=linux GOARCH=$1 make dist/flanneld && mv dist/flanneld ../bin/flanneld-$1 - +cd src || exit +GOOS=linux GOARCH=$1 make dist/flanneld && mv dist/flanneld ../bin/flanneld-"$1" diff --git a/packaging/images/components/components/haproxy-router/build_binaries b/packaging/images/components/components/haproxy-router/build_binaries index 29502b5cf1..36650fcbe9 100755 --- a/packaging/images/components/components/haproxy-router/build_binaries +++ b/packaging/images/components/components/haproxy-router/build_binaries @@ -15,7 +15,7 @@ GO111MODULE=on GOOS=linux GOARCH=$1 GOFLAGS="-mod=vendor" \ make build set +x -cp openshift-router ../bin/openshift-router-$1 +cp openshift-router ../bin/openshift-router-"$1" if [ "x$1" == "xriscv64" ]; then git stash diff --git a/packaging/images/components/components/hostpath-provisioner/build_binaries b/packaging/images/components/components/hostpath-provisioner/build_binaries index 5cb4a0e093..08012bf291 100755 --- a/packaging/images/components/components/hostpath-provisioner/build_binaries +++ b/packaging/images/components/components/hostpath-provisioner/build_binaries @@ -11,7 +11,7 @@ fi set -x GOOS=linux GOARCH=$1 CGO_ENABLED=0 GOFLAGS="-mod=vendor" \ - go build -a -ldflags '-extldflags "-static"' -o ../bin/hostpath-provisioner-$1 cmd/provisioner/hostpath-provisioner.go + go build -a -ldflags '-extldflags "-static"' -o ../bin/hostpath-provisioner-"$1" cmd/provisioner/hostpath-provisioner.go set +x diff --git a/packaging/images/components/components/kube-rbac-proxy/build_binaries b/packaging/images/components/components/kube-rbac-proxy/build_binaries index 742254e14e..657a5ce9c7 100755 --- a/packaging/images/components/components/kube-rbac-proxy/build_binaries +++ b/packaging/images/components/components/kube-rbac-proxy/build_binaries @@ -14,7 +14,7 @@ GO111MODULE=on GOOS=linux GOARCH=$1 GOFLAGS="-mod=vendor" \ make build set +x -cp _output/kube-rbac-proxy-linux-$1 ../bin/kube-rbac-proxy-$1 +cp _output/kube-rbac-proxy-linux-"$1" ../bin/kube-rbac-proxy-"$1" if [ "x$1" == "xriscv64" ]; then git stash diff --git a/packaging/images/components/components/pause/build_binaries b/packaging/images/components/components/pause/build_binaries index 1749c90fe1..4e28053214 100755 --- a/packaging/images/components/components/pause/build_binaries +++ b/packaging/images/components/components/pause/build_binaries @@ -4,7 +4,7 @@ # TODO use our own image for riscv64 builder -podman run -it --rm -v $(pwd)/src:/src -e TAG=${VERSION} -w /src carlosedp/crossbuild-riscv64 < /etc/microshift-aio/microshift-aio.conf export KUBECONFIG=$(/usr/bin/podman volume inspect microshift-data --format "{{.Mountpoint}}")/microshift/resources/kubeadmin/kubeconfig EOF - diff --git a/packaging/systemd/microshift-containerized b/packaging/systemd/microshift-containerized index 3b4b1065b3..e33247e9e0 100755 --- a/packaging/systemd/microshift-containerized +++ b/packaging/systemd/microshift-containerized @@ -5,4 +5,4 @@ set -euxo pipefail [[ -d /etc/microshift-containerized ]] || mkdir -p /etc/microshift-containerized cat < /etc/microshift-containerized/microshift-containerized.conf export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig -EOF \ No newline at end of file +EOF diff --git a/scripts/bindata.sh b/scripts/bindata.sh index 91110cf389..de7f7855ef 100755 --- a/scripts/bindata.sh +++ b/scripts/bindata.sh @@ -1,6 +1,6 @@ go install github.com/go-bindata/go-bindata/... for i in crd core rbac apps scc storage; do OUTPUT="pkg/assets/${i}/bindata.go" - ${GOPATH}/bin/go-bindata -nocompress -nometadata -prefix "pkg/assets/${i}" -pkg assets -o ${OUTPUT} "./assets/${i}/..." + "${GOPATH}"/bin/go-bindata -nocompress -nometadata -prefix "pkg/assets/${i}" -pkg assets -o ${OUTPUT} "./assets/${i}/..." gofmt -s -w "${OUTPUT}" done diff --git a/scripts/release.sh b/scripts/release.sh index 7c227c8865..d227ca5778 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -36,7 +36,7 @@ ROOT="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/../")" # Check for a container manager cli (podman || docker), and alias it to "podman", since # they implement the same cli interface. __ctr_mgr_alias=$({ which podman &>/dev/null && echo "podman"; } || { which docker &>/dev/null && echo "docker"; } || echo "") -alias podman=${__ctr_mgr_alias:?"a container manager (podman || docker) is required as part of the release automation; none found"} +alias podman="${__ctr_mgr_alias:?"a container manager (podman || docker) is required as part of the release automation; none found"}" ######### # FUNCS # diff --git a/scripts/tools.go b/scripts/tools.go index b06d5bc360..7e471dcef5 100644 --- a/scripts/tools.go +++ b/scripts/tools.go @@ -1,4 +1,4 @@ -// This package imports things required by build scripts, to force `go mod` to see them as dependencies +// Package tools imports things required by build scripts, to force `go mod` to see them as dependencies package tools import (