#!/bin/bash set -o pipefail DIRNAME=$(dirname $(realpath $0)) REQUIRED_GEN_PACK_LIB="0.4.0" ############ gen-pack library ########### function install_lib() { local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz" echo "Downloading gen_pack lib to '$2'" mkdir -p "$2" curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1 } function load_lib() { local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}" local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}" if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then echo "Required gen-pack lib not found!" >&2 install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}" fi if [[ -d "${GLOBAL_LIB}" ]]; then . "${GLOBAL_LIB}/gen-pack" elif [[ -d "${USER_LIB}" ]]; then . "${USER_LIB}/gen-pack" else echo "Required gen-pack lib is not installed!" >&2 exit 1 fi } load_lib find_linkchecker ######################################### check_links "${DIRNAME}/../Documentation/index.html" "${DIRNAME}"