From 80badf81820b00571bdaf9674cbfc2bbc38bd896 Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Mon, 29 Aug 2022 02:09:09 +0700 Subject: [PATCH] Makefile: add iso_checksum target --- Makefile | 7 +++++-- update_iso_checksum.sh | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0d01e60..69600ae 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: alpine-qemu.pkr.hcl +all: iso_checksum alpine-qemu.pkr.hcl alpine-qemu.pkr.hcl: @echo "==> Validating $@ ..." @@ -12,4 +12,7 @@ format: clean: @find ./artifacts/* -prune -exec rm -rfv {} \; -.PHONY: all alpine-qemu.pkr.hcl format clean +iso_checksum: + @find . -name *.pkr.hcl -type f -exec sh update_iso_checksum.sh {} \; + +.PHONY: all alpine-qemu.pkr.hcl format clean iso_checksum diff --git a/update_iso_checksum.sh b/update_iso_checksum.sh index 9b5b93c..e66008c 100644 --- a/update_iso_checksum.sh +++ b/update_iso_checksum.sh @@ -15,6 +15,6 @@ fi iso_url=$(hcl2json "$filename" | jq -r '.variable.iso_url[].default') -printf "Checking sha512sum of \033[1;34m%s\033[0m ...\n" "$iso_url" +printf "Checking sha512sum of \033[1;33m%s\033[0m ...\n" "$iso_url" sha512_sum=$(wget -qO- "${iso_url}".sha512 | awk '{print $1}') -sed -i -E "s|(default = \"sha512:).*\"|\\1$sha512_sum\"|g" "$filename" && echo "ISO checksum updated." +sed -i -E "s|(default = \"sha512:).*\"|\\1$sha512_sum\"|g" "$filename" && printf "ISO checksum updated in \033[1;32m%s\033[0m.\n" "$filename"