summaryrefslogtreecommitdiffstats
path: root/mkosi.images/system/mkosi.sync
diff options
context:
space:
mode:
Diffstat (limited to 'mkosi.images/system/mkosi.sync')
-rwxr-xr-xmkosi.images/system/mkosi.sync21
1 files changed, 17 insertions, 4 deletions
diff --git a/mkosi.images/system/mkosi.sync b/mkosi.images/system/mkosi.sync
index 3e42a09b2c..a4f0ab94ec 100755
--- a/mkosi.images/system/mkosi.sync
+++ b/mkosi.images/system/mkosi.sync
@@ -2,8 +2,21 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
-if [ -z "$(ls --almost-all "pkg/$DISTRIBUTION")" ] || [ -f "pkg/$DISTRIBUTION/.git" ]; then
- PKG_SUBDIR="$(realpath "pkg/$DISTRIBUTION" --relative-to "$PWD")"
- git submodule sync "$PKG_SUBDIR"
- git submodule update --init "$PKG_SUBDIR"
+if ((NO_SYNC)); then
+ exit 0
fi
+
+PKG_SUBDIR="$(realpath --canonicalize-missing "pkg/$DISTRIBUTION" --relative-to "$PWD")"
+
+if [[ -d "$PKG_SUBDIR/.git" ]] && [[ "$(git -C "$PKG_SUBDIR" rev-parse HEAD)" == "$GIT_COMMIT" ]]; then
+ exit 0
+fi
+
+if [[ ! -e "$PKG_SUBDIR" ]] || [[ -z "$(ls --almost-all "$PKG_SUBDIR")" ]]; then
+ git clone "$GIT_URL" --branch "$GIT_BRANCH" "$PKG_SUBDIR"
+else
+ git -C "$PKG_SUBDIR" remote set-url origin "$GIT_URL"
+ git -C "$PKG_SUBDIR" fetch origin "$GIT_BRANCH"
+fi
+
+git -C "$PKG_SUBDIR" -c advice.detachedHead=false checkout "$GIT_COMMIT"