|
|
@ -42,6 +42,7 @@ |
|
|
|
(def-introspect-struct auto-update-metadata |
|
|
|
name ([] 64 char) |
|
|
|
latest-version int |
|
|
|
changelog (* char) |
|
|
|
downloads (* auto-update-download) (override 'dynarray)) |
|
|
|
|
|
|
|
(def-type-alias-global CURL void) |
|
|
@ -119,6 +120,8 @@ |
|
|
|
;; ./cryptography-cli create-signed-file Machsearch_Linux-x64.zip ~/website/updates/Machsearch/Machsearch_Linux-x64.auto-update |
|
|
|
;; The download will only occur if the latest version is greater than current-application-version. |
|
|
|
;; new-file-to-use-out-buffer will only be set if there was actually a newer file |
|
|
|
;; changelog-out may be null if not provided |
|
|
|
;; Note: Any more args and this should take an args struct, or return the metadata! |
|
|
|
(defun auto-update-download (curl (* CURL) public-key (* (unsigned char)) |
|
|
|
update-cakedata-url (* (const char)) |
|
|
|
current-application-version int |
|
|
@ -126,6 +129,7 @@ |
|
|
|
new-file-to-use-out-buffer (* char) |
|
|
|
new-file-to-use-out-buffer-size size_t |
|
|
|
new-version-out (* int) |
|
|
|
changelog-out (* (* char)) |
|
|
|
&return bool) |
|
|
|
(var update-metadata auto-update-metadata (array 0)) |
|
|
|
(unless (auto-update-get-latest-version-metadata |
|
|
@ -185,9 +189,18 @@ |
|
|
|
(snprintf new-file-to-use-out-buffer new-file-to-use-out-buffer-size "%s/%s" |
|
|
|
version-output-directory (path platform-download > file-to-use)) |
|
|
|
(set (deref new-version-out) (field update-metadata latest-version)) |
|
|
|
(when changelog-out |
|
|
|
(set (deref changelog-out) (field update-metadata changelog)) |
|
|
|
;; Caller takes ownership |
|
|
|
(set (field update-metadata changelog) null)) |
|
|
|
(free-introspect-struct-fields auto-update-metadata--metadata (addr update-metadata) free) |
|
|
|
(return true)) |
|
|
|
|
|
|
|
;; Retain the ability to use another allocator within this module |
|
|
|
(defun auto-update-changelog-free (changelog (* char)) |
|
|
|
(when changelog |
|
|
|
(free changelog))) |
|
|
|
|
|
|
|
(comptime-cond |
|
|
|
('auto-test |
|
|
|
(c-import "<stdio.h>") |
|
|
@ -199,8 +212,8 @@ |
|
|
|
;; zip test.zip TestSerialize.cakedata TestDictionarySerialize.cakedata |
|
|
|
;; ./cryptography-cli create-signed-file test.zip ~/website/updates/Product/Product_Linux-x64.auto-update |
|
|
|
(var macoy-public-key ([] crypto_sign_PUBLICKEYBYTES (unsigned char)) |
|
|
|
(array 0x44 0xb2 0x64 0xe2 0x1b 0x8f 0x1e 0x23 0xc2 0x45 0xfc 0x74 0xa8 0x3c 0x4a 0xe2 0xcd |
|
|
|
0xf6 0x89 0x17 0xbf 0x69 0xf8 0x16 0xb0 0x61 0xc5 0xd5 0xff 0x56 0xae 0xdb)) |
|
|
|
(array 0x8a 0xd0 0x2a 0x05 0x0a 0x57 0xe8 0x4c 0x7c 0x73 0xcf 0xdb 0x26 0xdd 0xb9 0xf7 0x6f 0x92 |
|
|
|
0x05 0xe6 0x5f 0xa5 0xf7 0xf4 0x50 0x87 0x33 0xec 0x5f 0xb0 0x66 0x84)) |
|
|
|
(var update-cakedata-url (* (const char)) |
|
|
|
"https://localhost:8888/updates/Machsearch/machsearch.cakedata") |
|
|
|
(var current-version int 0) |
|
|
@ -222,14 +235,18 @@ |
|
|
|
(curl_easy_setopt curl CURLOPT_SSL_VERIFYHOST 0) |
|
|
|
|
|
|
|
(var new-version int 0) |
|
|
|
(var changelog (* char) null) |
|
|
|
(unless (auto-update-download curl macoy-public-key update-cakedata-url current-version |
|
|
|
output-directory new-file-to-use (sizeof new-file-to-use) |
|
|
|
(addr new-version)) |
|
|
|
(addr new-version) (addr changelog)) |
|
|
|
(curl_easy_cleanup curl) |
|
|
|
(curl_global_cleanup) |
|
|
|
(return 1)) |
|
|
|
|
|
|
|
(fprintf stderr "The update says I should use %s for version %d\n" new-file-to-use new-version) |
|
|
|
(if changelog |
|
|
|
(fprintf stderr "Changelog:\n%s\n" changelog) |
|
|
|
(auto-update-changelog-free changelog)) |
|
|
|
|
|
|
|
(curl_easy_cleanup curl) |
|
|
|
(curl_global_cleanup) |
|
|
|