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

# 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)
ARCH=$(uname -m)

uninstall_protoc() {
echo "Removing protoc..."
local DIST="$1"
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved

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
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;;
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 "$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 $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
FirePing32 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading