#!/bin/bash if ! type "include" >/dev/null 2>&1; then include() { . "$(cd "$(dirname "$1")" && pwd)/${2}" } fi include "${BASH_SOURCE[0]}" ./pragma_once.bash if ! pragma_once ${BASH_SOURCE[0]}; then return 0; fi include "${BASH_SOURCE[0]}" ./attach/export.bash include "${BASH_SOURCE[0]}" ./patch/export.bash include "${BASH_SOURCE[0]}" ./libc/export.bash include "${BASH_SOURCE[0]}" ./base/export.bash install_cmake() { local ver="$1" local install_dir="${_ae_root_}/opt/cmake" sudo mkdir -p "${install_dir}" if [[ -z "$ver" ]]; then ver=$(git ls-remote --tags https://github.com/Kitware/CMake.git | awk '{print $2}' | grep -v '{}' | sed 's#refs/tags/##' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1) fi if [[ -z "$ver" ]]; then echo "[cmake] failed to resolve stable version" >&2 return 1 fi local file="cmake-${ver#v}-linux-x86_64.sh" wget -q "https://github.com/Kitware/CMake/releases/download/${ver}/${file}" \ -O "/tmp/${file}" if [[ $? -ne 0 ]]; then echo "[cmake] download failed ${ver}" >&2 return 1 fi chmod +x "/tmp/${file}" "/tmp/${file}" --skip-license --prefix="${install_dir}" export PATH="${install_dir}/bin:$PATH" echo "[cmake installed] version=${ver}" } check_cmake() { if ! command -v cmake >/dev/null 2>&1; then echo "[cmake] not installed" return 1 fi cmake --version | head -n1 } get_cmake_version() { if ! command -v cmake >/dev/null 2>&1; then echo "none" return fi cmake --version | head -n1 | awk '{print $3}' } cmake_require() { local required="$1" local cur cur=$(get_cmake_version) if [[ "$cur" == "none" ]]; then return 1 fi dpkg --compare-versions "$cur" ge "$required" }