github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/download-compatibility-test-binaries.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2023 PingCAP, Inc. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # download-compatibility-test-binaries.sh will 16 # * download all the binaries you need for dm compatibility testing 17 18 # Notice: 19 # Please don't try the script locally, 20 # it downloads files for linux platform. 21 22 set -o errexit 23 set -o nounset 24 set -o pipefail 25 26 # See https://misc.flogisoft.com/bash/tip_colors_and_formatting. 27 color-green() { # Green 28 echo -e "\x1B[1;32m${*}\x1B[0m" 29 } 30 31 function download() { 32 local url=$1 33 local file_name=$2 34 local file_path=$3 35 if [[ -f "${file_path}" ]]; then 36 echo "file ${file_name} already exists, skip download" 37 return 38 fi 39 echo ">>>" 40 echo "download ${file_name} from ${url}" 41 wget --no-verbose --retry-connrefused --waitretry=1 -t 3 -O "${file_path}" "${url}" 42 } 43 44 # Specify the download branch. 45 branch=$1 46 47 # PingCAP file server URL. 48 file_server_url="http://fileserver.pingcap.net" 49 50 # Get sha1 based on branch name. 51 tidb_sha1=$(curl "${file_server_url}/download/refs/pingcap/tidb/${branch}/sha1") 52 53 # All download links. 54 tidb_download_url="${file_server_url}/download/builds/pingcap/tidb/${tidb_sha1}/centos7/tidb-server.tar.gz" 55 sync_diff_inspector_download_url="http://download.pingcap.org/tidb-enterprise-tools-nightly-linux-amd64.tar.gz" 56 mydumper_download_url="http://download.pingcap.org/tidb-enterprise-tools-latest-linux-amd64.tar.gz" 57 58 gh_os_download_url="https://github.com/github/gh-ost/releases/download/v1.1.0/gh-ost-binary-linux-20200828140552.tar.gz" 59 minio_download_url="${file_server_url}/download/minio.tar.gz" 60 61 # Some temporary dir. 62 rm -rf tmp 63 rm -rf third_bin 64 65 mkdir -p third_bin 66 mkdir -p tmp 67 mkdir -p bin 68 69 color-green "Download binaries..." 70 download "$tidb_download_url" "tidb-server.tar.gz" "tmp/tidb-server.tar.gz" 71 tar -xz -C third_bin bin/tidb-server -f tmp/tidb-server.tar.gz && mv third_bin/bin/tidb-server third_bin/ 72 73 download "$sync_diff_inspector_download_url" "tidb-enterprise-tools-nightly-linux-amd64.tar.gz" "tmp/tidb-enterprise-tools-nightly-linux-amd64.tar.gz" 74 tar -xz -C third_bin tidb-enterprise-tools-nightly-linux-amd64/bin/sync_diff_inspector -f tmp/tidb-enterprise-tools-nightly-linux-amd64.tar.gz 75 mv third_bin/tidb-enterprise-tools-nightly-linux-amd64/bin/sync_diff_inspector third_bin/ && rm -rf third_bin/tidb-enterprise-tools-nightly-linux-amd64 76 download "$mydumper_download_url" "tidb-enterprise-tools-latest-linux-amd64.tar.gz" "tmp/tidb-enterprise-tools-latest-linux-amd64.tar.gz" 77 tar -xz -C third_bin tidb-enterprise-tools-latest-linux-amd64/bin/mydumper -f tmp/tidb-enterprise-tools-latest-linux-amd64.tar.gz 78 mv third_bin/tidb-enterprise-tools-latest-linux-amd64/bin/mydumper third_bin/ && rm -rf third_bin/tidb-enterprise-tools-latest-linux-amd64 79 download "$minio_download_url" "minio.tar.gz" "tmp/minio.tar.gz" 80 tar -xz -C third_bin -f tmp/minio.tar.gz 81 download "$gh_os_download_url" "gh-ost-binary-linux-20200828140552.tar.gz" "tmp/gh-ost-binary-linux-20200828140552.tar.gz" 82 tar -xz -C third_bin -f tmp/gh-ost-binary-linux-20200828140552.tar.gz 83 84 chmod a+x third_bin/* 85 86 # Copy it to the bin directory in the root directory. 87 rm -rf tmp 88 mv third_bin/* ./bin 89 rm -rf bin/bin 90 rm -rf third_bin 91 92 color-green "Download SUCCESS"