git.sh: Remove .git if XBMK_RELEASE=y

The build system already deletes .git in all source
directories for each given release, but does so at
the very end; it still does, but now it is deleted
one by one per project, to save space during very
large builds (release sizes vary wildly, depending
on how many trees exist for coreboot basically).

If you're building entirely in tmpfs (as I do), this
could be a problem if you have lots of .git/ directories.

This change reduces disk usage, or in the above example,
memory usage when running the build system from tmpfs.

This complements another recent change, where ROM images
are compressed per target during release builds, rather
than all at the very end of the process. It is part of a
series of optimisations, to reduce the memory and disk
usage of the build system, and to reduce I/O wastage
in general.

This change will not be the last of such changes!

Signed-off-by: Leah Rowe <leah@libreboot.org>
master
Leah Rowe 2024-05-18 04:53:31 +01:00
parent dd851caac9
commit f8e3ca3b22
3 changed files with 12 additions and 2 deletions

3
build
View File

@ -157,8 +157,7 @@ fetch_trees()
[ ! -f "$x" ] || [ -L "$xp" ] || x_ rm -Rf "src/$xp/$xp"
done
find . -name ".git" -exec rm -Rf {} + || $err "$_xm: rm .git"
find . -name ".gitmodules" -exec rm -Rf {} + || $err "$_xm: rm .gitmod"
rmgit .
rm -Rf tmp .git src/u-boot/*/test/lib/strlcat.c || $err "$_xm !rm"
}

View File

@ -111,6 +111,8 @@ git_prep()
fi
fi
[ "$xbmk_release" = "y" ] && rmgit "$tmpgit"
[ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}"
mv "$tmpgit" "$_loc" || $err "git_prep: !mv $tmpgit $_loc"
[ -n "$xtree" ] && [ ! -d "src/coreboot/$xtree" ] && \

View File

@ -178,3 +178,12 @@ mksha512sum()
$err "!sha512sum \"${1}\" > \"${2}\""
) || $err "failed to create tarball checksum"
}
rmgit()
{
(
cd "$1" || $err "!cd gitrepo $1"
find . -name ".git" -exec rm -Rf {} + || $err "!rm .git $1"
find . -name ".gitmodules" -exec rm -Rf {} + || $err "!rm .gitmod $1"
) || $err "Cannot remove .git/.gitmodules in $1"
}