blob: 8340ca4f21377df34f0f68e004625c1d8c7230f4 (
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
44
45
46
47
48
49
|
#
# set -o errexit -o noglob are assumed.
#
pkgp_fetch_git() {
local _tgtdir="${1}" _subdir="${2}" _url="${3}" _branch="${4}";
if [ "${ARG_OFFLINE:-0}" -eq 0 ]; then
if [ -e "${DLCACHEDIR}/${_subdir}" ]; then
(ex_build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\
git pull origin "${_branch:-main}");
else
git clone "${_url}" "${DLCACHEDIR}/${_subdir}";
if [ -n "${_branch}" -a \
\( -z "${_branch#main}" \) -a \
\( -z "${_branch#master}" \) ]; then
(ex_build_fileop cd "${DLCACHEDIR}/${_subdir}" &&\
git checkout -b "${_branch}");
fi;
fi;
fi;
ex_build_fileop rm "${_tgtdir}/${_subdir}";
ex_build_fileop cp "${DLCACHEDIR}/${_subdir}" "${_tgtdir}";
};
pkgp_fetch_urls_git() {
local _tgtdir _url_spec _subdir _url _git_branch;
_tgtdir="${1}"; shift;
for _url_spec in "${@}"; do
_subdir="${_url_spec%=*}";
_url="${_url_spec#*=}";
_url="${_url%@*}";
if [ "${_url_spec#*@}" != "${_url_spec}" ]; then
_git_branch=${_url_spec#*@};
fi;
pkgp_fetch_git "${_tgtdir}" "${_subdir}" "${_url}" "${_git_branch}";
done;
};
pkg_fetch_git() {
if [ ${#} -gt 0 ]; then
pkgp_fetch_urls_git "${PKG_BASE_DIR}" "${@}";
else
if [ -n "${PKG_URLS_GIT}" ]; then
pkgp_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT};
fi;
fi;
};
# vim:filetype=sh
|