Skip to content

Commit

Permalink
Reduce cache size further by not adding build dir to it
Browse files Browse the repository at this point in the history
  • Loading branch information
BtbN committed Jan 26, 2024
1 parent 7f0f519 commit 932ff8f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
3 changes: 1 addition & 2 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $?
Expand Down
2 changes: 1 addition & 1 deletion scripts.d/50-aom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion scripts.d/50-aribb24/50-libaribb24.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion scripts.d/50-zvbi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 9 additions & 0 deletions util/run_stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion util/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 932ff8f

Please sign in to comment.