Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/tools/bring/installer.om # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / tools / bring / installer.om` 220 lines ยท 5053 bytes Raw Blame History 1 om2 2 note Writes bring.sh, get.sh and withdraw.sh (the same download, check and run; each runs its command). 3 note Manifest: version line, HTTPS receipt URL line, then target TAB HTTPS binary URL TAB sha256 LF. 4 note Targets: Linux-aarch64, Linux-x86_64, Darwin-arm64, Darwin-x86_64. No target implies no release. 5 note Input is streamed, never evaluated as shell. Quotes and control bytes in values are refused. 6 note The download is a loop with no count: 503, 502, 504 and 429 mean the release server is busy (its 7 note cold-build cache answers 503 with Retry-After), so one plain line, a 10 second wait and the same 8 note request again; 200 goes on to the fingerprint check; any other code stops, nothing run. A signal 9 note exits (the EXIT trap removes the download), so Ctrl-C stops the wait. 10 text bringnm "bring.sh" 11 text getnm "get.sh" 12 text wdnm "withdraw.sh" 13 text header "#!/bin/sh\nset -eu\numask 077\n" 14 text vers "version='" 15 text receipt "receipt='" 16 text closeq "'\n" 17 text detect "target=\"$(uname -s)-$(uname -m)\"\ncase \"$target\" in\n" 18 text row1 ")\nurl='" 19 text row2 "'\nexpected='" 20 text row3 "'\n;;\n" 21 text ending "*) echo 'This platform has no Interplane release yet.' >&2; exit 1;;\nesac\nd=$(mktemp -d)\ntrap 'rm -f \"$d/interplane\"; rmdir \"$d\"' EXIT\ntrap 'exit 1' HUP INT TERM\nwhile :; do\n code=$(curl -q --proto '=https' --proto-redir '=https' -sSL -o \"$d/interplane\" -w '%{http_code}' \"$url\") || code=000\n case $code in\n 200) break;;\n 503|502|504|429) echo 'The download server is busy; trying again in 10 seconds.' >&2; sleep 10;;\n *) echo \"The download failed with HTTP $code. Nothing was run.\" >&2; exit 1;;\n esac\ndone\nif command -v sha256sum >/dev/null 2>&1; then\n actual=$(sha256sum \"$d/interplane\")\nelse\n actual=$(shasum -a 256 \"$d/interplane\")\nfi\nactual=${actual%% *}\nprintf 'Interplane %s\\nDownloaded SHA-256: %s\\nExpected SHA-256: %s\\nCompare with: %s\\n' \"$version\" \"$actual\" \"$expected\" \"$receipt\"\n[ \"$actual\" = \"$expected\" ] || { echo 'Fingerprint mismatch. Nothing was run.' >&2; exit 1; }\nchmod 700 \"$d/interplane\"\n" 22 text brun "\"$d/interplane\" bring \"$@\" < /dev/tty\n" 23 text grun "\"$d/interplane\" get \"$@\" < /dev/tty\n" 24 text wrun "\"$d/interplane\" withdraw \"$@\" < /dev/tty\n" 25 text la "Linux-aarch64" 26 text lx "Linux-x86_64" 27 text da "Darwin-arm64" 28 text dx "Darwin-x86_64" 29 text https "https://" 30 text bad "installer: invalid manifest; output scripts removed\n" 31 global outs int 3 32 global ch uchar 1 33 fn fail to void 34 x = write 2 bad 0 len bad 35 for i ulong 3 36 x = fclose get outs i 37 end 38 x = unlink bringnm 0 len bringnm 39 x = unlink getnm 0 len getnm 40 x = unlink wdnm 0 len wdnm 41 exit 1 42 end 43 fn emit s view uchar * to void 44 for i ulong 3 45 p = ulong 0 46 while lt p len s bound `9223372036854775807` 47 r = write get outs i s p sub len s p 48 if le r 0 49 fail 50 end 51 p = add p ulong r 52 end 53 end 54 end 55 fn bytein to long 56 r = read 0 ch 0 1 57 if eq r 0 58 ret -1 59 end 60 if ne r 1 61 fail 62 end 63 ret long get ch 0 64 end 65 fn emitbyte c uchar to void 66 b = new uchar 1 0 67 put b 0 c 68 emit b 69 end 70 fn value delim long url bool to void 71 n = ulong 0 72 while true bound `9223372036854775807` 73 c = bytein 74 if eq c delim 75 break 76 end 77 if or lt c 33 or gt c 126 eq c 39 78 fail 79 end 80 if url 81 if lt n len https 82 if ne c long get https n 83 fail 84 end 85 end 86 end 87 emitbyte uchar c 88 n = add n 1 89 end 90 if eq n 0 91 fail 92 end 93 if url 94 if le n len https 95 fail 96 end 97 end 98 end 99 fn same a view uchar * b view uchar * to bool 100 if ne len a len b 101 ret false 102 end 103 for i ulong len a bound `9223372036854775807` 104 if ne get a i get b i 105 ret false 106 end 107 end 108 ret true 109 end 110 fn target s view uchar * to ulong 111 if same s la 112 ret 1 113 end 114 if same s lx 115 ret 2 116 end 117 if same s da 118 ret 4 119 end 120 if same s dx 121 ret 8 122 end 123 fail 124 ret 0 125 end 126 fn main to int 127 put outs 0 -1 128 put outs 1 -1 129 put outs 2 -1 130 fd = fopen bringnm 0 len bringnm 524481 384 131 if lt fd 0 132 exit 1 133 end 134 put outs 0 int fd 135 fd = fopen getnm 0 len getnm 524481 384 136 if lt fd 0 137 x = fclose get outs 0 138 x = unlink bringnm 0 len bringnm 139 exit 1 140 end 141 put outs 1 int fd 142 fd = fopen wdnm 0 len wdnm 524481 384 143 if lt fd 0 144 x = fclose get outs 0 145 x = fclose get outs 1 146 x = unlink bringnm 0 len bringnm 147 x = unlink getnm 0 len getnm 148 exit 1 149 end 150 put outs 2 int fd 151 emit header 152 emit vers 153 value 10 false 154 emit closeq 155 emit receipt 156 value 10 true 157 emit closeq 158 emit detect 159 buf = new uchar 14 0 160 seen = ulong 0 161 while true bound `9223372036854775807` 162 c = bytein 163 if eq c -1 164 break 165 end 166 n = ulong 0 167 while ne c 9 bound `9223372036854775807` 168 if or lt c 33 ge n len buf 169 fail 170 end 171 put buf n uchar c 172 n = add n 1 173 c = bytein 174 end 175 v = target part buf 0 n 176 if ne and seen v 0 177 fail 178 end 179 seen = or seen v 180 emit part buf 0 n 181 emit row1 182 value 9 true 183 emit row2 184 for i ulong 64 185 c = bytein 186 if not or and ge c 48 le c 57 and ge c 97 le c 102 187 fail 188 end 189 emitbyte uchar c 190 end 191 if ne bytein 10 192 fail 193 end 194 emit row3 195 end 196 if eq seen 0 197 fail 198 end 199 emit ending 200 x = write get outs 0 brun 0 len brun 201 if ne x long len brun 202 fail 203 end 204 x = write get outs 1 grun 0 len grun 205 if ne x long len grun 206 fail 207 end 208 x = write get outs 2 wrun 0 len wrun 209 if ne x long len wrun 210 fail 211 end 212 for i ulong 3 213 x = fsync get outs i 214 if lt x 0 215 fail 216 end 217 x = fclose get outs i 218 end 219 ret 0 220 end