From 986162fb1883cce2ef3692c19272974e4bb28f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Thu, 19 Aug 2021 21:04:15 +0200 Subject: subr.rtl/rtl_fetch_git.subr:{rtlp_fetch_url_git,rtl_fetch_mirror_urls_git}(): correctly reference ${_subdir} when {fetching,mirroring}. subr/pkg_fetch_download.subr:pkg_fetch_download_clean_dlcache(): correctly cleanup dlcache wrt. Git repositories. --- subr/pkg_fetch_download.subr | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'subr') diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr index 0affb358..d6f300d8 100644 --- a/subr/pkg_fetch_download.subr +++ b/subr/pkg_fetch_download.subr @@ -4,24 +4,25 @@ pkg_fetch_download_clean_dlcache() { local _dlcachedir="${1}" _pkg_name="${2}" _pkg_fname="${3}" _pkg_urls_git="${4}"\ - _fname="" _pkg_urls_git_dname=""; + _fname="" _skipfl=0 _url_spec="" _url_subdir=""; - if [ -n "${_pkg_urls_git}" ]; then - _pkg_urls_git_dname="${_pkg_urls_git%%=*}"; - _pkg_urls_git_dname="${_pkg_urls_git_dname##*/}"; - fi; for _fname in $(cd "${_dlcachedir}/${_pkg_name}" && find \ + -maxdepth 1 \ -mindepth 1 \ ${_pkg_fname:+-not -name "${_pkg_fname}"} \ - ${_pkg_fname:+-not -name "${_pkg_fname}.fetched"} \ - ${_pkg_urls_git_dname:+ \ - -not -path "./${_pkg_urls_git_dname}" \ - -not -path "./${_pkg_urls_git_dname}/*" \ - -not -path "./${_pkg_urls_git_dname}.git" \ - -not -path "./${_pkg_urls_git_dname}.git/*"}); do - _fname="${_dlcachedir}/${_pkg_name}/${_fname#./}" - rtl_log_msg notice "Deleting redundant file \`%s' for package \`%s'." "${_fname}" "${_pkg_name}"; - rtl_fileop rm "${_fname}"; + ${_pkg_fname:+-not -name "${_pkg_fname}.fetched"}); do + _fname="${_fname#./}"; _skipfl=0; + for _url_spec in ${_pkg_urls_git}; do + _url_subdir="${_url_spec%%=*}"; _url_subdir="${_url_subdir##*/}"; + if [ "${_fname%.git}" = "${_url_subdir}" ]; then + _skipfl=1; break; + fi; + done; + if [ "${_skipfl}" -eq 0 ]; then + _fname="${_dlcachedir}/${_pkg_name}/${_fname}"; + rtl_log_msg notice "Deleting redundant file \`%s' for package \`%s'." "${_fname}" "${_pkg_name}"; + rtl_fileop rm "${_fname}"; + fi; done; }; -- cgit v1.2.3