|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
#
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
# set +o errexit -o noglob -o nounset is assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
rtlp_fetch_url_git() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}" \
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
_oldpwd="";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
(set -o errexit -o noglob -o nounset;
|
|
Lucio Andrés Illanes Albornoz |
847bee |
rtl_flock_acquire 4 || exit "${?}";
|
|
Lucio Andrés Illanes Albornoz |
e1d469 |
trap "rm -f \"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching\"" EXIT;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
(rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
git pull ${DEFAULT_GIT_ARGS} origin "${_branch:-main}");
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
(rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
|
|
Lucio Andrés Illanes Albornoz |
adfcc4 |
git submodule update);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
else
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
git clone ${DEFAULT_GIT_ARGS} "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
76f7b7 |
if [ -n "${_branch}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
(rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
76f7b7 |
git checkout "${_branch}");
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
(rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
|
|
Lucio Andrés Illanes Albornoz |
adfcc4 |
git submodule update --init);
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
_oldpwd="${PWD}"; rtl_fileop cd "${PKG_BASE_DIR}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fileop rm "${_tgtdir}/${_subdir}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fileop cp "${BUILD_DLCACHEDIR}/${_subdir}" "${_tgtdir}";
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fileop cd "${_oldpwd}";) 4<>"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching";
|
|
Lucio Andrés Illanes Albornoz |
689d3c |
if [ "${?}" -eq 0 ]; then
|
|
Lucio Andrés Illanes Albornoz |
689d3c |
cd "$(pwd)";
|
|
Lucio Andrés Illanes Albornoz |
689d3c |
else
|
|
Lucio Andrés Illanes Albornoz |
bf9edf |
return 1;
|
|
Lucio Andrés Illanes Albornoz |
689d3c |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fetch_urls_git() {
|
|
Lucio Andrés Illanes Albornoz |
907bd3 |
local _tgtdir="" _url_spec="" _subdir="" _url="" _git_branch="";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
fce0a9 |
_tgtdir="${1}"; shift;
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
if [ "${ARG_FETCH_FORCE}" = "offline" ]; then
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
return 0;
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
for _url_spec in "${@}"; do
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_subdir="${_url_spec%=*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_url="${_url_spec#*=}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_url="${_url%@*}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ "${_url_spec#*@}" != "${_url_spec}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_git_branch=${_url_spec#*@};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
rtlp_fetch_url_git "${_tgtdir}" "${_subdir}" \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
"${_url}" "${_git_branch}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
done;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
# N.B. URLs ($1) may contain `?' or '&' characters.
|
|
Lucio Andrés Illanes Albornoz |
c6d6e0 |
rtl_fetch_url_wget() {
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
local _url="${1}" _sha256sum_src="${2}" _target_fname="${3}" _target_fname_full="" RTL_CHECK_DIGEST_DIGEST="";
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
if [ "${ARG_FETCH_FORCE}" = "offline" ]; then
|
|
Lucio Andrés Illanes Albornoz |
d279a9 |
return 0;
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
else if [ -z "${_target_fname}" ]; then
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
_target_fname="$(rtl_basename "${_url}")";
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
fi;
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
_target_fname_full="${BUILD_DLCACHEDIR}/${_target_fname}";
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
(set -o errexit -o noglob -o nounset;
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
rtl_flock_acquire 4 || exit "${?}";
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
trap "_rc=\"\${?}\"; rm -f \"${_target_fname_full}.fetching\"; exit \"\${_rc}\";" EXIT;
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
if [ -z "${_sha256sum_src}" ]\
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
|| ! rtl_check_digest_file "${_target_fname_full}" "${_sha256sum_src}" "${_target_fname_full}.fetched"; then
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
wget ${DEFAULT_WGET_ARGS} -O "${_target_fname_full}" "${_url}";
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
if [ -n "${_sha256sum_src}" ]\
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
&& ! rtl_check_digest "${_target_fname_full}" "${_sha256sum_src}"; then
|
|
Lucio Andrés Illanes Albornoz |
b6a9a1 |
rtl_log_msg fatalexit "Error: hash mismatch for URL \`%s' (downloaded file: %s, from build variables: %s.)"\
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
"${_url}" "${RTL_CHECK_DIGEST_DIGEST}" "${_sha256sum_src}";
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
else
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
printf "%s" "${RTL_CHECK_DIGEST_DIGEST}" > "${_target_fname_full}.fetched";
|
|
Lucio Andrés Illanes Albornoz |
689d3c |
fi;
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
fi;) 4<>"${_target_fname_full}.fetching";
|
|
Lucio Andrés Illanes Albornoz |
63d19c |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
# vim:filetype=sh
|