From 77fc965cf5c96e3bd2f1149686be590925a148b0 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 30 Aug 2019 17:49:04 +0200 Subject: build-initramfs.sh: fix broken shallow submodule cloning ... the git submodule foreach never worked (?) or at least it got broken somehow. Change to "manually" shallow-cloning the modules, quite ugly but speeds things up quite a bit --- builder/build-initramfs.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 50ce7c1e..28f6b8af 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -38,12 +38,22 @@ if ! [[ -d "$_needed_location" ]]; then "$_git_source" "$_temporary_repository_location" pushd "$_temporary_repository_location" git submodule init - # shellcheck disable=SC2016 - git submodule foreach ' - branch="$(git config --file "$toplevel/.gitmodules" "submodule.$name.branch")" - git clone --depth 1 --branch "$branch" - ' - git submodule update # --remote <- this seems like a bad idea + # try to clone submodules as shallowy as possible, since we cannot just + # use '--depth 1' on submodules residing on non-master branches... + for mod in $(awk '$1 == "[submodule" {gsub(/"|]/,"",$2); print $2}' .gitmodules); do + url="$(git config -f .gitmodules --get submodule.${mod}.url)" + path="$(git config -f .gitmodules --get submodule.${mod}.path)" + branch="$(git config -f .gitmodules --get submodule.${mod}.branch)" + commit="$(git submodule status $path | grep -oE '[0-9a-f]{40}')" + [ "$mod" = "dnbd3" ] && depth_arg=("--shallow-since" "2019-02-12") + [ "$mod" = "rebash" ] && depth_arg=("--shallow-since" "2016-11-30") + [ "$mod" = "qemu-xmount" ] && depth_arg=("--shallow-since" "2016-01-01") + [ "$mod" = "xmount" ] && depth_arg=("--depth" "1") + git clone -n --no-tags "${depth_arg[@]}" --branch "$branch" "$url" "$path" + pushd "$path" + git checkout "$commit" + popd + done # apply patches for submodules git submodule foreach ' for p in $(find ${toplevel}/builder/patches/${path##*/} -type f -name "*.patch" | sort -n); do -- cgit v1.2.3-55-g7522