Skip to content

Commit b99dc98

Browse files
committed
mkosi: do a sparse checkout of debian/ubuntu packaging repo
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.
1 parent 01420b2 commit b99dc98

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Distribution=|ubuntu
77
[Content]
88
Environment=
99
GIT_URL=https://salsa.debian.org/systemd-team/systemd.git
10+
GIT_SUBDIR=debian
1011
GIT_BRANCH=debian/master
1112
GIT_COMMIT=5b9607385d49c09440e6e3b35c03ceec73162aec
1213

mkosi.images/system/mkosi.sync

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,21 @@ if [[ -d "$PKG_SUBDIR/.git" ]] && [[ "$(git -C "$PKG_SUBDIR" rev-parse HEAD)" ==
1313
exit 0
1414
fi
1515

16+
# The repository on Salsa has the full upstream sources, so it's a waste of space to
17+
# redownload and duplicate everything, so do a sparse checkout as we only need the
18+
# packaging directory anyway
19+
if [[ -n "${GIT_SUBDIR:-}" ]]; then
20+
sparse=(--no-checkout --filter=tree:0)
21+
else
22+
sparse=()
23+
fi
24+
1625
if [[ ! -e "$PKG_SUBDIR" ]] || [[ -z "$(ls --almost-all "$PKG_SUBDIR")" ]]; then
17-
git clone "$GIT_URL" --branch "$GIT_BRANCH" "$PKG_SUBDIR"
26+
git clone "$GIT_URL" --branch "$GIT_BRANCH" "${sparse[@]}" "$PKG_SUBDIR"
27+
if [[ -n "${GIT_SUBDIR:-}" ]]; then
28+
# --no-cone is needed to check out only one top-level directory
29+
git -C "$PKG_SUBDIR" sparse-checkout set --no-cone "${GIT_SUBDIR:-}"
30+
fi
1831
else
1932
git -C "$PKG_SUBDIR" remote set-url origin "$GIT_URL"
2033
git -C "$PKG_SUBDIR" fetch origin "$GIT_BRANCH"

0 commit comments

Comments
 (0)