star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

commit e0340db452e474ddbf76ea540a68e80c4586be0a
parent bca11972e99625827caec49d4c9efbf75120e6e6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 28 Mar 2024 09:40:34 +0100

Deleting a downloaded file detected as corrupted

When an invalid file is detected, we delete it and its checksum, notify
the error and ask the user to re-execute the make command. The purpose
of this is to help the user understand what's going on (the download
went wrong) and what he can do about it: in this case, simply try to
rerun the make command.

Diffstat:
Msrc/spkg.mk.in | 23+++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/spkg.mk.in b/src/spkg.mk.in @@ -1,18 +1,25 @@ @NAME@: @ARCH@.tgz @ARCH@.sha512sum prefix - @if ! cmp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/@ARCH@.sha512sum"\ - > /dev/null 2>&1; then\ - sha512sum -c @ARCH@.sha512sum;\ - tar -xvf @ARCH@.tgz -C $$(cat .prefix);\ - $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" install "$$(cat .prefix)";\ - cp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/";\ + @if ! cmp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/@ARCH@.sha512sum" \ + > /dev/null 2>&1; then \ + if sha512sum -c @ARCH@.sha512sum; then \ + tar -xvf @ARCH@.tgz -C $$(cat .prefix); \ + $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" install "$$(cat .prefix)"; \ + cp @ARCH@.sha512sum "$$(cat .prefix)/share/spkg/"; \ + else \ + rm -f @ARCH@.tgz; \ + rm -f @ARCH@.sha512sum; \ + >&2 printf "ERROR: %s was corrupted and therefore deleted.\n" @ARCH@.tgz; \ + >&2 printf "Try rerunning make\n"; \ + exit 1; \ + fi \ fi @ARCH@.sha512sum @ARCH@.tgz: curl --fail --retry 3 -O "@PATH@/$@" uninstall_@NAME@: prefix - if [ -f "$$(cat .prefix)/share/spkg/@NAME@.sh" ]; then\ - $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" uninstall "$$(cat .prefix)";\ + if [ -f "$$(cat .prefix)/share/spkg/@NAME@.sh" ]; then \ + $(SHELL) "$$(cat .prefix)/share/spkg/@NAME@.sh" uninstall "$$(cat .prefix)"; \ fi rm -f "$$(cat .prefix)/share/spkg/@ARCH@.sha512sum"