summaryrefslogtreecommitdiff
path: root/update-submodule
diff options
context:
space:
mode:
Diffstat (limited to 'update-submodule')
-rwxr-xr-xupdate-submodule25
1 files changed, 25 insertions, 0 deletions
diff --git a/update-submodule b/update-submodule
new file mode 100755
index 000000000..3bd04b7a4
--- /dev/null
+++ b/update-submodule
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+url="$1"
+pkgSrcDir="${url%% *}"
+url="${url#${path} }"
+submoduleDir="${url%% *}"
+url="${url#${path} }"
+path="${url%% *}"
+url="${url#${path} }"
+
+if [ -n "$(ls -A "${path}")" ]; then
+ git -C "${pkgSrcDir}" submodule update 2>/dev/null || true
+ exit
+fi
+mkdir -p "${path}"
+if [ -n "${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 --ff-only
+git clone -q "${upstream}" "${path}"