From 7877cb410973adb5a8fb708aba89258d8473e577 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Wed, 18 Oct 2023 17:51:17 +0000 Subject: [PATCH 01/12] wip: remove deps Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tools/remove_dependencies.sh diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh new file mode 100644 index 00000000000..d916662a823 --- /dev/null +++ b/tools/remove_dependencies.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Copyright 2019 The Vitess Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Remove tools and dependencies installed by "make tools" + +source ./../dev.env + +uninstall_protoc() { + echo "Removing protoc..." + local dist="$1" + + unlink "$dist/bin/protoc" + rm -rf $dist +} + +uninstall_zookeeper() { + echo "Removing zookeeper..." + local dist="$1" + + rm -rf $dist +} + +uninstall_etcd() { + echo "Removing etcd..." + local version="$1" + local dist="$2" + + case $(uname) in + Linux) local platform=linux; local ext=tar.gz;; + Darwin) local platform=darwin; local ext=zip;; + *) echo "ERROR: unsupported platform for etcd"; exit 1;; + esac + + case $(get_arch) in + aarch64) local target=arm64;; + x86_64) local target=amd64;; + arm64) local target=arm64;; + *) echo "ERROR: unsupported architecture for etcd"; exit 1;; + esac + + + unlink "$dist/etcd-${version}-${platform}-${target}/etcd" + unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" + rm -rf $dist +} + +uninstall_consul() { + echo "Removing consul..." + local dist="$1" + + unlink "$dist/consul" + rm -rf $dist +} From 9ad4dbc81b9b2c19962b1cc2162192dec3e31c11 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Wed, 18 Oct 2023 21:24:18 +0000 Subject: [PATCH 02/12] remove deps and symlinks Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 90 +++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 6 deletions(-) mode change 100644 => 100755 tools/remove_dependencies.sh diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh old mode 100644 new mode 100755 index d916662a823..df48a7bf4c0 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -16,13 +16,29 @@ # Remove tools and dependencies installed by "make tools" -source ./../dev.env +get_arch() { + uname -m +} + +function fail() { + echo "ERROR: ${1}" + exit 1 +} + +BUILD_JAVA=${BUILD_JAVA:-1} +BUILD_CONSUL=${BUILD_CONSUL:-1} +VTROOT="$PWD/../" + +[[ "$(dirname "$0")" = "." ]] || fail "remove_dependencies.sh must be run from its current directory" uninstall_protoc() { echo "Removing protoc..." local dist="$1" - unlink "$dist/bin/protoc" + if [ -f $dist ]; then + unlink "$dist/bin/protoc" + rm "$VTROOT/bin/protoc" + fi rm -rf $dist } @@ -51,9 +67,14 @@ uninstall_etcd() { *) echo "ERROR: unsupported architecture for etcd"; exit 1;; esac - - unlink "$dist/etcd-${version}-${platform}-${target}/etcd" - unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" + if [ -f "$dist/etcd-${version}-${platform}-${target}/etcd" ]; then + unlink "$dist/etcd-${version}-${platform}-${target}/etcd" + rm "$VTROOT/bin/etcd" + fi + if [ -f "$dist/etcd-${version}-${platform}-${target}/etcdctl" ]; then + unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" + rm "$VTROOT/bin/etcdctl" + fi rm -rf $dist } @@ -61,6 +82,63 @@ uninstall_consul() { echo "Removing consul..." local dist="$1" - unlink "$dist/consul" + if [ -f "$dist/consul" ]; then + unlink "$dist/consul" + rm "$VTROOT/bin/consul" + fi rm -rf $dist } + +uninstall_toxiproxy() { + echo "Removing toxiproxy..." + local dist="$1" + + case $(uname) in + Linux) local platform=linux;; + Darwin) local platform=darwin;; + *) echo "WARNING: unsupported platform. Some tests that rely on toxiproxy will not function."; return;; + esac + + case $(get_arch) in + aarch64) local target=arm64;; + x86_64) local target=amd64;; + arm64) local target=arm64;; + *) echo "WARNING: unsupported architecture. Some tests that rely on toxiproxy will not function."; return;; + esac + + file="toxiproxy-server-${platform}-${target}" + + if [ -f "$dist/$file" ]; then + unlink "$dist/$file" + rm "$VTROOT/bin/toxiproxy-server" + fi + rm -rf $dist +} + +uninstall_all() { + echo "## local system details..." + echo "## platform: $(uname) target:$(get_arch) OS: $os" + + # protoc + protoc_ver=21.3 + uninstall_protoc "$VTROOT/dist/vt-protoc-$protoc_ver" + + # zk + zk_ver=${ZK_VERSION:-3.8.0} + if [ "$BUILD_JAVA" == 1 ] ; then + uninstall_zookeeper "$VTROOT/dist/vt-zookeeper-$zk_ver" + fi + + # etcd + uninstall_etcd "v3.5.6" "$VTROOT/dist/etcd" + + # consul + if [ "$BUILD_CONSUL" == 1 ] ; then + uninstall_consul "$VTROOT/dist/consul" + fi + + # toxiproxy + uninstall_toxiproxy "$VTROOT/dist/toxiproxy" +} + +uninstall_all From fd79a71aeb97fc493dc0043888b2dbce1885a05a Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 19 Oct 2023 07:59:04 +0000 Subject: [PATCH 03/12] workflow fixes; update makefile Signed-off-by: Prakhar Gurunani --- Makefile | 4 +++ bootstrap.sh | 14 ++++----- build.env | 11 +++++-- tools/remove_dependencies.sh | 60 ++++++++++++++++++++---------------- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 4eca82e0fc9..a8643728300 100644 --- a/Makefile +++ b/Makefile @@ -392,6 +392,10 @@ tools: echo $$(date): Installing dependencies ./bootstrap.sh +clean_tools: + source build.env + ./tools/remove_dependencies.sh + minimaltools: echo $$(date): Installing minimal dependencies BUILD_JAVA=0 BUILD_CONSUL=0 ./bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh index f95302ea771..094edb4b3e2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -224,27 +224,25 @@ install_toxiproxy() { install_all() { echo "##local system details..." - echo "##platform: $(uname) target:$(get_arch) OS: $os" + echo "##platform: $(uname) target:$(get_arch) OS: $OSTYPE" # protoc - protoc_ver=21.3 - install_dep "protoc" "$protoc_ver" "$VTROOT/dist/vt-protoc-$protoc_ver" install_protoc + install_dep "protoc" "$PROTOC_VER" "$VTROOT/dist/vt-protoc-$PROTOC_VER" install_protoc # zk - zk_ver=${ZK_VERSION:-3.8.0} if [ "$BUILD_JAVA" == 1 ] ; then - install_dep "Zookeeper" "$zk_ver" "$VTROOT/dist/vt-zookeeper-$zk_ver" install_zookeeper + install_dep "Zookeeper" "$ZK_VER" "$VTROOT/dist/vt-zookeeper-$ZK_VER" install_zookeeper fi # etcd - install_dep "etcd" "v3.5.6" "$VTROOT/dist/etcd" install_etcd + install_dep "etcd" $ETCD_VER "$VTROOT/dist/etcd" install_etcd # consul if [ "$BUILD_CONSUL" == 1 ] ; then - install_dep "Consul" "1.11.4" "$VTROOT/dist/consul" install_consul + install_dep "Consul" $CONSUL_VER "$VTROOT/dist/consul" install_consul fi # toxiproxy - install_dep "toxiproxy" "v2.5.0" "$VTROOT/dist/toxiproxy" install_toxiproxy + install_dep "toxiproxy" $TOXIPROXY_VER "$VTROOT/dist/toxiproxy" install_toxiproxy echo echo "bootstrap finished - run 'make build' to compile" diff --git a/build.env b/build.env index b9e44331e65..5986ee247b0 100755 --- a/build.env +++ b/build.env @@ -1,13 +1,13 @@ # No shebang line as this script is sourced from an external shell. # Copyright 2019 The Vitess Authors. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,6 +27,11 @@ mkdir -p vthook export VTROOT="$PWD" export VTDATAROOT="${VTDATAROOT:-${VTROOT}/vtdataroot}" export PATH="$PWD/bin:$PATH" +export PROTOC_VER=21.3 +export ZK_VER=${ZK_VERSION:-3.8.0} +export ETCD_VER=v3.5.6 +export CONSUL_VER=1.11.4 +export TOXIPROXY_VER=v2.5.0 mkdir -p "$VTDATAROOT" diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index df48a7bf4c0..8c04a57697e 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2019 The Vitess Authors. +# Copyright 2023 The Vitess Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,9 +16,7 @@ # Remove tools and dependencies installed by "make tools" -get_arch() { - uname -m -} +set -euo pipefail function fail() { echo "ERROR: ${1}" @@ -27,26 +25,29 @@ function fail() { BUILD_JAVA=${BUILD_JAVA:-1} BUILD_CONSUL=${BUILD_CONSUL:-1} -VTROOT="$PWD/../" - -[[ "$(dirname "$0")" = "." ]] || fail "remove_dependencies.sh must be run from its current directory" +uname=$(uname) +get_arch=$(uname -m) uninstall_protoc() { echo "Removing protoc..." local dist="$1" - if [ -f $dist ]; then + if [ -f "$dist/bin/protoc" ]; then unlink "$dist/bin/protoc" rm "$VTROOT/bin/protoc" fi - rm -rf $dist + if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "vt-protoc-$PROTOC_VER" ]]; then + rm -rf $dist + fi } uninstall_zookeeper() { echo "Removing zookeeper..." local dist="$1" - rm -rf $dist + if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "vt-zookeeper-$ZK_VER" ]]; then + rm -rf $dist + fi } uninstall_etcd() { @@ -54,17 +55,17 @@ uninstall_etcd() { local version="$1" local dist="$2" - case $(uname) in + case uname in Linux) local platform=linux; local ext=tar.gz;; Darwin) local platform=darwin; local ext=zip;; - *) echo "ERROR: unsupported platform for etcd"; exit 1;; + *) echo "Etcd not installed. Ignoring.."; return;; esac - case $(get_arch) in + case get_arch in aarch64) local target=arm64;; x86_64) local target=amd64;; arm64) local target=arm64;; - *) echo "ERROR: unsupported architecture for etcd"; exit 1;; + *) echo "Etcd not installed. Ignoring.."; return;; esac if [ -f "$dist/etcd-${version}-${platform}-${target}/etcd" ]; then @@ -75,7 +76,10 @@ uninstall_etcd() { unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" rm "$VTROOT/bin/etcdctl" fi - rm -rf $dist + + if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "etcd" ]]; then + rm -rf $dist + fi } uninstall_consul() { @@ -86,24 +90,26 @@ uninstall_consul() { unlink "$dist/consul" rm "$VTROOT/bin/consul" fi - rm -rf $dist + if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "consul" ]]; then + rm -rf $dist + fi } uninstall_toxiproxy() { echo "Removing toxiproxy..." local dist="$1" - case $(uname) in + case uname in Linux) local platform=linux;; Darwin) local platform=darwin;; - *) echo "WARNING: unsupported platform. Some tests that rely on toxiproxy will not function."; return;; + *) echo "Toxiproxy not installed. Ignoring.."; return;; esac - case $(get_arch) in + case get_arch in aarch64) local target=arm64;; x86_64) local target=amd64;; arm64) local target=arm64;; - *) echo "WARNING: unsupported architecture. Some tests that rely on toxiproxy will not function."; return;; + *) echo "Toxiproxy not installed. Ignoring.."; return;; esac file="toxiproxy-server-${platform}-${target}" @@ -112,25 +118,25 @@ uninstall_toxiproxy() { unlink "$dist/$file" rm "$VTROOT/bin/toxiproxy-server" fi - rm -rf $dist + if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "toxiproxy" ]]; then + rm -rf $dist + fi } uninstall_all() { echo "## local system details..." - echo "## platform: $(uname) target:$(get_arch) OS: $os" + echo "## platform: $uname target:$get_arch OS: $OSTYPE" # protoc - protoc_ver=21.3 - uninstall_protoc "$VTROOT/dist/vt-protoc-$protoc_ver" + uninstall_protoc "$VTROOT/dist/vt-protoc-$PROTOC_VER" # zk - zk_ver=${ZK_VERSION:-3.8.0} if [ "$BUILD_JAVA" == 1 ] ; then - uninstall_zookeeper "$VTROOT/dist/vt-zookeeper-$zk_ver" + uninstall_zookeeper "$VTROOT/dist/vt-zookeeper-$ZK_VER" fi # etcd - uninstall_etcd "v3.5.6" "$VTROOT/dist/etcd" + uninstall_etcd $ETCD_VER "$VTROOT/dist/etcd" # consul if [ "$BUILD_CONSUL" == 1 ] ; then From 64d7eb6838e14a4d296a3a3ab47b33412716b4e0 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 19 Oct 2023 08:04:30 +0000 Subject: [PATCH 04/12] minor fixes Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index 8c04a57697e..39849cce11a 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -55,13 +55,13 @@ uninstall_etcd() { local version="$1" local dist="$2" - case uname in + case $uname in Linux) local platform=linux; local ext=tar.gz;; Darwin) local platform=darwin; local ext=zip;; *) echo "Etcd not installed. Ignoring.."; return;; esac - case get_arch in + case $get_arch in aarch64) local target=arm64;; x86_64) local target=amd64;; arm64) local target=arm64;; @@ -99,13 +99,13 @@ uninstall_toxiproxy() { echo "Removing toxiproxy..." local dist="$1" - case uname in + case $uname in Linux) local platform=linux;; Darwin) local platform=darwin;; *) echo "Toxiproxy not installed. Ignoring.."; return;; esac - case get_arch in + case $get_arch in aarch64) local target=arm64;; x86_64) local target=amd64;; arm64) local target=arm64;; From b7353f85c9bfe3bfc81906b6307f8b5a25f753cc Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 23 Oct 2023 22:02:04 +0000 Subject: [PATCH 05/12] fix: var names Signed-off-by: Prakhar Gurunani --- bootstrap.sh | 6 +-- tools/remove_dependencies.sh | 72 ++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 094edb4b3e2..d3a4943ad38 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -234,15 +234,15 @@ install_all() { fi # etcd - install_dep "etcd" $ETCD_VER "$VTROOT/dist/etcd" install_etcd + install_dep "etcd" "$ETCD_VER" "$VTROOT/dist/etcd" install_etcd # consul if [ "$BUILD_CONSUL" == 1 ] ; then - install_dep "Consul" $CONSUL_VER "$VTROOT/dist/consul" install_consul + install_dep "Consul" "$CONSUL_VER" "$VTROOT/dist/consul" install_consul fi # toxiproxy - install_dep "toxiproxy" $TOXIPROXY_VER "$VTROOT/dist/toxiproxy" install_toxiproxy + install_dep "toxiproxy" "$TOXIPROXY_VER" "$VTROOT/dist/toxiproxy" install_toxiproxy echo echo "bootstrap finished - run 'make build' to compile" diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index 39849cce11a..2cf8357fd6a 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -25,107 +25,107 @@ function fail() { BUILD_JAVA=${BUILD_JAVA:-1} BUILD_CONSUL=${BUILD_CONSUL:-1} -uname=$(uname) -get_arch=$(uname -m) +UNAME=$(uname) +ARCH=$(uname -m) uninstall_protoc() { echo "Removing protoc..." - local dist="$1" + local DIST="$1" - if [ -f "$dist/bin/protoc" ]; then - unlink "$dist/bin/protoc" + if [ -f "$DIST/bin/protoc" ]; then + unlink "$DIST/bin/protoc" rm "$VTROOT/bin/protoc" fi - if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "vt-protoc-$PROTOC_VER" ]]; then - rm -rf $dist + if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "vt-protoc-$PROTOC_VER" ]]; then + rm -rf $DIST fi } uninstall_zookeeper() { echo "Removing zookeeper..." - local dist="$1" + local DIST="$1" - if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "vt-zookeeper-$ZK_VER" ]]; then - rm -rf $dist + if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "vt-zookeeper-$ZK_VER" ]]; then + rm -rf $DIST fi } uninstall_etcd() { echo "Removing etcd..." local version="$1" - local dist="$2" + local DIST="$2" - case $uname in + case $UNAME in Linux) local platform=linux; local ext=tar.gz;; Darwin) local platform=darwin; local ext=zip;; - *) echo "Etcd not installed. Ignoring.."; return;; + *) echo "Etcd not installed. Ignoring..."; return;; esac - case $get_arch in + case $ARCH in aarch64) local target=arm64;; x86_64) local target=amd64;; arm64) local target=arm64;; - *) echo "Etcd not installed. Ignoring.."; return;; + *) echo "Etcd not installed. Ignoring..."; return;; esac - if [ -f "$dist/etcd-${version}-${platform}-${target}/etcd" ]; then - unlink "$dist/etcd-${version}-${platform}-${target}/etcd" + if [ -f "$DIST/etcd-${version}-${platform}-${target}/etcd" ]; then + unlink "$DIST/etcd-${version}-${platform}-${target}/etcd" rm "$VTROOT/bin/etcd" fi - if [ -f "$dist/etcd-${version}-${platform}-${target}/etcdctl" ]; then - unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" + if [ -f "$DIST/etcd-${version}-${platform}-${target}/etcdctl" ]; then + unlink "$DIST/etcd-${version}-${platform}-${target}/etcdctl" rm "$VTROOT/bin/etcdctl" fi - if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "etcd" ]]; then - rm -rf $dist + if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "etcd" ]]; then + rm -rf $DIST fi } uninstall_consul() { echo "Removing consul..." - local dist="$1" + local DIST="$1" - if [ -f "$dist/consul" ]; then - unlink "$dist/consul" + if [ -f "$DIST/consul" ]; then + unlink "$DIST/consul" rm "$VTROOT/bin/consul" fi - if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "consul" ]]; then - rm -rf $dist + if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "consul" ]]; then + rm -rf $DIST fi } uninstall_toxiproxy() { echo "Removing toxiproxy..." - local dist="$1" + local DIST="$1" - case $uname in + case $UNAME in Linux) local platform=linux;; Darwin) local platform=darwin;; - *) echo "Toxiproxy not installed. Ignoring.."; return;; + *) echo "Toxiproxy not installed. Ignoring..."; return;; esac - case $get_arch in + case $ARCH in aarch64) local target=arm64;; x86_64) local target=amd64;; arm64) local target=arm64;; - *) echo "Toxiproxy not installed. Ignoring.."; return;; + *) echo "Toxiproxy not installed. Ignoring..."; return;; esac file="toxiproxy-server-${platform}-${target}" - if [ -f "$dist/$file" ]; then - unlink "$dist/$file" + if [ -f "$DIST/$file" ]; then + unlink "$DIST/$file" rm "$VTROOT/bin/toxiproxy-server" fi - if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "toxiproxy" ]]; then - rm -rf $dist + if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "toxiproxy" ]]; then + rm -rf $DIST fi } uninstall_all() { echo "## local system details..." - echo "## platform: $uname target:$get_arch OS: $OSTYPE" + echo "## platform: $UNAME target:$ARCH OS: $OSTYPE" # protoc uninstall_protoc "$VTROOT/dist/vt-protoc-$PROTOC_VER" From 037e3d92b84ff69c80e9312a1267112f6094c1af Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 15:09:44 +0000 Subject: [PATCH 06/12] fix: remove files in bash way to achieve max compatibility Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index 2cf8357fd6a..c47d3ab5ce2 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -90,7 +90,7 @@ uninstall_consul() { unlink "$DIST/consul" rm "$VTROOT/bin/consul" fi - if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "consul" ]]; then + if [[ "${DIST##*/}" == "consul" ]]; then rm -rf $DIST fi } @@ -118,7 +118,7 @@ uninstall_toxiproxy() { unlink "$DIST/$file" rm "$VTROOT/bin/toxiproxy-server" fi - if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "toxiproxy" ]]; then + if [[ "${DIST##*/}" == "toxiproxy" ]]; then rm -rf $DIST fi } From 66533b1830f55f829055f88cd650998cb0d5bb59 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 15:27:07 +0000 Subject: [PATCH 07/12] fix: vars Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 48 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index c47d3ab5ce2..d6002c43d75 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -30,30 +30,30 @@ ARCH=$(uname -m) uninstall_protoc() { echo "Removing protoc..." - local DIST="$1" + local dist="$1" - if [ -f "$DIST/bin/protoc" ]; then - unlink "$DIST/bin/protoc" + if [ -f "$dist/bin/protoc" ]; then + unlink "$dist/bin/protoc" rm "$VTROOT/bin/protoc" fi - if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "vt-protoc-$PROTOC_VER" ]]; then - rm -rf $DIST + if [[ "${dist##*/}" == "vt-protoc-$PROTOC_VER" ]]; then + rm -rf $dist fi } uninstall_zookeeper() { echo "Removing zookeeper..." - local DIST="$1" + local dist="$1" - if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "vt-zookeeper-$ZK_VER" ]]; then - rm -rf $DIST + if [[ "${dist##*/}" == "vt-zookeeper-$ZK_VER" ]]; then + rm -rf $dist fi } uninstall_etcd() { echo "Removing etcd..." local version="$1" - local DIST="$2" + local dist="$2" case $UNAME in Linux) local platform=linux; local ext=tar.gz;; @@ -68,36 +68,36 @@ uninstall_etcd() { *) echo "Etcd not installed. Ignoring..."; return;; esac - if [ -f "$DIST/etcd-${version}-${platform}-${target}/etcd" ]; then - unlink "$DIST/etcd-${version}-${platform}-${target}/etcd" + if [ -f "$dist/etcd-${version}-${platform}-${target}/etcd" ]; then + unlink "$dist/etcd-${version}-${platform}-${target}/etcd" rm "$VTROOT/bin/etcd" fi - if [ -f "$DIST/etcd-${version}-${platform}-${target}/etcdctl" ]; then - unlink "$DIST/etcd-${version}-${platform}-${target}/etcdctl" + if [ -f "$dist/etcd-${version}-${platform}-${target}/etcdctl" ]; then + unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" rm "$VTROOT/bin/etcdctl" fi - if [[ "$(echo $DIST | awk -F/ '{print $NF}')" == "etcd" ]]; then - rm -rf $DIST + if [[ "${dist##*/}" == "etcd" ]]; then + rm -rf $dist fi } uninstall_consul() { echo "Removing consul..." - local DIST="$1" + local dist="$1" - if [ -f "$DIST/consul" ]; then - unlink "$DIST/consul" + if [ -f "$dist/consul" ]; then + unlink "$dist/consul" rm "$VTROOT/bin/consul" fi - if [[ "${DIST##*/}" == "consul" ]]; then - rm -rf $DIST + if [[ "${dist##*/}" == "consul" ]]; then + rm -rf $dist fi } uninstall_toxiproxy() { echo "Removing toxiproxy..." - local DIST="$1" + local dist="$1" case $UNAME in Linux) local platform=linux;; @@ -114,11 +114,11 @@ uninstall_toxiproxy() { file="toxiproxy-server-${platform}-${target}" - if [ -f "$DIST/$file" ]; then - unlink "$DIST/$file" + if [ -f "$dist/$file" ]; then + unlink "$dist/$file" rm "$VTROOT/bin/toxiproxy-server" fi - if [[ "${DIST##*/}" == "toxiproxy" ]]; then + if [[ "${dist##*/}" == "toxiproxy" ]]; then rm -rf $DIST fi } From 675de0fe12a1820e8d1cb5bb2cdabbfad23ce12b Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 16:01:47 +0000 Subject: [PATCH 08/12] fix: vars Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index d6002c43d75..a6e029de29b 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -119,7 +119,7 @@ uninstall_toxiproxy() { rm "$VTROOT/bin/toxiproxy-server" fi if [[ "${dist##*/}" == "toxiproxy" ]]; then - rm -rf $DIST + rm -rf $dist fi } From b6c89942623ccfd6124472e756256de5dbb2e01a Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 16:27:53 +0000 Subject: [PATCH 09/12] fix: shellcheck warnings Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index a6e029de29b..45e51f8cbd9 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -37,7 +37,7 @@ uninstall_protoc() { rm "$VTROOT/bin/protoc" fi if [[ "${dist##*/}" == "vt-protoc-$PROTOC_VER" ]]; then - rm -rf $dist + rm -rf "$dist" fi } @@ -46,7 +46,7 @@ uninstall_zookeeper() { local dist="$1" if [[ "${dist##*/}" == "vt-zookeeper-$ZK_VER" ]]; then - rm -rf $dist + rm -rf "$dist" fi } @@ -78,7 +78,7 @@ uninstall_etcd() { fi if [[ "${dist##*/}" == "etcd" ]]; then - rm -rf $dist + rm -rf "$dist" fi } @@ -91,7 +91,7 @@ uninstall_consul() { rm "$VTROOT/bin/consul" fi if [[ "${dist##*/}" == "consul" ]]; then - rm -rf $dist + rm -rf "$dist" fi } @@ -119,7 +119,7 @@ uninstall_toxiproxy() { rm "$VTROOT/bin/toxiproxy-server" fi if [[ "${dist##*/}" == "toxiproxy" ]]; then - rm -rf $dist + rm -rf "$dist" fi } @@ -136,7 +136,7 @@ uninstall_all() { fi # etcd - uninstall_etcd $ETCD_VER "$VTROOT/dist/etcd" + uninstall_etcd "$ETCD_VER" "$VTROOT/dist/etcd" # consul if [ "$BUILD_CONSUL" == 1 ] ; then From c290572df5a91b050d0d3f8a361629bc07fedf14 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 16:37:28 +0000 Subject: [PATCH 10/12] remove local var Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index 45e51f8cbd9..32a6f56496a 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -56,8 +56,8 @@ uninstall_etcd() { local dist="$2" case $UNAME in - Linux) local platform=linux; local ext=tar.gz;; - Darwin) local platform=darwin; local ext=zip;; + Linux) local platform=linux;; + Darwin) local platform=darwin;; *) echo "Etcd not installed. Ignoring..."; return;; esac From 1102d60e9c36ba888e018fde3c2e76d78d75e43a Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 17:13:32 +0000 Subject: [PATCH 11/12] makefile: remove source Signed-off-by: Prakhar Gurunani --- Makefile | 1 - tools/remove_dependencies.sh | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b3198536f75..625a28baac0 100644 --- a/Makefile +++ b/Makefile @@ -393,7 +393,6 @@ tools: ./bootstrap.sh clean_tools: - source build.env ./tools/remove_dependencies.sh minimaltools: diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index 32a6f56496a..6d439519417 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -18,6 +18,8 @@ set -euo pipefail +source build.env + function fail() { echo "ERROR: ${1}" exit 1 From e6130fd3dd09dec4eb8197c9947f68e53922939c Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Thu, 26 Oct 2023 17:18:44 +0000 Subject: [PATCH 12/12] use -f to remove binaries Signed-off-by: Prakhar Gurunani --- tools/remove_dependencies.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/remove_dependencies.sh b/tools/remove_dependencies.sh index 6d439519417..62bf7785ba3 100755 --- a/tools/remove_dependencies.sh +++ b/tools/remove_dependencies.sh @@ -36,7 +36,7 @@ uninstall_protoc() { if [ -f "$dist/bin/protoc" ]; then unlink "$dist/bin/protoc" - rm "$VTROOT/bin/protoc" + rm -f "$VTROOT/bin/protoc" fi if [[ "${dist##*/}" == "vt-protoc-$PROTOC_VER" ]]; then rm -rf "$dist" @@ -72,11 +72,11 @@ uninstall_etcd() { if [ -f "$dist/etcd-${version}-${platform}-${target}/etcd" ]; then unlink "$dist/etcd-${version}-${platform}-${target}/etcd" - rm "$VTROOT/bin/etcd" + rm -f "$VTROOT/bin/etcd" fi if [ -f "$dist/etcd-${version}-${platform}-${target}/etcdctl" ]; then unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl" - rm "$VTROOT/bin/etcdctl" + rm -f "$VTROOT/bin/etcdctl" fi if [[ "${dist##*/}" == "etcd" ]]; then @@ -90,7 +90,7 @@ uninstall_consul() { if [ -f "$dist/consul" ]; then unlink "$dist/consul" - rm "$VTROOT/bin/consul" + rm -f "$VTROOT/bin/consul" fi if [[ "${dist##*/}" == "consul" ]]; then rm -rf "$dist" @@ -118,7 +118,7 @@ uninstall_toxiproxy() { if [ -f "$dist/$file" ]; then unlink "$dist/$file" - rm "$VTROOT/bin/toxiproxy-server" + rm -f "$VTROOT/bin/toxiproxy-server" fi if [[ "${dist##*/}" == "toxiproxy" ]]; then rm -rf "$dist"