summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-05-18 04:53:31 +0100
committerLeah Rowe <leah@libreboot.org>2024-05-18 04:53:31 +0100
commitf8e3ca3b2246efb5e525bd8f45adafe6a93ed8a0 (patch)
tree633edfffdd5306a9293bc354151cf43cd5b46b69
parentdd851caac9078b621bc03f59f7735bcbbd2e9fb1 (diff)
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>
-rwxr-xr-xbuild3
-rwxr-xr-xinclude/git.sh2
-rwxr-xr-xinclude/option.sh9
3 files changed, 12 insertions, 2 deletions
diff --git a/build b/build
index 565d0ffa..fdb47947 100755
--- a/build
+++ b/build
@@ -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"
}
diff --git a/include/git.sh b/include/git.sh
index 04143540..bc818b19 100755
--- a/include/git.sh
+++ b/include/git.sh
@@ -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" ] && \
diff --git a/include/option.sh b/include/option.sh
index b2e94a6a..1114611b 100755
--- a/include/option.sh
+++ b/include/option.sh
@@ -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"
+}