|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
# set -o errexit -o noglob are assumed.
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
#
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
exp_rtl_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 (arab, vxp) |
ec19f0 |
_oldpwd;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
(ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
git pull origin "${_branch:-main}");
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
git clone "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -n "${_branch}" -a \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
\( -z "${_branch#main}" \) -a \
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
\( -z "${_branch#master}" \) ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
(ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
git checkout -b "${_branch}");
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_oldpwd="${PWD}"; ex_rtl_fileop cd "${PKG_BASE_DIR}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_fileop rm "${_tgtdir}/${_subdir}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_fileop cp "${BUILD_DLCACHEDIR}/${_subdir}" "${_tgtdir}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_fileop cd "${_oldpwd}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
};
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_fetch_urls_git() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
local _tgtdir _url_spec _subdir _url _git_branch;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_tgtdir="${1}"; shift;
|
|
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 (arab, vxp) |
ec19f0 |
exp_rtl_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 (arab, vxp) |
ec19f0 |
ex_rtl_fetch_url_wget() {
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
local _url="${1}" _sha256sum_src="${2}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -z "${3}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_url_dst="${BUILD_DLCACHEDIR}/$(ex_rtl_basename "${_url}")";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
_url_dst="${BUILD_DLCACHEDIR}/${3}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -e "${_url_dst}.fetched" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
return 0;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
else
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
wget ${DEFAULT_WGET_ARGS} -c -O "${_url_dst}" "${_url}";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ -n "${_sha256sum_src}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
set -- $(openssl dgst -sha256 "${_url_dst}"); shift $((${#}-1));
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
ex_rtl_log_msg failexit "Error: hash mismatch for URL \`${_url}' (is: ${_sha256sum_dst}, should be: ${_sha256sum_src}.)";
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
fi;
|
|
Lucio Andrés Illanes Albornoz (arab, vxp) |
ec19f0 |
touch "${_url_dst}.fetched";
|
|
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
|