File: prepare_proxy_verifier.sh

package info (click to toggle)
trafficserver 9.2.5%2Bds-0%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 64,964 kB
  • sloc: cpp: 345,958; ansic: 31,184; python: 25,297; sh: 7,023; makefile: 3,045; perl: 2,255; java: 277; pascal: 119; sql: 94; xml: 2
file content (115 lines) | stat: -rwxr-xr-x 3,888 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# vim: sw=4:ts=4:softtabstop=4:ai:et

#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you 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.

fail()
{
    echo $1
    exit 1
}

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
ROOT=${ROOT:-${SCRIPT_DIR}}
[ -d "${ROOT}" ] || fail "ROOT: \"${ROOT}\" is not a directory."
[ -d "${ROOT}/tests" ] || fail "\"${ROOT}/tests\" is not a directory."

PV_VERSION_FILE="${ROOT}/tests/proxy-verifier-version.txt"
[ -r "${PV_VERSION_FILE}" ] || fail "\"${PV_VERSION_FILE}\" does not exist."

pv_name="proxy-verifier"
pv_version=`cat ${ROOT}/tests/proxy-verifier-version.txt`
pv_top_dir="${ROOT}/tests/proxy-verifier"
pv_unpack_dir="${pv_top_dir}/unpack/${pv_version}"
bin_dir="${pv_unpack_dir}/bin"
pv_dir="${pv_name}-${pv_version}"
pv_tar_filename="${pv_dir}.tar.gz"
pv_tar="${pv_top_dir}/${pv_tar_filename}"
pv_tar_url="https://ci.trafficserver.apache.org/bintray/${pv_tar_filename}"
expected_sha1="8e9adc6e0b31251ca8e6fc2064ae54e5d752bb72"
pv_client="${bin_dir}/verifier-client"
pv_server="${bin_dir}/verifier-server"
TAR=${TAR:-tar}
CURL=${CURL:-curl}
# Check to see whether Proxy Verifier has already been unpacked.
if ! [ -x ${pv_client} -a -x ${pv_server} ]
then
    # 1. Get the tar file if it has not been retrieved already.
    # Note that the two spaces between the hash and ${ARCHIVE) is needed
    if [ ! -e ${pv_tar} ]
    then
        # default to using native sha1sum command when available
        if [ $(which sha1sum) ]
        then
            SHASUM=${SHASUM:-sha1sum}
        else
            SHASUM=${SHASUM:-shasum}
        fi
        mkdir -p ${pv_top_dir}
        ${CURL} -L --progress-bar -o ${pv_tar} ${pv_tar_url} || \
            fail "Failed to download ${pv_tar_url}."
        cat > ${pv_top_dir}/sha1 << EOF
${expected_sha1}  ${pv_tar}
EOF
        ${SHASUM} -c ${pv_top_dir}/sha1 || fail "SHA1 mismatch for downloaded ${pv_tar_filename}."
    fi

    # 2. Untar the Proxy Verifier binaries.
    mkdir -p ${pv_unpack_dir}
    ${TAR} -x -C ${pv_unpack_dir} -f ${pv_tar}

    # 3. Determine the target OS.
    pv_os_dir=""
    case $(uname -s) in
    Darwin)
        case $(uname -m) in
        x86_64)
            pv_os_dir="${pv_unpack_dir}/${pv_dir}/darwin-amd64"
            ;;
        arm64)
            pv_os_dir="${pv_unpack_dir}/${pv_dir}/darwin-arm64"
            ;;
        *)
            fail "Unrecognized Mac architecture: $(uname -m)"
            ;;
        esac
        ;;
    Linux)
        pv_os_dir="${pv_unpack_dir}/${pv_dir}/linux"
        case $(uname -m) in
        x86_64)
            pv_os_dir="${pv_unpack_dir}/${pv_dir}/linux-amd64"
            ;;
        aarch64)
            pv_os_dir="${pv_unpack_dir}/${pv_dir}/linux-arm64"
            ;;
        *)
            fail "Unrecognized Linux architecture: $(uname -m)"
            ;;
        esac
        ;;
    *)
        fail "We need to build proxy-verifier for $(uname -s)"
    esac

    # 4. Link the OS-specific binaries to the bin directory.
    mkdir -p ${bin_dir}
    ln -s ${pv_os_dir}/verifier-client ${bin_dir}
    ln -s ${pv_os_dir}/verifier-server ${bin_dir}
    chmod +x ${pv_client}
    chmod +x ${pv_server}
fi