File: get-clang-format

package info (click to toggle)
rocsolver 6.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 17,876 kB
  • sloc: cpp: 151,850; python: 2,275; sh: 875; objc: 642; ansic: 402; makefile: 71; xml: 26
file content (76 lines) | stat: -rwxr-xr-x 2,974 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
#!/usr/bin/env bash
# Downloads and extracts clang-format

set -euo pipefail

# Check arguments
if [[ $# -ne 1 ]]; then
  >&2 echo "usage: $0 <output directory>"
fi

# Get absolute path
output_dir=$(cd -- "$1" && pwd)

# Setup temporary workspace
workspace=$(mktemp -d)
on_exit() {
  rm -r -- "$workspace"
}
trap on_exit EXIT
cd -- "$workspace"

# Check OS
if [[ -e /etc/os-release ]]; then
  source /etc/os-release
else
  >&2 echo '/etc/os-release is required to choose a version'
  exit 1
fi

if [[ -z ${ID+x} ]]; then
  >&2 echo '$ID must be set'
  exit 1
fi

# Download and extract clang-format to the output directory
case "$ID" in
  ubuntu)
    wget -q --show-progress https://repo.radeon.com/rocm/apt/4.3.1/pool/main/l/llvm-amdgpu4.3.1/llvm-amdgpu4.3.1_13.0.0.21313.40301_amd64.deb
    echo '5c96fbc11558296422b17a29388ed91d6e436abc7c460d17510e6a5300e1dc8f *llvm-amdgpu4.3.1_13.0.0.21313.40301_amd64.deb' | sha256sum -c || exit
    ar x llvm-amdgpu4.3.1_13.0.0.21313.40301_amd64.deb data.tar.xz
    tar xJf data.tar.xz --strip-components=5 ./opt/rocm-4.3.1/llvm/bin/clang-format
    install --backup --verbose clang-format "$output_dir"
    ;;
  centos)
    if [[ -z ${VERSION_ID+x} ]]; then
      >&2 echo '$VERSION_ID must be set'
      exit 1
    fi
    case "$VERSION_ID" in
      7)
        wget https://repo.radeon.com/rocm/yum/rpm/llvm-amdgpu-13.0.0.21295.40300-52.el7.x86_64.rpm
        echo '13984360c38f5a6cb52d79f576902f8f36cfd95aaf8d004223d5c3f5f07e2116 *llvm-amdgpu-13.0.0.21295.40300-52.el7.x86_64.rpm' | sha256sum -c || exit
        rpm2cpio llvm-amdgpu-13.0.0.21295.40300-52.el7.x86_64.rpm | cpio -idm --quiet ./opt/rocm-4.3.0/llvm/bin/clang-format
        install --backup --verbose ./opt/rocm-4.3.0/llvm/bin/clang-format "$output_dir"
        ;;
      8)
        wget -q --show-progress https://repo.radeon.com/rocm/centos8/rpm/llvm-amdgpu4.3.0-13.0.0.21295.40300-52.el8.x86_64.rpm
        echo '4c2a6665431e6a37edbc7b5ed4daa5e4289f274af12eb07442b8c32cc63bf849 *llvm-amdgpu4.3.0-13.0.0.21295.40300-52.el8.x86_64.rpm' | sha256sum -c || exit
        rpm2cpio llvm-amdgpu4.3.0-13.0.0.21295.40300-52.el8.x86_64.rpm | cpio -idm --quiet ./opt/rocm-4.3.0/llvm/bin/clang-format
        install --backup --verbose ./opt/rocm-4.3.0/llvm/bin/clang-format "$output_dir"
        ;;
      *)
        >&2 echo "centos $VERSION_ID is not a supported OS"
        exit 1 ;;
    esac
    ;;
  sles)
    wget -q --show-progress https://repo.radeon.com/rocm/zyp/4.3.1/llvm-amdgpu4.3.1-13.0.0.21313.40301-sles152.59.x86_64.rpm
    echo '992e52d3c9274d266f30efd25b270cd8b3660f3d9fb2d0eca6e801c0e4a2d359 *llvm-amdgpu4.3.1-13.0.0.21313.40301-sles152.59.x86_64.rpm' | sha256sum -c || exit
    rpm2cpio llvm-amdgpu4.3.1-13.0.0.21313.40301-sles152.59.x86_64.rpm | cpio -idm --quiet ./opt/rocm-4.3.1/llvm/bin/clang-format
    install --backup --verbose ./opt/rocm-4.3.1/llvm/bin/clang-format "$output_dir"
    ;;
  *)
    >&2 echo "$ID is not a supported OS"
    exit 1 ;;
esac