# SPDX-License-Identifier: GPL-2.0-or-later # Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv) # Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) msg_color() { echo $( cd "${ROOT}" PROJECT="${PROJECT:-Generic}" ARCH="${ARCH:-x86_64}" . config/options "" echo $(print_color "$1" "$2") ) } msg_warn() { msg_color CLR_WARNING "$1" } msg_error() { msg_color CLR_ERROR "$1" } msg_info() { echo "$1" } git_clone() { # git_clone https://repo.url target_dir [branch] echo "[mkpkg] Checking out $1 ..." if [ ! -d "$2" ]; then git clone "$1" "$2" else cd "$2" git fetch cd .. fi if [ -n "$3" ]; then cd "$2" git checkout -q origin/"$3"; cd .. fi } get_pkg_var() { local pkg_name="$1" pkg_var="$2" cd "${ROOT}" PROJECT="${PROJECT:-Generic}" ARCH="${ARCH:-x86_64}" source config/options ${pkg_name} &>/dev/null echo "${!pkg_var}" } resolve_hash() { if [ -d "$1" ] ; then cd "$1" git rev-parse $2 2>/dev/null fi } resolve_hash_in_branch() { if [ -d "$1" ] ; then cd "$1" git rev-parse origin/$2 2>/dev/null fi } resolve_hash_on_gh() { curl -s -L -H "Authorization: token ${GITHUB_API_TOKEN}" \ -H "Accept: application/vnd.github.VERSION.sha" \ "${1/*github.com/https:\/\/api.github.com\/repos}/commits/$2" } resolve_tag_in_branch() { local tag if [ -d "$1" ] ; then cd "$1" if [ $# -eq 3 ] ; then tag=$(git describe --abbrev=0 --tags --match "$3" origin/$2 2>/dev/null) if [ -n "$tag" ] ; then echo "$tag" return fi fi git describe --abbrev=0 --tags origin/$2 2>/dev/null fi } resolve_tag_on_gh() { local tag local QUERY=$(tr '\n' ' ' <