]> git.sesse.net Git - stockfish/commitdiff
Better error message on missing curl/wget
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Tue, 18 Aug 2020 16:06:28 +0000 (18:06 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Tue, 18 Aug 2020 17:57:30 +0000 (19:57 +0200)
provide clean error/warning message for missing curl/wget, sha256sum/shasum

fixes https://github.com/official-stockfish/Stockfish/issues/3025

closes https://github.com/official-stockfish/Stockfish/pull/3026

No functional change

src/Makefile

index 1f8ba4559dce1e5c104c8c5b7fc709953e7b9163..a3feb68e3e349957c97155a4543ac9c31e97c5b6 100644 (file)
@@ -669,9 +669,24 @@ net:
        @echo "Default net: $(nnuenet)"
        $(eval nnuedownloadurl := https://tests.stockfishchess.org/api/nn/$(nnuenet))
        $(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -skL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
        @echo "Default net: $(nnuenet)"
        $(eval nnuedownloadurl := https://tests.stockfishchess.org/api/nn/$(nnuenet))
        $(eval curl_or_wget := $(shell if hash curl 2>/dev/null; then echo "curl -skL"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi))
-       @if test -f "$(nnuenet)"; then echo "Already available."; else echo "Downloading $(nnuedownloadurl)"; $(curl_or_wget) $(nnuedownloadurl) > $(nnuenet); fi
+       @if test -f "$(nnuenet)"; then \
+            echo "Already available."; \
+         else \
+            if [ "x$(curl_or_wget)" = "x" ]; then \
+               echo "Automatic download failed: neither curl nor wget is installed. Install one of these tools or download the net manually"; exit 1; \
+            else \
+               echo "Downloading $(nnuedownloadurl)"; $(curl_or_wget) $(nnuedownloadurl) > $(nnuenet);\
+            fi; \
+        fi;
        $(eval shasum_command := $(shell if hash shasum 2>/dev/null; then echo "shasum -a 256 "; elif hash sha256sum 2>/dev/null; then echo "sha256sum "; fi))
        $(eval shasum_command := $(shell if hash shasum 2>/dev/null; then echo "shasum -a 256 "; elif hash sha256sum 2>/dev/null; then echo "sha256sum "; fi))
-       @if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then echo "Failed download or $(nnuenet) corrupted, please delete!"; exit 1; fi
+       @if [ "x$(shasum_command)" != "x" ]; then \
+           if [ "$(nnuenet)" != "nn-"`$(shasum_command) $(nnuenet) | cut -c1-12`".nnue" ]; then \
+                echo "Failed download or $(nnuenet) corrupted, please delete!"; exit 1; \
+            fi \
+         else \
+            echo "shasum / sha256sum not found, skipping net validation"; \
+        fi
+
 
 # clean binaries and objects
 objclean:
 
 # clean binaries and objects
 objclean: