summaryrefslogtreecommitdiffhomepage
path: root/subr.pkg/pkg_fetch_download.subr
blob: 6fedc6b4b142d0912c554c9501d551385f194787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# set +o errexit -o noglob -o nounset is assumed.
#

pkg_fetch_download() {
	local _pfd_group_name="${1}" _pfd_pkg_name="${2}" _pfd_restart_at="${3}";

	if [ "${ARG_FETCH_FORCE:-}" != "offline" ]; then
		if [ "${PKG_URL:+1}" = 1 ]; then
			if ! rtl_fetch_dlcache_subdir				\
					"${BUILD_DLCACHEDIR}" "${PKG_NAME}"	\
					"${PKG_INHERIT_FROM:-}";
			then
				return 1;
			elif ! rtl_fetch_url_wget	\
					"${PKG_URL}" "${PKG_SHA256SUM}" "${BUILD_DLCACHEDIR}/${PKG_NAME}"\
					"${PKG_FNAME}" "${PKG_NAME}" "${PKG_MIRRORS:-}"; then
				return 1;
			fi;
		fi;

		if [ "${PKG_URLS_GIT:+1}" = 1 ]; then
			if ! rtl_fetch_dlcache_subdir				\
					"${BUILD_DLCACHEDIR}" "${PKG_NAME}"	\
					"${PKG_INHERIT_FROM:-}";
			then
				return 1;
			elif ! rtl_fetch_urls_git	\
					"${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}"\
					"${PKG_NAME}" "${PKG_MIRRORS_GIT:-}" ${PKG_URLS_GIT}; then
				return 1;
			fi;
		fi;

		rtl_fetch_clean_dlcache				\
			"${BUILD_DLCACHEDIR}" "${PKG_NAME}"	\
			"${PKG_FNAME:-}" "${PKG_URLS_GIT:-}";
	fi;

	return 0;
};

# vim:filetype=sh textwidth=0