blob: 17fd1339edf51ddbc32ddee6a4c89601680b7f32 (
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
|
#!/bin/bash
pkgSrcDir="$1"
submoduleDir="$2"
url="$3"
path="${url%% *}"
url="${url#${path} }"
if [ -d "${path}" ] && [ -n "$(ls -A "${path}")" ]; then
git -C "${pkgSrcDir}" submodule update 2>/dev/null || true
exit
fi
if [ ! -f "${path}" ]; then
>&2 echo 'update-submodule needs a commit'
>&2 printf '"%s" ' "$@"
>&2 printf '\n'
exit 1
fi
commit=$(cat "${path}")
rm "${path}"
mkdir -p "${path}"
if [ -d "${submoduleDir}" ]; then
upstream="${submoduleDir}/${path}"
if [ ! -d "${upstream}" ]; then
git clone -q "${url}" "${upstream}"
fi
else
upstream="${pkgSrcDir}/${path}"
fi
git -C "${upstream}" pull -q --rebase
git -C "${upstream}" archive "${commit}" \
| tar -C "${path}" -x
|