From 932ff8fb571a45789240ca56528ae985583ecc42 Mon Sep 17 00:00:00 2001 From: BtbN Date: Fri, 26 Jan 2024 23:55:23 +0100 Subject: [PATCH] Reduce cache size further by not adding build dir to it --- generate.sh | 3 +-- scripts.d/50-aom.sh | 2 +- scripts.d/50-aribb24/50-libaribb24.sh | 2 +- scripts.d/50-zvbi.sh | 2 +- util/run_stage.sh | 9 +++++++++ util/vars.sh | 6 +++++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/generate.sh b/generate.sh index f7d6b189c..7b3173f6f 100755 --- a/generate.sh +++ b/generate.sh @@ -39,8 +39,7 @@ exec_dockerstage() { STG="$(ffbuild_dockerdl)" if [[ -n "$STG" ]]; then HASH="$(sha256sum <<<"$STG" | cut -d" " -f1)" - to_df "ADD .cache/downloads/${STAGENAME}_${HASH}.tar.xz /${STAGENAME}" - to_df "WORKDIR /${STAGENAME}" + export SELFCACHE=".cache/downloads/${STAGENAME}_${HASH}.tar.xz" fi ffbuild_dockerstage || exit $? diff --git a/scripts.d/50-aom.sh b/scripts.d/50-aom.sh index b4f91698b..b1f474fa9 100755 --- a/scripts.d/50-aom.sh +++ b/scripts.d/50-aom.sh @@ -8,7 +8,7 @@ ffbuild_enabled() { } ffbuild_dockerstage() { - to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/aom,dst=/patches run_stage /stage.sh" + to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=${SELFCACHE},dst=/cache.tar.xz --mount=src=patches/aom,dst=/patches run_stage /stage.sh" } ffbuild_dockerbuild() { diff --git a/scripts.d/50-aribb24/50-libaribb24.sh b/scripts.d/50-aribb24/50-libaribb24.sh index 8a1453193..72c05e02d 100755 --- a/scripts.d/50-aribb24/50-libaribb24.sh +++ b/scripts.d/50-aribb24/50-libaribb24.sh @@ -8,7 +8,7 @@ ffbuild_enabled() { } ffbuild_dockerstage() { - to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/aribb24,dst=/patches run_stage /stage.sh" + to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=${SELFCACHE},dst=/cache.tar.xz --mount=src=patches/aribb24,dst=/patches run_stage /stage.sh" } ffbuild_dockerbuild() { diff --git a/scripts.d/50-zvbi.sh b/scripts.d/50-zvbi.sh index 7667fcd3c..bb63d5443 100755 --- a/scripts.d/50-zvbi.sh +++ b/scripts.d/50-zvbi.sh @@ -8,7 +8,7 @@ ffbuild_enabled() { } ffbuild_dockerstage() { - to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/zvbi,dst=/patches run_stage /stage.sh" + to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=${SELFCACHE},dst=/cache.tar.xz --mount=src=patches/zvbi,dst=/patches run_stage /stage.sh" } ffbuild_dockerdl() { diff --git a/util/run_stage.sh b/util/run_stage.sh index 8280b02cd..0237c0a0b 100755 --- a/util/run_stage.sh +++ b/util/run_stage.sh @@ -8,6 +8,15 @@ export RAW_LDFLAGS="$LDFLAGS" [[ -n "$STAGE_CXXFLAGS" ]] && export CXXFLAGS="$CXXFLAGS $STAGE_CXXFLAGS" [[ -n "$STAGE_LDFLAGS" ]] && export LDFLAGS="$LDFLAGS $STAGE_LDFLAGS" +if [[ -n "$STAGENAME" && -f /cache.tar.xz ]]; then + mkdir -p "/$STAGENAME" + tar xaf /cache.tar.xz -C "/$STAGENAME" + cd "/$STAGENAME" +elif [[ -n "$STAGENAME" ]]; then + mkdir -p "/$STAGENAME" + cd "/$STAGENAME" +fi + git config --global --add safe.directory "$PWD" source "$1" diff --git a/util/vars.sh b/util/vars.sh index 656ac0625..3ff79bcb1 100644 --- a/util/vars.sh +++ b/util/vars.sh @@ -38,7 +38,11 @@ TARGET_IMAGE="${REGISTRY}/${REPO}/base-${TARGET}:latest" IMAGE="${REGISTRY}/${REPO}/${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}:latest" ffbuild_dockerstage() { - to_df "RUN --mount=src=${SELF},dst=/stage.sh run_stage /stage.sh" + if [[ -n "$SELFCACHE" ]]; then + to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=${SELFCACHE},dst=/cache.tar.xz run_stage /stage.sh" + else + to_df "RUN --mount=src=${SELF},dst=/stage.sh run_stage /stage.sh" + fi } ffbuild_dockerlayer() {