Improve install scripts

* Only use bash where needed (scripts with pipes that use -o pipefail)
* Make string comparisons POSIX compatible
* Handle whitespace(s) in GOPATH
* Remove superfluous quotes in variable assignments

Change-Id: If1ea55f06f402ded646b5085d4837c0996f90fab
Signed-off-by: Joakim Roubert <joakimr@axis.com>
This commit is contained in:
Joakim Roubert 2019-12-12 13:25:25 +01:00
parent 55698e6942
commit 499fbb0337
6 changed files with 19 additions and 19 deletions

View File

@ -21,18 +21,18 @@
# #
set -eu -o pipefail set -eu -o pipefail
CNI_COMMIT=$(grep containernetworking/plugins ${GOPATH}/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}') CNI_COMMIT=$(grep containernetworking/plugins "$GOPATH"/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
CNI_DIR=/opt/cni CNI_DIR=/opt/cni
CNI_CONFIG_DIR=/etc/cni/net.d CNI_CONFIG_DIR=/etc/cni/net.d
go get -d github.com/containernetworking/plugins/... go get -d github.com/containernetworking/plugins/...
cd $GOPATH/src/github.com/containernetworking/plugins cd "$GOPATH"/src/github.com/containernetworking/plugins
git checkout $CNI_COMMIT git checkout $CNI_COMMIT
FASTBUILD=true ./build.sh FASTBUILD=true ./build.sh
mkdir -p $CNI_DIR mkdir -p $CNI_DIR
cp -r ./bin $CNI_DIR cp -r ./bin $CNI_DIR
mkdir -p $CNI_CONFIG_DIR mkdir -p $CNI_CONFIG_DIR
bash -c 'cat >'$CNI_CONFIG_DIR'/10-containerd-net.conflist <<EOF cat > $CNI_CONFIG_DIR/10-containerd-net.conflist <<EOF
{ {
"cniVersion": "0.3.1", "cniVersion": "0.3.1",
"name": "containerd-net", "name": "containerd-net",
@ -57,4 +57,4 @@ bash -c 'cat >'$CNI_CONFIG_DIR'/10-containerd-net.conflist <<EOF
} }
] ]
} }
EOF' EOF

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# Copyright The containerd Authors. # Copyright The containerd Authors.
@ -18,12 +18,12 @@
# Builds and installs critools including critest and crictl # Builds and installs critools including critest and crictl
# to /usr/local/bin. # to /usr/local/bin.
# #
set -eu -o pipefail set -eu
go get -u github.com/onsi/ginkgo/ginkgo go get -u github.com/onsi/ginkgo/ginkgo
CRITEST_COMMIT=v1.16.1 CRITEST_COMMIT=v1.16.1
go get -d github.com/kubernetes-incubator/cri-tools/... go get -d github.com/kubernetes-incubator/cri-tools/...
cd $GOPATH/src/github.com/kubernetes-incubator/cri-tools cd "$GOPATH"/src/github.com/kubernetes-incubator/cri-tools
git checkout $CRITEST_COMMIT git checkout $CRITEST_COMMIT
make make
make install make install

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# Copyright The containerd Authors. # Copyright The containerd Authors.
@ -18,14 +18,14 @@
# #
# Install developer tools to $GOBIN (or $GOPATH/bin if unset) # Install developer tools to $GOBIN (or $GOPATH/bin if unset)
# #
set -eu -o pipefail set -eu
go get -u github.com/stevvooe/protobuild go get -u github.com/stevvooe/protobuild
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u github.com/cpuguy83/go-md2man go get -u github.com/cpuguy83/go-md2man
( (
cd $GOPATH/src/github.com/golangci/golangci-lint/cmd/golangci-lint cd "$GOPATH"/src/github.com/golangci/golangci-lint/cmd/golangci-lint
git checkout v1.18.0 git checkout v1.18.0
go build -v && go install go build -v && go install
) )

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# Copyright The containerd Authors. # Copyright The containerd Authors.
@ -18,7 +18,7 @@
# #
# Downloads and installs protobuf # Downloads and installs protobuf
# #
set -eu -o pipefail set -eu
PROTOBUF_VERSION=3.7.0 PROTOBUF_VERSION=3.7.0
GOARCH=$(go env GOARCH) GOARCH=$(go env GOARCH)
@ -33,9 +33,9 @@ arm64)
;; ;;
amd64|386) amd64|386)
if [ $GOOS == "windows" ]; then if [ "$GOOS" = windows ]; then
wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-win32.zip" wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-win32.zip"
elif [ $GOOS == "linux" ]; then elif [ "$GOOS" = linux ]; then
wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip" wget -O $PROTOBUF_DIR/protobuf "https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip"
fi fi
unzip $PROTOBUF_DIR/protobuf -d /usr/local unzip $PROTOBUF_DIR/protobuf -d /usr/local

View File

@ -21,9 +21,9 @@
# #
set -eu -o pipefail set -eu -o pipefail
RUNC_COMMIT=$(grep opencontainers/runc ${GOPATH}/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}') RUNC_COMMIT=$(grep opencontainers/runc "$GOPATH"/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
go get -d github.com/opencontainers/runc go get -d github.com/opencontainers/runc
cd $GOPATH/src/github.com/opencontainers/runc cd "$GOPATH"/src/github.com/opencontainers/runc
git checkout $RUNC_COMMIT git checkout $RUNC_COMMIT
make BUILDTAGS="apparmor seccomp" runc install make BUILDTAGS='apparmor seccomp' runc install

View File

@ -23,8 +23,8 @@ set -eu -o pipefail
set -x set -x
export SECCOMP_VERSION="2.3.3" export SECCOMP_VERSION=2.3.3
export SECCOMP_PATH="$(mktemp -d)" export SECCOMP_PATH=$(mktemp -d)
curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" | tar -xzC "$SECCOMP_PATH" --strip-components=1 curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_VERSION}/libseccomp-${SECCOMP_VERSION}.tar.gz" | tar -xzC "$SECCOMP_PATH" --strip-components=1
( (
cd "$SECCOMP_PATH" cd "$SECCOMP_PATH"