summaryrefslogtreecommitdiffhomepage
path: root/subr.rtl
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-04-06 11:26:11 +0100
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-04-06 11:26:11 +0100
commit2c5ce2e826a8af69d14429ea4da158bf94d31ca7 (patch)
tree97c90e082a90c8c617960cdae71a6e3dffbdfc97 /subr.rtl
parent360eb692689993886cc8c5e471e73c76dcfaa123 (diff)
downloadmidipix_build-2c5ce2e826a8af69d14429ea4da158bf94d31ca7.tar.bz2
midipix_build-2c5ce2e826a8af69d14429ea4da158bf94d31ca7.tar.xz
pkgtool.sh:pkgtoolp_mirror_fetch(): call pkg_fetch_download_clean_dlcache() post-{archive,Git} mirroring.
pkgtool.sh:pkgtoolp_mirror_fetch(): mirror both archive as well as Git URL(s). subr/pkg_configure_patch.subr:pkg_configure_patch(): apply patches from within ${PKG_BASE_DIR} given both ${PKG_FNAME} and ${PKG_URLS_GIT}. subr.rtl/rtl_fetch.subr:rtl_fetch_mirror_urls_git(): ignore all but last component in ${_subdir}. subr.rtl/rtl_fetch.subr:rtl_fetch_mirror_urls_git(): create prerequisite directories. subr.rtl/rtl_fetch.subr:rtlp_fetch_url_git(): ignore all but last component in ${_subdir} wrt. ${_cache_dlname}. subr.rtl/rtl_fetch.subr:rtlp_fetch_url_git(): create prerequisite directories wrt. ${_tgtdir}. subr/ex_pkg_env.subr:exp_pkg_env_defaults(): reject absence of ${PKG_SUBDIR} given both ${PKG_FNAME} and ${PKG_URLS_GIT}. subr/pkg_fetch_download.subr:pkg_fetch_download_clean_dlcache(): initial implementation. subr/pkg_fetch_download.subr:pkg_fetch_download(): call pkg_fetch_download_clean_dlcache() post-{archive,Git} download.
Diffstat (limited to 'subr.rtl')
-rw-r--r--subr.rtl/rtl_fetch.subr32
1 files changed, 20 insertions, 12 deletions
diff --git a/subr.rtl/rtl_fetch.subr b/subr.rtl/rtl_fetch.subr
index 1b230b9d..f5410e30 100644
--- a/subr.rtl/rtl_fetch.subr
+++ b/subr.rtl/rtl_fetch.subr
@@ -6,8 +6,12 @@ rtl_fetch_mirror_urls_git() {
local _git_args="${1}" _tgtdir="${2}" _rc=0 _repo_dname="" _subdir="" _url="" _url_spec=""; shift 2;
for _url_spec in "${@}"; do
- _subdir="${_url_spec%=*}"; _url="${_url_spec#*=}"; _url="${_url%@*}";
+ _subdir="${_url_spec%=*}"; _subdir="${_subdir##*/}"; _url="${_url_spec#*=}"; _url="${_url%@*}";
_repo_dname="${_url##*/}"; [ "${_repo_dname%.git}" = "${_repo_dname}" ] && _repo_dname="${_repo_dname}.git";
+
+ if [ ! -e "$(rtl_dirname "${_tgtdir}")" ]; then
+ rtl_fileop mkdir "$(rtl_dirname "${_tgtdir}")";
+ fi;
(set -o errexit -o noglob -o nounset;
rtl_flock_acquire 4 || exit "${?}";
trap "rm -f \"${_tgtdir}/.fetching\"" EXIT;
@@ -23,22 +27,23 @@ rtl_fetch_mirror_urls_git() {
rtlp_fetch_url_git() {
local _cache_dname="${1}" _git_args="${2}" _git_branch="${3}" _mirrors="${4}" _pkg_name="${5}"\
- _subdir="${6}" _tgtdir="${7}" _url="${8}" _clonefl=0 _oldpwd="" _url_base="";
+ _subdir="${6}" _tgtdir="${7}" _url="${8}" _cache_dname_full="" _clonefl=0 _oldpwd="" _url_base="";
+ _cache_dname_full="${_cache_dname}/${_subdir##*/}";
(set -o errexit -o noglob -o nounset;
rtl_flock_acquire 4 || exit "${?}";
- trap "rm -f \"${_cache_dname}/${_subdir%%[/]}.fetching\"" EXIT;
- if [ -e "${_cache_dname}/${_subdir}" ]; then
- (rtl_fileop cd "${_cache_dname}/${_subdir}" &&\
+ trap "rm -f \"${_cache_dname_full%%[/]}.fetching\"" EXIT;
+ if [ -e "${_cache_dname_full}" ]; then
+ (rtl_fileop cd "${_cache_dname_full}" &&\
git pull ${_git_args} origin "${_git_branch:-main}") || return 1;
- (rtl_fileop cd "${_cache_dname}/${_subdir}" &&\
+ (rtl_fileop cd "${_cache_dname_full}" &&\
git submodule update) || return 1;
- else if git clone ${_git_args} -b "${_git_branch:-main}" "${_url}" "${_cache_dname}/${_subdir}"; then
+ else if git clone ${_git_args} -b "${_git_branch:-main}" "${_url}" "${_cache_dname_full}"; then
_clonefl=1;
elif [ "${_mirrors}" = "skip" ]; then
return 1;
else for _url_base in ${_mirrors}; do
- if git clone ${_git_args} -b "${_git_branch:-main}" "${_url_base}/${_pkg_name}/${_url##*/}" "${_cache_dname}/${_subdir}"; then
+ if git clone ${_git_args} -b "${_git_branch:-main}" "${_url_base}/${_pkg_name}/${_url##*/}" "${_cache_dname_full}"; then
_clonefl=1; break;
fi;
done;
@@ -46,19 +51,22 @@ rtlp_fetch_url_git() {
if [ "${_clonefl}" -eq 0 ]; then
return 1;
else if [ -n "${_git_branch}" ]; then
- (rtl_fileop cd "${_cache_dname}/${_subdir}" &&\
+ (rtl_fileop cd "${_cache_dname_full}" &&\
git checkout "${_git_branch}") || return 1;
fi;
- (rtl_fileop cd "${_cache_dname}/${_subdir}" &&\
+ (rtl_fileop cd "${_cache_dname_full}" &&\
git submodule update --init) || return 1;
fi;
fi;
if [ "${_cache_dname}" != "${_tgtdir}" ]; then
_oldpwd="${PWD}"; rtl_fileop cd "${_tgtdir}" || return 1;
rtl_fileop rm "${_tgtdir}/${_subdir}" || return 1;
- rtl_fileop cp "${_cache_dname}/${_subdir}" "${_tgtdir}" || return 1;
+ if [ ! -e "$(rtl_dirname "${_tgtdir}/${_subdir}")" ]; then
+ rtl_fileop mkdir "$(rtl_dirname "${_tgtdir}/${_subdir}")";
+ fi;
+ rtl_fileop cp "${_cache_dname_full}" "${_tgtdir}/${_subdir}" || return 1;
rtl_fileop cd "${_oldpwd}" || return 1;
- fi) 4<>"${_cache_dname}/${_subdir%%[/]}.fetching";
+ fi) 4<>"${_cache_dname_full%%[/]}.fetching";
if [ "${?}" -eq 0 ]; then
cd "$(pwd)";