Skip to content

Commit 7bddb8f

Browse files
committed
pipelines: fetch: Move cache to subdir
I'd like to allow things other than melange to cache under this directory - sccache in particular. Let's move the fetch cache into its own directory so that it'll be more clear who owns what. Signed-off-by: dann frazier <dann.frazier@chainguard.dev>
1 parent ff4843d commit 7bddb8f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/build/pipelines/fetch.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ inputs:
7171

7272
pipeline:
7373
- runs: |
74-
CACHEDIR="/var/cache/melange"
74+
MELANGE_CACHE_DIR="/var/cache/melange"
75+
FETCH_CACHE_DIR="$[MELANGE_CACHE_DIR}/fetch"
7576
7677
if [ -n "${{inputs.expected-sha512}}" ]; then
7778
hashsize=512
@@ -90,7 +91,7 @@ pipeline:
9091
9192
fn=""
9293
if [ -n "$hashsize" ]; then
93-
fn="${CACHEDIR}/sha${hashsize}:${expected}"
94+
fn="${FETCH_CACHE_DIR}/sha${hashsize}:${expected}"
9495
if [ -f "$fn" ]; then
9596
printf "fetch: found %s in cache\n" "${fn}"
9697
cp "${fn}" "${bn}"
@@ -108,11 +109,12 @@ pipeline:
108109
printf "fetch: Expected sha%s does not match found: %s\n" "${hashsize}" "${sum}"
109110
exit 1
110111
fi
111-
if [ -d "${CACHEDIR}" ]; then
112+
if [ -d "${MELANGE_CACHE_DIR}" ]; then
112113
printf "fetch: Caching %s in %s\n" "${bn}" "${fn}"
114+
mkdir -p "${FETCH_CACHE_DIR}"
113115
cp "${bn}" "${fn}" || { rm -f "${fn}"; printf "fetch: Caching failed\n"; }
114116
else
115-
printf "fetch: %s not available, will not cache %s\n" "${CACHEDIR}" "${bn}"
117+
printf "fetch: %s not available, will not cache %s\n" "${MELANGE_CACHE_DIR}" "${bn}"
116118
fi
117119
else
118120
printf "fetch: Checksum validation skipped\n"

0 commit comments

Comments
 (0)