0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-12-15 00:29:54 +00:00
Tomáš Kelemen (vudiq) 42898a5470
get_git: change GET_SKIP_SUBMODULE to PKG_GIT_SKIP_SUBMODULE
this resets the env for each package
2024-04-16 08:53:19 +02:00

60 lines
2.1 KiB
Plaintext
Executable File

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
# Handler for git, creates shallow clone of the package repository
# Usage (in package.mk):
# PKG_URL (mandatory) must point to a git repository (git://... or https://example.com/repo.git)
# PKG_VERSION (mandatory) must point to a full commit SHA
# PKG_GIT_CLONE_BRANCH (optional) clone specific branch (used here only for stamp, but can be used by other scripts to update the PKG_VERSION)
# PKG_GIT_SKIP_SUBMODULE (optional) do not pull submodules
GIT_STAMP="${PKG_URL}|${PKG_VERSION}"
[ -n "${PKG_GIT_CLONE_BRANCH}" ] && GIT_STAMP+="|${PKG_GIT_CLONE_BRANCH}"
[ -n "${PKG_GIT_SKIP_SUBMODULE}" ] && GIT_STAMP+="|${PKG_GIT_SKIP_SUBMODULE}"
GIT_TARBALL="${PACKAGE}.tar.xz"
GIT_STAMP_FILE="${GIT_TARBALL}.gitstamp"
GIT_TAR_SOURCE="${1}-${PKG_VERSION}"
_get_repo_already_downloaded() {
if [ -f "${GIT_TARBALL}" -a -f "${GIT_STAMP_FILE}" ]; then
[ "${GIT_STAMP}" = "$(cat ${GIT_STAMP_FILE} 2>/dev/null)" ] && return 0
fi
return 1
}
# Latest file already present, exit now...
_get_repo_already_downloaded && exit 0
lock_source_dir "${1}"
# Check again in case of concurrent access - if nothing needs to be downloaded, exit now...
_get_repo_already_downloaded && exit 0
# At this point, we need to download something...
build_msg "CLR_GET" "GET" "${1} (git)" "indent"
pkg_lock_status "GETPKG" "${PKG_NAME}" "unpack" "processing package repository..."
rm -rf "${STAMP_URL}" "${STAMP_SHA}" "${PACKAGE}" "${GIT_TARBALL}" "${GIT_STAMP_FILE}"
mkdir -p "${PACKAGE}"
git -C "${PACKAGE}" init
git -C "${PACKAGE}" remote add origin ${PKG_URL}
build_msg "CLR_GET" "GIT FETCH" "${1}"
git -C "${PACKAGE}" fetch --depth 1 origin ${PKG_VERSION}
git -C "${PACKAGE}" checkout FETCH_HEAD
if [ "${PKG_GIT_SKIP_SUBMODULE}" != "yes" ]; then
build_msg "CLR_GET" "GIT SUBMODULE" "${1}"
git -C "${PACKAGE}" submodule update --init --recursive --depth 1
fi
build_msg "CLR_GET" "GIT TARBALL" "${1}"
echo "Creating tarball from the package repository..."
tar --create --file ${GIT_TARBALL} --remove-files --xz --directory=${SOURCES}/${1} ${GIT_TAR_SOURCE}
echo "${GIT_STAMP}" > ${GIT_STAMP_FILE}