Skip to content

Commit

Permalink
Tools: Remove dependencies installed by make tools (#14309)
Browse files Browse the repository at this point in the history
Signed-off-by: Prakhar Gurunani <[email protected]>
  • Loading branch information
FirePing32 authored Oct 26, 2023
1 parent 49acc58 commit 0d07456
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ tools:
echo $$(date): Installing dependencies
./bootstrap.sh

clean_tools:
./tools/remove_dependencies.sh

minimaltools:
echo $$(date): Installing minimal dependencies
BUILD_JAVA=0 BUILD_CONSUL=0 ./bootstrap.sh
Expand Down
14 changes: 6 additions & 8 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions build.env
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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"

Expand Down
152 changes: 152 additions & 0 deletions tools/remove_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/bin/bash

# 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.
# 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"

set -euo pipefail

source build.env

function fail() {
echo "ERROR: ${1}"
exit 1
}

BUILD_JAVA=${BUILD_JAVA:-1}
BUILD_CONSUL=${BUILD_CONSUL:-1}
UNAME=$(uname)
ARCH=$(uname -m)

uninstall_protoc() {
echo "Removing protoc..."
local dist="$1"

if [ -f "$dist/bin/protoc" ]; then
unlink "$dist/bin/protoc"
rm -f "$VTROOT/bin/protoc"
fi
if [[ "${dist##*/}" == "vt-protoc-$PROTOC_VER" ]]; then
rm -rf "$dist"
fi
}

uninstall_zookeeper() {
echo "Removing zookeeper..."
local dist="$1"

if [[ "${dist##*/}" == "vt-zookeeper-$ZK_VER" ]]; then
rm -rf "$dist"
fi
}

uninstall_etcd() {
echo "Removing etcd..."
local version="$1"
local dist="$2"

case $UNAME in
Linux) local platform=linux;;
Darwin) local platform=darwin;;
*) echo "Etcd not installed. Ignoring..."; return;;
esac

case $ARCH in
aarch64) local target=arm64;;
x86_64) local target=amd64;;
arm64) local target=arm64;;
*) echo "Etcd not installed. Ignoring..."; return;;
esac

if [ -f "$dist/etcd-${version}-${platform}-${target}/etcd" ]; then
unlink "$dist/etcd-${version}-${platform}-${target}/etcd"
rm -f "$VTROOT/bin/etcd"
fi
if [ -f "$dist/etcd-${version}-${platform}-${target}/etcdctl" ]; then
unlink "$dist/etcd-${version}-${platform}-${target}/etcdctl"
rm -f "$VTROOT/bin/etcdctl"
fi

if [[ "${dist##*/}" == "etcd" ]]; then
rm -rf "$dist"
fi
}

uninstall_consul() {
echo "Removing consul..."
local dist="$1"

if [ -f "$dist/consul" ]; then
unlink "$dist/consul"
rm -f "$VTROOT/bin/consul"
fi
if [[ "${dist##*/}" == "consul" ]]; then
rm -rf "$dist"
fi
}

uninstall_toxiproxy() {
echo "Removing toxiproxy..."
local dist="$1"

case $UNAME in
Linux) local platform=linux;;
Darwin) local platform=darwin;;
*) echo "Toxiproxy not installed. Ignoring..."; return;;
esac

case $ARCH in
aarch64) local target=arm64;;
x86_64) local target=amd64;;
arm64) local target=arm64;;
*) echo "Toxiproxy not installed. Ignoring..."; return;;
esac

file="toxiproxy-server-${platform}-${target}"

if [ -f "$dist/$file" ]; then
unlink "$dist/$file"
rm -f "$VTROOT/bin/toxiproxy-server"
fi
if [[ "${dist##*/}" == "toxiproxy" ]]; then
rm -rf "$dist"
fi
}

uninstall_all() {
echo "## local system details..."
echo "## platform: $UNAME target:$ARCH OS: $OSTYPE"

# protoc
uninstall_protoc "$VTROOT/dist/vt-protoc-$PROTOC_VER"

# zk
if [ "$BUILD_JAVA" == 1 ] ; then
uninstall_zookeeper "$VTROOT/dist/vt-zookeeper-$ZK_VER"
fi

# etcd
uninstall_etcd "$ETCD_VER" "$VTROOT/dist/etcd"

# consul
if [ "$BUILD_CONSUL" == 1 ] ; then
uninstall_consul "$VTROOT/dist/consul"
fi

# toxiproxy
uninstall_toxiproxy "$VTROOT/dist/toxiproxy"
}

uninstall_all

0 comments on commit 0d07456

Please sign in to comment.