Makefile: add iso_checksum target

This commit is contained in:
Hoang Nguyen 2022-08-29 02:09:09 +07:00
parent 1432187a8f
commit 80badf8182
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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"