]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: do a sparse checkout of debian/ubuntu packaging repo
authorLuca Boccassi <bluca@debian.org>
Wed, 5 Jun 2024 23:14:37 +0000 (00:14 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 6 Jun 2024 11:16:03 +0000 (12:16 +0100)
The repository on Salsa includes the full upstream sources, which means
they are duplicated, taking extra space and showing duplicated grep results.
But we only need the debian/ subfolder, so do a sparse clone and checkout.

mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf
mkosi.images/system/mkosi.sync

index abb55884ee5109f6a521511376b23727611f24ad..964ade7325496460192fc04f2f11e5b73e267c51 100644 (file)
@@ -7,6 +7,7 @@ Distribution=|ubuntu
 [Content]
 Environment=
         GIT_URL=https://salsa.debian.org/systemd-team/systemd.git
+        GIT_SUBDIR=debian
         GIT_BRANCH=debian/master
         GIT_COMMIT=5b9607385d49c09440e6e3b35c03ceec73162aec
 
index 6856af7c6b013a441221f194b03942332d7db9de..d21ecd198081cf5b304e0aaa292f4e3508a92719 100755 (executable)
@@ -13,8 +13,21 @@ if [[ -d "$PKG_SUBDIR/.git" ]] && [[ "$(git -C "$PKG_SUBDIR" rev-parse HEAD)" ==
     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" "$PKG_SUBDIR"
+    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"