From 9ad4dbc81b9b2c19962b1cc2162192dec3e31c11 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Wed, 18 Oct 2023 21:24:18 +0000 Subject: [PATCH] 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