Skip to content

Commit b39d101

Browse files
authored
NETOBSERV-1578 Fix bash issues on macos (#150)
* use env bash * require bash 4.2+
1 parent bf44e00 commit b39d101

File tree

7 files changed

+29
-7
lines changed

7 files changed

+29
-7
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ifneq ($(CLEAN_BUILD),)
4848
endif
4949

5050
GOLANGCI_LINT_VERSION = v1.61.0
51+
BASH_VERSION = v4.2.0
5152
YQ_VERSION = v4.43.1
5253

5354
# build a single arch target provided as argument
@@ -151,6 +152,7 @@ commands: ## Generate either oc or kubectl plugins and add them to build folder
151152
PULL_POLICY=$(PULL_POLICY) \
152153
AGENT_IMAGE=$(AGENT_IMAGE) \
153154
VERSION=$(VERSION) \
155+
REQUIRED_BASH_VERSION=$(BASH_VERSION) \
154156
REQUIRED_YQ_VERSION=$(YQ_VERSION) \
155157
SUPPORTED_ARCHS=$(MULTIARCH_TARGETS) \
156158
./scripts/inject.sh

commands/netobserv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
source "./scripts/functions.sh"
33
source "./scripts/dependencies_check.sh"
44

@@ -94,7 +94,8 @@ function metrics() {
9494
if [[ ! "$*" =~ ^(.*)help|version(.*) ]]; then
9595
required_yq_version="v0.0.0"
9696
supported_archs=""
97-
check_dependencies "$required_yq_version" "$supported_archs"
97+
required_bash_version="v0.0.0"
98+
check_dependencies "$required_yq_version" "$supported_archs" "$required_bash_version"
9899
fi
99100

100101
case "$1" in

scripts/dependencies_check.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ function check_dependencies() {
3030
else
3131
echo "'yq' is up to date (version $current_yq_version)."
3232
fi
33+
34+
current_bash_version="v${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]}"
35+
required_bash_version="$3"
36+
# Compare versions
37+
compare_versions "${current_bash_version#v}" "${required_bash_version#v}"
38+
39+
if [ "$result" -eq 0 ]; then
40+
echo "Please upgrade bash to $required_bash_version or up. Found version $current_bash_version."
41+
exit 1
42+
else
43+
echo "'bash' is up to date (version $current_bash_version)."
44+
fi
3345
}
3446

3547
function compare_versions() {

scripts/generate-doc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
ADOC=./docs/netobserv_cli.adoc
33

44
# Header

scripts/inject.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -x
33

44
cp -a ./commands/. ./tmp
@@ -33,10 +33,17 @@ else
3333
sed -i.bak "s/^version=.*/version=\"$VERSION\"/" ./tmp/netobserv
3434
fi
3535

36+
if [ -z "$REQUIRED_BASH_VERSION" ]; then
37+
echo "require bash version is not set, keeping the current version"
38+
else
39+
echo "updating dependencies to check for bash $REQUIRED_BASH_VERSION"
40+
sed -i.bak "s/^required_bash_version=.*/required_bash_version=\"$REQUIRED_BASH_VERSION\"/" ./tmp/netobserv
41+
fi
42+
3643
if [ -z "$REQUIRED_YQ_VERSION" ]; then
3744
echo "require yq version is not set, keeping the current version"
3845
else
39-
echo "updating dependencies_check to check for $REQUIRED_YQ_VERSION"
46+
echo "updating dependencies to check for yq $REQUIRED_YQ_VERSION"
4047
sed -i.bak "s/^required_yq_version=.*/required_yq_version=\"$REQUIRED_YQ_VERSION\"/" ./tmp/netobserv
4148
fi
4249

scripts/krew.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
SHA=$(sha256sum netobserv-cli.tar.gz | awk '{print $1}')
44

scripts/update-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
echo "Downloading frontend config from operator repo"
44
curl "https://raw.githubusercontent.com/netobserv/network-observability-operator/refs/heads/main/controllers/consoleplugin/config/static-frontend-config.yaml" -o ./cmd/config.yaml

0 commit comments

Comments
 (0)