|
|
@ -22,3 +22,47 @@ |
|
|
|
;; a subprocess, etc. |
|
|
|
;; - On subsequent executions, check the user data directory for any update files, and run those |
|
|
|
;; as a subprocess instead. (In the case where the update is an entire executable). |
|
|
|
|
|
|
|
(import |
|
|
|
;; Cakelisp |
|
|
|
"FileUtilities.cake" |
|
|
|
;; GameLib |
|
|
|
"Introspection.cake" "DynamicArray.cake" "Curl.cake") |
|
|
|
|
|
|
|
(defun auto-update-get-latest-version-metadata (update-cakedata-url (* (const char)) &return bool) |
|
|
|
(when (!= (curl_global_init CURL_GLOBAL_DEFAULT) 0) |
|
|
|
(fprintf stderr "error: Failed to initialize curl\n") |
|
|
|
(return false)) |
|
|
|
|
|
|
|
(var curl (* CURL) (curl_easy_init)) |
|
|
|
(unless curl |
|
|
|
(fprintf stderr "error: Failed to get curl\n") |
|
|
|
(curl_global_cleanup) |
|
|
|
(return false)) |
|
|
|
|
|
|
|
(scope |
|
|
|
(curl_easy_setopt curl CURLOPT_URL update-cakedata-url) |
|
|
|
(curl_easy_setopt curl CURLOPT_SSL_VERIFYPEER 0) ;; TODO TODO TODO REMOVE! |
|
|
|
(curl_easy_setopt curl CURLOPT_SSL_VERIFYHOST 0) ;; TODO TODO TODO REMOVE! |
|
|
|
(var result CURLcode (curl_easy_perform curl)) |
|
|
|
(unless (= CURLE_OK result) |
|
|
|
(fprintf stderr "error: failed to get url %s with result %s\n" |
|
|
|
update-cakedata-url (curl-code-to-string result)) |
|
|
|
(curl_easy_cleanup curl) |
|
|
|
(curl_global_cleanup) |
|
|
|
(return false)) |
|
|
|
(curl_easy_cleanup curl)) |
|
|
|
|
|
|
|
(fflush stdout) |
|
|
|
(curl_global_cleanup) |
|
|
|
(return true)) |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('auto-test |
|
|
|
(c-import "<stdio.h>") |
|
|
|
(defun test--auto-update (&return int) |
|
|
|
(unless (auto-update-get-latest-version-metadata |
|
|
|
"https://localhost:8888/updates/Machsearch/machsearch.cakedata") |
|
|
|
(fprintf stderr "error: expected server to be running before doing this test\n") |
|
|
|
(return 1)) |
|
|
|
(return 0)))) |
|
|
|