diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:42 +0000 |
commit | 78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch) | |
tree | f515d16b6efd858a9aeb5b0ef5d6f90bf288283d /mkosi.images/system/mkosi.sync | |
parent | Adding debian version 255.5-1. (diff) | |
download | systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mkosi.images/system/mkosi.sync')
-rwxr-xr-x | mkosi.images/system/mkosi.sync | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/mkosi.images/system/mkosi.sync b/mkosi.images/system/mkosi.sync new file mode 100755 index 0000000..d21ecd1 --- /dev/null +++ b/mkosi.images/system/mkosi.sync @@ -0,0 +1,36 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e +set -o nounset + +if ((${NO_SYNC:-0})); 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 + +# 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 + +if [[ ! -e "$PKG_SUBDIR" ]] || [[ -z "$(ls --almost-all "$PKG_SUBDIR")" ]]; then + git clone "$GIT_URL" --branch "$GIT_BRANCH" "${sparse[@]}" "$PKG_SUBDIR" + if [[ -n "${GIT_SUBDIR:-}" ]]; then + # --no-cone is needed to check out only one top-level directory + git -C "$PKG_SUBDIR" sparse-checkout set --no-cone "${GIT_SUBDIR:-}" + fi +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" |