summaryrefslogtreecommitdiffstats
path: root/mkosi.images/build/mkosi.sync
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:20:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:20:44 +0000
commitca5ecaae7a8f75e18ba85b29839752da76e3b7b9 (patch)
tree6f62ddc7fbe8ae132441a0b25e2a76e423e66e9f /mkosi.images/build/mkosi.sync
parentReleasing progress-linux version 256.2-1~progress7.99u1. (diff)
downloadsystemd-ca5ecaae7a8f75e18ba85b29839752da76e3b7b9.tar.xz
systemd-ca5ecaae7a8f75e18ba85b29839752da76e3b7b9.zip
Merging upstream version 256.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mkosi.images/build/mkosi.sync')
-rwxr-xr-xmkosi.images/build/mkosi.sync51
1 files changed, 51 insertions, 0 deletions
diff --git a/mkosi.images/build/mkosi.sync b/mkosi.images/build/mkosi.sync
new file mode 100755
index 0000000..febe893
--- /dev/null
+++ b/mkosi.images/build/mkosi.sync
@@ -0,0 +1,51 @@
+#!/bin/bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -e
+set -o nounset
+
+if ((${NO_SYNC:-0})) || ((${NO_BUILD:-0})); then
+ exit 0
+fi
+
+if [[ -d "pkg/$PKG_SUBDIR/.git" ]]; then
+ if [[ "$(git -C "pkg/$PKG_SUBDIR" rev-parse HEAD)" == "$GIT_COMMIT" ]]; then
+ exit 0
+ fi
+
+ if ! git -C "pkg/$PKG_SUBDIR" show-ref --quiet "origin/$GIT_BRANCH"; then
+ git -C "pkg/$PKG_SUBDIR" remote set-url origin "$GIT_URL"
+ git -C "pkg/$PKG_SUBDIR" fetch origin "$GIT_BRANCH"
+ fi
+
+ # If work is being done on the packaging rules in a separate branch, don't touch the checkout.
+ if ! git -C "pkg/$PKG_SUBDIR" merge-base --is-ancestor HEAD "origin/$GIT_BRANCH"; then
+ EXIT_STATUS=$?
+ if [[ $EXIT_STATUS -eq 1 ]]; then
+ exit 0
+ else
+ exit $EXIT_STATUS
+ fi
+ fi
+fi
+
+if [[ ! -e "pkg/$PKG_SUBDIR" ]] || [[ -z "$(ls --almost-all "pkg/$PKG_SUBDIR")" ]]; then
+ # The repository on Salsa has the full upstream sources, so it's a waste of
+ # space to redownload and duplicate everything, so do a sparse checkout as
+ # we only need the packaging directory anyway.
+ if [[ -n "${GIT_SUBDIR:-}" ]]; then
+ sparse=(--no-checkout --filter=tree:0)
+ else
+ sparse=()
+ fi
+
+ git clone "$GIT_URL" --branch "$GIT_BRANCH" "${sparse[@]}" "pkg/$PKG_SUBDIR"
+ if [[ -n "${GIT_SUBDIR:-}" ]]; then
+ # --no-cone is needed to check out only one top-level directory
+ git -C "pkg/$PKG_SUBDIR" sparse-checkout set --no-cone "${GIT_SUBDIR:-}"
+ fi
+else
+ git -C "pkg/$PKG_SUBDIR" remote set-url origin "$GIT_URL"
+ git -C "pkg/$PKG_SUBDIR" fetch origin "$GIT_BRANCH"
+fi
+
+git -C "pkg/$PKG_SUBDIR" -c advice.detachedHead=false checkout "$GIT_COMMIT"