From b5728603d647ba10f80e38226235bd98e9e3e3ec Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Sat, 7 Dec 2024 22:20:01 +0500 Subject: [PATCH] chore: keep downloads in target/ --- .gitignore | 1 + publish.sh | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b5b404ed..d24b7a39 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /tests/target/ *.tmp .idea +/target/ diff --git a/publish.sh b/publish.sh index 8a7dffd9..2bd1d9a4 100755 --- a/publish.sh +++ b/publish.sh @@ -11,6 +11,9 @@ from_linux=eclipse-temurin-17 pattern="# common for all images" +tmpdir=./target +mkdir -p "$tmpdir" + # we need gnu-sed on macos if prefix="$(brew --prefix gnu-sed 2>&1)" && [ -d "${prefix}/libexec/gnubin" ]; then PATH="${prefix}/libexec/gnubin:$PATH" @@ -46,15 +49,15 @@ find . -iname Dockerfile -exec grep -Hl "ARG uri=" {} \; | while read -r file; d uri=$(grep "ARG uri=" "$file" | sed -e 's/ARG uri=//') zip=$(grep "ARG zip=" "$file" | sed -e 's/ARG zip=//') hash=$(grep "ARG hash=" "$file" | sed -e 's/ARG hash=//') - if ! [ -f "/tmp/$zip" ]; then + if ! [ -f "$tmpdir/$zip" ]; then echo "Downloading: $uri/$zip" - curl -sSLf -o "/tmp/$zip" "$uri/$zip" + curl -sSLf -o "$tmpdir/$zip" "$uri/$zip" fi - IFS=" " read -r -a new_hash <<<"$(sha256sum "/tmp/$zip")" + IFS=" " read -r -a new_hash <<<"$(sha256sum "$tmpdir/$zip")" echo "$file $uri/$zip $hash ${new_hash[0]}" sed -i -e "s/ARG hash=.*/ARG hash=${new_hash[0]}/" "$file" echo "Extracting JAVA_HOME from $zip" - if ! java_home="$( (unzip -t "/tmp/$zip" || true) | grep -m 1 "testing: " | sed -e 's#.*testing: \(.*\)/.*#\1#')"; then + if ! java_home="$( (unzip -t "$tmpdir/$zip" || true) | grep -m 1 "testing: " | sed -e 's#.*testing: \(.*\)/.*#\1#')"; then echo >&2 "Failed to extract JAVA_HOME" exit 1 fi