Browse Source

fix(build): use more portable bash (#5537)

* build: use more portable bash

Currently scritps assume bash to be present at /bin/bash, but this
is not always the case.
Switch a more portable alternative (/usr/bin/env bash), which finds
whatever version is available for the user.

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>

* build: use bash shell correctly

Use correct $SHELL on the hack/api-docs

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>

---------

Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
Co-authored-by: Gergely Brautigam <skarlso777@gmail.com>
Tiago Castro 5 months ago
parent
commit
8dc6e633e8

+ 1 - 1
Makefile

@@ -1,5 +1,5 @@
 # set the shell to bash always
-SHELL         := /bin/bash
+SHELL         := /usr/bin/env bash
 
 # set make and shell flags to exit on errors
 MAKEFLAGS     += --warn-undefined-variables

+ 1 - 1
cmd/esoctl/Makefile

@@ -1,5 +1,5 @@
 # set the shell to bash always
-SHELL         := /bin/bash
+SHELL         := /usr/bin/env bash
 
 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
 ifeq (,$(shell go env GOBIN))

+ 1 - 1
docs/examples/bitwarden.md

@@ -45,7 +45,7 @@ CMD ["/entrypoint.sh"]
 
 And the content of `entrypoint.sh`:
 ```bash
-#!/bin/bash
+#!/usr/bin/env bash
 
 set -e
 

+ 1 - 1
e2e/Makefile

@@ -1,5 +1,5 @@
 MAKEFLAGS   += --warn-undefined-variables
-SHELL       := /bin/bash
+SHELL       := /usr/bin/env bash
 .SHELLFLAGS := -euo pipefail -c
 
 KIND_IMG       = "kindest/node:v1.33.4@sha256:25a6018e48dfcaee478f4a59af81157a437f15e6e140bf103f85a2e7cd0cbbf2"

+ 1 - 1
e2e/entrypoint.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Copyright 2019 The Kubernetes Authors.
 #

+ 1 - 1
e2e/run.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Copyright 2019 The Kubernetes Authors.
 #

+ 4 - 3
hack/api-docs/Makefile

@@ -23,6 +23,7 @@ MINOR_VERSION ?= $(shell echo $(VERSION_NO_V) | cut -d'.' -f2)
 VERSION_TO_CHECK ?= $(shell echo $(MAJOR_VERSION).$(MINOR_VERSION))
 DOCS_ALIAS ?= unstable
 SERVE_BIND_ADDRESS ?= 127.0.0.1
+SHELL := /usr/bin/env bash
 
 # TOP is the current directory where this Makefile lives.
 TOP := $(dir $(firstword $(MAKEFILE_LIST)))
@@ -69,7 +70,7 @@ build: image generate $(SOURCES)
 		--env "GIT_COMMITTER_NAME=$(shell git config user.name)" \
 		--env "GIT_COMMITTER_EMAIL=$(shell git config user.email)" \
 		$(MKDOCS_IMAGE) \
-		/bin/bash -c "cd /repo && $(MIKE) deploy --ignore --update-aliases -F hack/api-docs/mkdocs.yml $(DOCS_VERSION) $(DOCS_ALIAS);"
+		$(SHELL) -c "cd /repo && $(MIKE) deploy --ignore --update-aliases -F hack/api-docs/mkdocs.yml $(DOCS_VERSION) $(DOCS_ALIAS);"
 .PHONY: build.publish
 build.publish: image generate $(SOURCES)
 	mkdir -p $(GENROOT)
@@ -79,7 +80,7 @@ build.publish: image generate $(SOURCES)
 		--rm \
 		--user $(UID):$(GID) \
 		$(MKDOCS_IMAGE) \
-		/bin/bash -c "cd /repo && $(MIKE) deploy --update-aliases -p -F hack/api-docs/mkdocs.yml $(DOCS_VERSION) $(DOCS_ALIAS);"
+		$(SHELL) -c "cd /repo && $(MIKE) deploy --update-aliases -p -F hack/api-docs/mkdocs.yml $(DOCS_VERSION) $(DOCS_ALIAS);"
 .PHONY: generate
 generate:
 	./generate.sh $(SRCDIR)/api/spec.md
@@ -100,4 +101,4 @@ serve: build
 		-p $(SERVE_BIND_ADDRESS):8000:8000 \
 		--rm \
 		$(MKDOCS_IMAGE) \
-		/bin/bash -c "cd /repo && mkdocs serve -f hack/api-docs/mkdocs.yml -a 0.0.0.0:8000"
+		$(SHELL) -c "cd /repo && mkdocs serve -f hack/api-docs/mkdocs.yml -a 0.0.0.0:8000"

+ 1 - 1
hack/api-docs/add_eso_version.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Script to add a new ESO version to the stability-support.md file
 # Usage: ./add_eso_version.sh <ESO_VERSION>

+ 1 - 1
hack/api-docs/generate.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Copyright 2020 The Kubernetes Authors.
 #

+ 1 - 1
hack/update-deps.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 set -euo pipefail
 
 # update-deps.sh: Update Go module dependencies across all modules in the repository