diff options
author | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-02-26 21:54:12 +0000 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de> | 2020-02-26 21:54:12 +0000 |
commit | c6d6e08feab839a9dc5792071fb803494cc51a69 (patch) | |
tree | 1513c817e4446ac3cf512d6c1f287a10fc1daf2e /subr/ex_rtl_fetch.subr | |
parent | 4a5da5254e1207686f492e7ce8759c80466185f3 (diff) | |
download | midipix_build-c6d6e08feab839a9dc5792071fb803494cc51a69.tar.bz2 midipix_build-c6d6e08feab839a9dc5792071fb803494cc51a69.tar.xz |
General cleanup, pt. II.
Diffstat (limited to 'subr/ex_rtl_fetch.subr')
-rw-r--r-- | subr/ex_rtl_fetch.subr | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/subr/ex_rtl_fetch.subr b/subr/ex_rtl_fetch.subr deleted file mode 100644 index c4ba862d..00000000 --- a/subr/ex_rtl_fetch.subr +++ /dev/null @@ -1,92 +0,0 @@ -# -# set +o errexit -o noglob is assumed. -# - -exp_rtl_fetch_url_git() { - local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}" \ - _oldpwd=""; - (set -o errexit -o noglob; trap "rm -f \"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching\"" EXIT; - while true; do - if flock -E 622 -w 3600 4; then - break; - elif [ "${?}" -eq 622 ]; then - continue; - else - exit "${?}"; - fi; - done; - if [ -e "${BUILD_DLCACHEDIR}/${_subdir}" ]; then - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git pull ${DEFAULT_GIT_ARGS} origin "${_branch:-main}"); - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git submodule update); - else - git clone ${DEFAULT_GIT_ARGS} "${_url}" "${BUILD_DLCACHEDIR}/${_subdir}"; - if [ -n "${_branch}" ]; then - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git checkout "${_branch}"); - fi; - (ex_rtl_fileop cd "${BUILD_DLCACHEDIR}/${_subdir}" &&\ - git submodule update --init); - fi; - _oldpwd="${PWD}"; ex_rtl_fileop cd "${PKG_BASE_DIR}"; - ex_rtl_fileop rm "${_tgtdir}/${_subdir}"; - ex_rtl_fileop cp "${BUILD_DLCACHEDIR}/${_subdir}" "${_tgtdir}"; - ex_rtl_fileop cd "${_oldpwd}";) 4<>"${BUILD_DLCACHEDIR}/${_subdir%%[/]}.fetching"; - if [ "${?}" -eq 0 ]; then - cd "$(pwd)"; - else - return "${?}"; - fi; -}; - -ex_rtl_fetch_urls_git() { - local _tgtdir="" _url_spec="" _subdir="" _url="" _git_branch=""; - _tgtdir="${1}"; shift; - if [ "${ARG_FETCH_FORCE}" = "offline" ]; then - return 0; - fi; - for _url_spec in "${@}"; do - _subdir="${_url_spec%=*}"; - _url="${_url_spec#*=}"; - _url="${_url%@*}"; - if [ "${_url_spec#*@}" != "${_url_spec}" ]; then - _git_branch=${_url_spec#*@}; - fi; - exp_rtl_fetch_url_git "${_tgtdir}" "${_subdir}" \ - "${_url}" "${_git_branch}"; - done; -}; - -# N.B. URLs ($1) may contain `?' or '&' characters. -ex_rtl_fetch_url_wget() { - local _url="${1}" _sha256sum_src="${2}" _target_fname="${3}" _sha256sum_dst=""; - if [ "${ARG_FETCH_FORCE}" = "offline" ]; then - return 0; - elif [ -z "${_target_fname}" ]; then - _target_fname="$(ex_rtl_basename "${_url}")"; - fi; - _url_dst="${BUILD_DLCACHEDIR}/${_target_fname}"; - (set -o errexit -o noglob; trap "_rc=\"\${?}\" ;rm -f \"${_url_dst}.fetching\"; exit \"\${_rc}\";" EXIT; - while true; do - if flock -E 622 -w 3600 4; then - break; - elif [ "${?}" -eq 622 ]; then - continue; - else - exit "${?}"; - fi; - done; - if [ ! -e "${_url_dst}.fetched" ]; then - wget ${DEFAULT_WGET_ARGS} -O "${_url_dst}" "${_url}"; - if [ -n "${_sha256sum_src}" ]; then - set -- $(sha256sum "${_url_dst}"); - if [ "${_sha256sum_dst:=${1}}" != "${_sha256sum_src}" ]; then - ex_rtl_log_msg failexit "Error: hash mismatch for URL \`${_url}' (downloaded file: ${_sha256sum_dst}, from build variables: ${_sha256sum_src}.)"; - fi; - fi; - ex_rtl_fileop touch "${_url_dst}.fetched"; - fi;) 4<>"${_url_dst}.fetching"; -}; - -# vim:filetype=sh |