Blame subr/pkg_fetch_download.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz 10ff54
pkg_fetch_download_dlcache_subdir() {
Lucio Andrés Illanes Albornoz 10ff54
	if [ -n "${PKG_INHERIT_FROM:-}" ]\
Lucio Andrés Illanes Albornoz 10ff54
	&& ! [ -e "${BUILD_DLCACHEDIR}/${PKG_NAME}" ]\
Lucio Andrés Illanes Albornoz 10ff54
	&& ! rtl_fileop ln_symbolic "${PKG_INHERIT_FROM}" "${BUILD_DLCACHEDIR}/${PKG_NAME}"; then
Lucio Andrés Illanes Albornoz 10ff54
		return 1;
Lucio Andrés Illanes Albornoz 10ff54
	elif [ -z "${PKG_INHERIT_FROM:-}" ]\
Lucio Andrés Illanes Albornoz 10ff54
	&& ! [ -e "${BUILD_DLCACHEDIR}/${PKG_NAME}" ]\
Lucio Andrés Illanes Albornoz 10ff54
	&& ! rtl_fileop mkdir "${BUILD_DLCACHEDIR}/${PKG_NAME}"; then
Lucio Andrés Illanes Albornoz 10ff54
		return 1;
Lucio Andrés Illanes Albornoz 10ff54
	else
Lucio Andrés Illanes Albornoz 10ff54
		return 0;
Lucio Andrés Illanes Albornoz 10ff54
	fi;
Lucio Andrés Illanes Albornoz 10ff54
};
Lucio Andrés Illanes Albornoz 10ff54
Lucio Andrés Illanes Albornoz d279a9
pkg_fetch_download() {
Lucio Andrés Illanes Albornoz 10ff54
	local _fname="";
Lucio Andrés Illanes Albornoz 10ff54
Lucio Andrés Illanes Albornoz b63b9b
	if [ "${ARG_FETCH_FORCE:-}" != "offline" ]; then
Lucio Andrés Illanes Albornoz b63b9b
		if [ -n "${PKG_URL:-}" ]; then
Lucio Andrés Illanes Albornoz 10ff54
			if ! pkg_fetch_download_dlcache_subdir; then
Lucio Andrés Illanes Albornoz 10ff54
				return 1;
Lucio Andrés Illanes Albornoz 10ff54
			elif ! rtl_fetch_url_wget	\
Lucio Andrés Illanes Albornoz 10ff54
					"${PKG_URL}" "${PKG_SHA256SUM}" "${BUILD_DLCACHEDIR}/${PKG_NAME}"\
Lucio Andrés Illanes Albornoz 368962
					"${PKG_FNAME}" "${PKG_NAME}" "${PKG_MIRRORS:-}"; then
Lucio Andrés Illanes Albornoz b63b9b
				return 1;
Lucio Andrés Illanes Albornoz 10ff54
			else
Lucio Andrés Illanes Albornoz 10ff54
				for _fname in $(find					\
Lucio Andrés Illanes Albornoz 10ff54
						"${BUILD_DLCACHEDIR}/${PKG_NAME}"	\
Lucio Andrés Illanes Albornoz 10ff54
						-type f					\
Lucio Andrés Illanes Albornoz 10ff54
						-not -name "${PKG_FNAME}"		\
Lucio Andrés Illanes Albornoz 10ff54
						-not -name "${PKG_FNAME}.fetched"); do
Lucio Andrés Illanes Albornoz 10ff54
					rtl_log_msg notice "Deleting redundant file \`%s' for package \`%s'." "${_fname}" "${PKG_NAME}";
Lucio Andrés Illanes Albornoz 10ff54
					rtl_fileop rm "${_fname}";
Lucio Andrés Illanes Albornoz 10ff54
				done;
Lucio Andrés Illanes Albornoz b63b9b
			fi;
Lucio Andrés Illanes Albornoz bf9edf
		fi;
Lucio Andrés Illanes Albornoz b63b9b
		if [ -n "${PKG_URLS_GIT:-}" ]; then
Lucio Andrés Illanes Albornoz 10ff54
			if ! pkg_fetch_download_dlcache_subdir; then
Lucio Andrés Illanes Albornoz 10ff54
				return 1;
Lucio Andrés Illanes Albornoz 10ff54
			elif ! rtl_fetch_urls_git	\
Lucio Andrés Illanes Albornoz 10ff54
					"${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}"\
Lucio Andrés Illanes Albornoz 368962
					"${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" ${PKG_URLS_GIT}; then
Lucio Andrés Illanes Albornoz b63b9b
				return 1;
Lucio Andrés Illanes Albornoz b63b9b
			fi;
Lucio Andrés Illanes Albornoz bf9edf
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
# vim:filetype=sh