Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: Remove dependencies installed by make tools #14309

Merged
merged 13 commits into from
Oct 26, 2023
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved

# 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}
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
export ETCD_VER=v3.5.6
export CONSUL_VER=1.11.4
export TOXIPROXY_VER=v2.5.0

mkdir -p "$VTDATAROOT"

Expand Down
150 changes: 150 additions & 0 deletions tools/remove_dependencies.sh
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/bin/bash

FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
# 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

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

FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
BUILD_JAVA=${BUILD_JAVA:-1}
BUILD_CONSUL=${BUILD_CONSUL:-1}
uname=$(uname)
get_arch=$(uname -m)
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved

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

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
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
rm -rf $dist
fi
}

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

if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "vt-zookeeper-$ZK_VER" ]]; then
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
rm -rf $dist
fi
}

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 "Etcd not installed. Ignoring.."; return;;
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
esac

case $get_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"
mattlord marked this conversation as resolved.
Show resolved Hide resolved
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

if [[ "$(echo $dist | awk -F/ '{print $NF}')" == "etcd" ]]; then
rm -rf $dist
fi
}

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

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
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 $get_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 "$VTROOT/bin/toxiproxy-server"
fi
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"

# 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