1#!/usr/bin/env bash 2#===- libcxx/utils/docker/scripts/install_clang_package.sh -----------------===// 3# 4# The LLVM Compiler Infrastructure 5# 6# This file is distributed under the University of Illinois Open Source 7# License. See LICENSE.TXT for details. 8# 9#===-----------------------------------------------------------------------===// 10 11set -e 12 13function show_usage() { 14 cat << EOF 15Usage: install_clang_package.sh [options] 16 17Install 18Available options: 19 -h|--help show this help message 20 --version the numeric version of the package to use. 21EOF 22} 23 24VERSION="" 25 26while [[ $# -gt 0 ]]; do 27 case "$1" in 28 --version) 29 shift 30 VERSION="$1" 31 shift 32 ;; 33 -h|--help) 34 show_usage 35 exit 0 36 ;; 37 *) 38 echo "Unknown option: $1" 39 exit 1 40 esac 41done 42 43 44 45curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 46add-apt-repository -s "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs) main" 47apt-get update 48apt-get install -y --no-install-recommends clang 49 50echo "Testing clang version..." 51clang --version 52 53echo "Testing clang++ version..." 54clang++ --version 55 56# Figure out the libc++ and libc++abi package versions that we want. 57if [ "$VERSION" == "" ]; then 58 VERSION="$(apt-cache search 'libc\+\+-[0-9]-dev' | awk '{print $1}' | awk -F- '{print $2}')" 59 echo "Installing version '$VERSION'" 60fi 61 62apt-get install -y --no-install-recommends "libc++-$VERSION-dev" "libc++abi-$VERSION-dev" 63 64echo "Done" 65