Blame subr.rtl/rtl_fetch.subr

Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
8d7a8a
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
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
e9fa07
rtl_fetch_clean_dlcache() {
e9fa07
	local	_pfdcd_dlcachedir="${1}" _pfdcd_pkg_name="${2}"		\
e9fa07
		_pfdcd_pkg_fname="${3}" _pfdcd_pkg_urls_git="${4}"	\
e9fa07
		_pfdcd_fname="" _pfdcd_skipfl=0 _pfdcd_url_spec=""	\
e9fa07
		_pfdcd_url_subdir="";
Lucio Andrés Illanes Albornoz 368962
e9fa07
	for _pfdcd_fname in	\
e9fa07
			$(cd "${_pfdcd_dlcachedir}/${_pfdcd_pkg_name}" 2>/dev/null &&
e9fa07
			 find -maxdepth 1 -mindepth 1				\
e9fa07
			${_pfdcd_pkg_fname:+-not -name "${_pfdcd_pkg_fname}"}	\
e9fa07
			${_pfdcd_pkg_fname:+-not -name "${_pfdcd_pkg_fname}.fetched"});
e9fa07
	do
e9fa07
		_pfdcd_fname="${_pfdcd_fname#./}"; _pfdcd_skipfl=0;
e9fa07
e9fa07
		for _pfdcd_url_spec in ${_pfdcd_pkg_urls_git}; do
e9fa07
			_pfdcd_url_subdir="${_pfdcd_url_spec%%=*}"; _pfdcd_url_subdir="${_pfdcd_url_subdir##*/}";
e9fa07
			if [ "${_pfdcd_fname%.git}" = "${_pfdcd_url_subdir}" ]; then
e9fa07
				_pfdcd_skipfl=1; break;
Lucio Andrés Illanes Albornoz 689d3c
			fi;
e9fa07
		done;
e9fa07
e9fa07
		if [ "${_pfdcd_skipfl}" -eq 0 ]; then
e9fa07
			_pfdcd_fname="${_pfdcd_dlcachedir}/${_pfdcd_pkg_name}/${_pfdcd_fname}";
e9fa07
			rtl_log_msg "verbose" "${MSG_rtl_fetch_rm_redundant}" "${_pfdcd_fname}" "${_pfdcd_pkg_name}";
e9fa07
			rtl_fileop rm "${_pfdcd_fname}";
e9fa07
		fi;
Lucio Andrés Illanes Albornoz b63b9b
	done;
e9fa07
e9fa07
	return 0;
e9fa07
};
e9fa07
e9fa07
rtl_fetch_dlcache_subdir() {
e9fa07
	local	_rfds_dlcache_dir="${1}" _rfds_name="${2}" _rfds_pkg_inherit_from="${3}";
e9fa07
e9fa07
	if [ "${_rfds_pkg_inherit_from:+1}" = 1 ]\
e9fa07
	&& ! [ -e "${_rfds_dlcache_dir}/${_rfds_name}" ]\
e9fa07
	&& ! rtl_fileop ln_symbolic "${_rfds_pkg_inherit_from}" "${_rfds_dlcache_dir}/${_rfds_name}";
e9fa07
	then
e9fa07
		return 1;
e9fa07
	elif [ "${_rfds_pkg_inherit_from:+1}" != 1 ]\
e9fa07
	&& ! [ -e "${_rfds_dlcache_dir}/${_rfds_name}" ]\
e9fa07
	&& ! rtl_fileop mkdir "${_rfds_dlcache_dir}/${_rfds_name}";
e9fa07
	then
e9fa07
		return 1;
e9fa07
	else
e9fa07
		return 0;
e9fa07
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
64844b
# vim:filetype=sh textwidth=0