omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / si / architecture / tools / candidate / check_pins.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note check_pins: do the pins of a candidate manifest equal what the pinned code consumes? |
| 3 | note Seeded native Omega port of scripts/check_candidate_pins.sh (aien-architecture #316). |
| 4 | note usage: check_pins <manifest.toml> exit 0 = every pin agrees, 1 = any mismatch or read failure |
| 5 | note check_candidate proves each pinned commit exists; this program proves the pins agree with each |
| 6 | note other. It reads the lock files of the pinned commits and compares: |
| 7 | note sovereign-core omega.lock = [commits] omega |
| 8 | note sovereign-core Cargo.lock aien-protocols rev = [commits] aien-protocols |
| 9 | note sovereign-core Cargo.lock crumb-spec rev = [contracts] crumb-spec |
| 10 | note sovereign-core Cargo.lock spark-crumbs rev = [contracts] spark-crumbs |
| 11 | note omega physics.lock = [commits] physics (when pinned) |
| 12 | note omega aienos.lock = [commits] aienos |
| 13 | note every [consumed_pins] key it knows = the value read from its lock file |
| 14 | note A Cargo.lock package with more than one git revision, or a lock file that cannot be read, fails. |
| 15 | note A Cargo.lock source counts under the repo's name or its -mv name (aien-dev/<name>-mv, issue 815, |
| 16 | note sovereign-core #906); both names are one pin, so two revisions across them are "several". |
| 17 | note A contract the manifest states as built in-tree, contracts.<name>-consumed = "in-tree" (sovereign-core |
| 18 | note #892, mirroring its [pins] "in-tree"), must have a path package <name> (no source line) in Cargo.lock |
| 19 | note and no git source under either name; its [contracts] commit is then not compared with Cargo.lock. |
| 20 | note Files come from `gh api -H "Accept: application/vnd.github.raw" repos/aien-dev/<repo>/contents/<path>?ref=<sha>`, |
| 21 | note or from the command in CAND_FILE_AT (run as: $CAND_FILE_AT <repo> <sha> <path>, printing the file). |
| 22 | note Same lines, same order and same exit code as the bash it replaces: the [consumed_pins] walk |
| 23 | note follows a bash 5.2 associative array (FNV-1 hash, 1024 buckets, x4 growth, newest first in a |
| 24 | note bucket). Children run through /bin/sh with this process's environment replayed from a memfd. |
| 25 | note Capacities (exit 70 beyond them): a manifest or a fetched file of 999000 bytes, 4096 keys, |
| 26 | note 256 git revisions of one package in Cargo.lock, a child argument list of 4096 bytes. |
| 27 | note See tools/candidate/README.md for the parsed subset and the named limits. |
| 28 | |
| 29 | text tsh "set -a\n. \"$1\"\nset +a\nshift\nexec \"$@\"\n" |
| 30 | text tm "usage: \n <manifest.toml>\nFAIL: \nOK: \nmanifest lacks commits.aien-sovereign-core or commits.omega\nsovereign-core omega.lock -> commits.omega\n: not pinned in the manifest\n = \n: manifest pins \n, the code consumes \ncannot read omega.lock at aien-sovereign-core \nsovereign-core Cargo.lock \n -> \n: git revision \ncannot read Cargo.lock at aien-sovereign-core \nomega aienos.lock -> commits.aienos\ncannot read aienos.lock at omega \nomega physics.lock -> commits.physics\ncannot read physics.lock at omega \nSKIP: consumed_pins.\n (not read by this script)\nconsumed_pins.\n: its lock file could not be read\nPINS AGREE: \nPINS DISAGREE: \nnone\nseveral:\ncheck_pins: input over capacity\n = in-tree (a path package with no git source, built from aien-sovereign-core \n)\n = in-tree, but Cargo.lock has a git source for it at \n = in-tree, but Cargo.lock has no path package named \n = \"\n\": the only accepted value is \"in-tree\"\n (Cargo.lock has a path package \n: the crate is built in-tree, which this manifest does not state with \n = \"in-tree\")\n" |
| 31 | text tk "commits.aien-sovereign-core\ncommits.omega\ncommits.aienos\ncommits.physics\ncommits.aien-protocols\ncontracts.crumb-spec\ncontracts.spark-crumbs\naien-protocols\ncrumb-spec\nspark-crumbs\nomega.lock\nCargo.lock\nphysics.lock\naienos.lock\nargus.lock\naien-sovereign-core\nomega\nconsumed_pins.\nsovereign-core-omega-lock\nsovereign-core-cargo-lock-aien-protocols\nomega-physics-lock\nomega-aienos-lock\nomega-argus-lock\nCAND_FILE_AT\n/bin/sh\n-c\nsh\n/proc/self/fd/\ngh\napi\n-H\nAccept: application/vnd.github.raw\nrepos/aien-dev/\n/contents/\n?ref=\nenvfile\nsource = \"git+https://github.com/aien-dev/\n.git\n-mv\ncontracts.crumb-spec-consumed\ncontracts.spark-crumbs-consumed\nin-tree\n[[package]]\nname = \nsource = \n" |
| 32 | |
| 33 | const CAP ulong 999000 |
| 34 | const MASK ulong 4294967295 |
| 35 | |
| 36 | global src uchar 999128 |
| 37 | global srcn ulong 1 |
| 38 | global pool uchar 1998000 |
| 39 | global pooln ulong 1 |
| 40 | global poolm ulong 1 |
| 41 | global kof ulong 8192 |
| 42 | global kln ulong 8192 |
| 43 | global vof ulong 8192 |
| 44 | global vln ulong 8192 |
| 45 | global khs ulong 8192 |
| 46 | global knx ulong 8192 |
| 47 | global kbk ulong 8192 |
| 48 | global kb2 ulong 4096 |
| 49 | global nen ulong 2 |
| 50 | global nbk ulong 2 |
| 51 | global secb uchar 8192 |
| 52 | global secl ulong 1 |
| 53 | global arg uchar 8192 |
| 54 | global argl ulong 1 |
| 55 | global obuf uchar 1100000 |
| 56 | global obl ulong 1 |
| 57 | global fpath uchar 4096 |
| 58 | global fpl ulong 1 |
| 59 | global a0 uchar 4096 |
| 60 | global a0l ulong 1 |
| 61 | global stb uchar 128 |
| 62 | global failf ulong 1 |
| 63 | global pk uchar 4096 |
| 64 | global pkn ulong 1 |
| 65 | global pkc ulong 1 |
| 66 | global ebuf uchar 65600 |
| 67 | global ewb uchar 131200 |
| 68 | global ev uchar 65600 |
| 69 | global evl ulong 1 |
| 70 | global efd long 1 |
| 71 | global epath uchar 32 |
| 72 | global epl ulong 1 |
| 73 | global status uchar 4 |
| 74 | global rmode ulong 1 |
| 75 | global nbuf uchar 24 |
| 76 | global pfd uchar 8 |
| 77 | global cap uchar 999000 |
| 78 | global capn ulong 1 |
| 79 | global lab uchar 8192 |
| 80 | global labl ulong 1 |
| 81 | global lk uchar 240 |
| 82 | global lkl ulong 6 |
| 83 | global revs uchar 10240 |
| 84 | global revn ulong 1 |
| 85 | global sevl ulong 1 |
| 86 | global fla ulong 1 |
| 87 | |
| 88 | note ---- text tables ---- |
| 89 | |
| 90 | fn om i ulong to void |
| 91 | s = ulong 0 |
| 92 | k = ulong 0 |
| 93 | while lt k i bound 8192 |
| 94 | if eq get tm s 10 |
| 95 | k = add k 1 |
| 96 | end |
| 97 | s = add s 1 |
| 98 | end |
| 99 | n = get obl 0 |
| 100 | while ne get tm s 10 bound 8191 |
| 101 | put obuf n get tm s |
| 102 | n = add n 1 |
| 103 | s = add s 1 |
| 104 | end |
| 105 | put obl 0 n |
| 106 | end |
| 107 | |
| 108 | fn kp i ulong to void |
| 109 | s = ulong 0 |
| 110 | k = ulong 0 |
| 111 | while lt k i bound 8192 |
| 112 | if eq get tk s 10 |
| 113 | k = add k 1 |
| 114 | end |
| 115 | s = add s 1 |
| 116 | end |
| 117 | n = ulong 0 |
| 118 | while ne get tk add s n 10 bound 8191 |
| 119 | put arg n get tk add s n |
| 120 | n = add n 1 |
| 121 | end |
| 122 | put argl 0 n |
| 123 | end |
| 124 | |
| 125 | fn over to void |
| 126 | put obl 0 0 |
| 127 | om 27 |
| 128 | oc 10 |
| 129 | oflush 2 |
| 130 | exit 70 |
| 131 | end |
| 132 | |
| 133 | note ---- output line ---- |
| 134 | |
| 135 | fn oc c uchar to void |
| 136 | n = get obl 0 |
| 137 | put obuf n c |
| 138 | put obl 0 add n 1 |
| 139 | end |
| 140 | |
| 141 | fn oflush fd int to void |
| 142 | r = write fd obuf 0 get obl 0 |
| 143 | put obl 0 0 |
| 144 | end |
| 145 | |
| 146 | fn opool o ulong n ulong to void |
| 147 | b = get obl 0 |
| 148 | for i ulong n |
| 149 | put obuf add b i get pool add o i |
| 150 | end |
| 151 | put obl 0 add b n |
| 152 | end |
| 153 | |
| 154 | fn oarg to void |
| 155 | b = get obl 0 |
| 156 | for i ulong get argl 0 |
| 157 | put obuf add b i get arg i |
| 158 | end |
| 159 | put obl 0 add b get argl 0 |
| 160 | end |
| 161 | |
| 162 | fn ofile to void |
| 163 | b = get obl 0 |
| 164 | for i ulong get fpl 0 |
| 165 | put obuf add b i get fpath i |
| 166 | end |
| 167 | put obl 0 add b get fpl 0 |
| 168 | end |
| 169 | |
| 170 | fn okey x ulong to void |
| 171 | opool get kof x get kln x |
| 172 | end |
| 173 | |
| 174 | fn oval e long to void |
| 175 | if ge e 0 |
| 176 | opool get vof ulong e get vln ulong e |
| 177 | end |
| 178 | end |
| 179 | |
| 180 | fn onum v ulong to void |
| 181 | d = ulong 0 |
| 182 | while gt v 0 bound 24 |
| 183 | put nbuf d uchar rem v 10 |
| 184 | v = div v 10 |
| 185 | d = add d 1 |
| 186 | end |
| 187 | if eq d 0 |
| 188 | put nbuf 0 0 |
| 189 | d = ulong 1 |
| 190 | end |
| 191 | for i ulong d |
| 192 | oc add 48 get nbuf sub sub d 1 i |
| 193 | end |
| 194 | end |
| 195 | |
| 196 | fn fail0 to void |
| 197 | put obl 0 0 |
| 198 | om 2 |
| 199 | end |
| 200 | |
| 201 | fn fail1 to void |
| 202 | oc 10 |
| 203 | oflush 2 |
| 204 | put failf 0 1 |
| 205 | end |
| 206 | |
| 207 | |
| 208 | note ---- key table: bash 5.2 associative array order ---- |
| 209 | |
| 210 | fn hashk to ulong |
| 211 | h = ulong 2166136261 |
| 212 | for j ulong get argl 0 |
| 213 | h = and mul h 16777619 MASK |
| 214 | h = xor h ulong get arg j |
| 215 | end |
| 216 | ret h |
| 217 | end |
| 218 | |
| 219 | fn treset t ulong to void |
| 220 | put nbk t 1024 |
| 221 | put nen t 0 |
| 222 | for b ulong 1024 |
| 223 | put kbk add mul t 4096 b 0 |
| 224 | end |
| 225 | end |
| 226 | |
| 227 | fn keyeq x ulong to bool |
| 228 | n = get argl 0 |
| 229 | if ne get kln x n |
| 230 | ret false |
| 231 | end |
| 232 | o = get kof x |
| 233 | for i ulong n |
| 234 | if ne get pool add o i get arg i |
| 235 | ret false |
| 236 | end |
| 237 | end |
| 238 | ret true |
| 239 | end |
| 240 | |
| 241 | fn tfind t ulong to long |
| 242 | h = hashk |
| 243 | b = and h sub get nbk t 1 |
| 244 | e = get kbk add mul t 4096 b |
| 245 | while ne e 0 bound 8192 |
| 246 | e = sub e 1 |
| 247 | if eq get khs e h |
| 248 | if keyeq e |
| 249 | ret long e |
| 250 | end |
| 251 | end |
| 252 | e = get knx e |
| 253 | end |
| 254 | ret -1 |
| 255 | end |
| 256 | |
| 257 | fn pcopy o ulong n ulong to void |
| 258 | p = get pooln 0 |
| 259 | if gt add p n len pool |
| 260 | over |
| 261 | end |
| 262 | for i ulong n |
| 263 | put pool add p i get src add o i |
| 264 | end |
| 265 | put pooln 0 add p n |
| 266 | end |
| 267 | |
| 268 | fn acopy to void |
| 269 | p = get pooln 0 |
| 270 | n = get argl 0 |
| 271 | if gt add p n len pool |
| 272 | over |
| 273 | end |
| 274 | for i ulong n |
| 275 | put pool add p i get arg i |
| 276 | end |
| 277 | put pooln 0 add p n |
| 278 | end |
| 279 | |
| 280 | fn tlink t ulong x ulong h ulong to void |
| 281 | b = add mul t 4096 and h sub get nbk t 1 |
| 282 | put knx x get kbk b |
| 283 | put kbk b add x 1 |
| 284 | end |
| 285 | |
| 286 | fn rehash t ulong j ulong to void |
| 287 | e = get kb2 j |
| 288 | while ne e 0 bound 8192 |
| 289 | x = sub e 1 |
| 290 | n = get knx x |
| 291 | tlink t x get khs x |
| 292 | e = n |
| 293 | end |
| 294 | end |
| 295 | |
| 296 | fn tgrow t ulong to void |
| 297 | nb = get nbk t |
| 298 | if gt mul nb 4 4096 |
| 299 | over |
| 300 | end |
| 301 | tb = mul t 4096 |
| 302 | for b ulong nb |
| 303 | put kb2 b get kbk add tb b |
| 304 | put kbk add tb b 0 |
| 305 | end |
| 306 | put nbk t mul nb 4 |
| 307 | for j ulong nb |
| 308 | rehash t j |
| 309 | end |
| 310 | end |
| 311 | |
| 312 | fn tset t ulong vs ulong vn ulong to void |
| 313 | e = tfind t |
| 314 | if ge e 0 |
| 315 | x = ulong e |
| 316 | put vof x get pooln 0 |
| 317 | put vln x vn |
| 318 | pcopy vs vn |
| 319 | ret |
| 320 | end |
| 321 | if ge get nen t mul get nbk t 2 |
| 322 | tgrow t |
| 323 | end |
| 324 | n = get nen t |
| 325 | if ge n 4096 |
| 326 | over |
| 327 | end |
| 328 | x = add mul t 4096 n |
| 329 | put kof x get pooln 0 |
| 330 | put kln x get argl 0 |
| 331 | acopy |
| 332 | put vof x get pooln 0 |
| 333 | put vln x vn |
| 334 | pcopy vs vn |
| 335 | h = hashk |
| 336 | put khs x h |
| 337 | tlink t x h |
| 338 | put nen t add n 1 |
| 339 | end |
| 340 | |
| 341 | note ---- the line parser: key = "value" [# comment], [section] [# comment], the rest ignored ---- |
| 342 | |
| 343 | fn isws c uchar to bool |
| 344 | ret or eq c 32 and ge c 9 le c 13 |
| 345 | end |
| 346 | |
| 347 | fn iskc c uchar to bool |
| 348 | d = or and ge c 48 le c 57 and ge c 65 le c 90 |
| 349 | d = or d and ge c 97 le c 122 |
| 350 | ret or d or eq c 95 or eq c 46 eq c 45 |
| 351 | end |
| 352 | |
| 353 | fn skipws i ulong e ulong to ulong |
| 354 | while lt i e bound 999999 |
| 355 | if not isws get src i |
| 356 | ret i |
| 357 | end |
| 358 | i = add i 1 |
| 359 | end |
| 360 | ret i |
| 361 | end |
| 362 | |
| 363 | fn skipkc i ulong e ulong to ulong |
| 364 | while lt i e bound 999999 |
| 365 | if not iskc get src i |
| 366 | ret i |
| 367 | end |
| 368 | i = add i 1 |
| 369 | end |
| 370 | ret i |
| 371 | end |
| 372 | |
| 373 | fn notq i ulong e ulong to bool |
| 374 | ret and lt i e ne get src i 34 |
| 375 | end |
| 376 | |
| 377 | fn skipnq i ulong e ulong to ulong |
| 378 | while notq i e bound 999999 |
| 379 | i = add i 1 |
| 380 | end |
| 381 | ret i |
| 382 | end |
| 383 | |
| 384 | fn mkkey ks ulong kn ulong to void |
| 385 | n = get secl 0 |
| 386 | if gt add n kn 8191 |
| 387 | over |
| 388 | end |
| 389 | for i ulong n |
| 390 | put arg i get secb i |
| 391 | end |
| 392 | for i ulong kn |
| 393 | put arg add n i get src add ks i |
| 394 | end |
| 395 | put argl 0 add n kn |
| 396 | end |
| 397 | |
| 398 | fn kvline t ulong ls ulong z ulong to bool |
| 399 | i = skipws ls z |
| 400 | ks = i |
| 401 | i = skipkc i z |
| 402 | kn = sub i ks |
| 403 | if eq kn 0 |
| 404 | ret false |
| 405 | end |
| 406 | i = skipws i z |
| 407 | if ge i z |
| 408 | ret false |
| 409 | end |
| 410 | if ne get src i 61 |
| 411 | ret false |
| 412 | end |
| 413 | i = skipws add i 1 z |
| 414 | if ge i z |
| 415 | ret false |
| 416 | end |
| 417 | if ne get src i 34 |
| 418 | ret false |
| 419 | end |
| 420 | vs = add i 1 |
| 421 | i = skipnq vs z |
| 422 | if ge i z |
| 423 | ret false |
| 424 | end |
| 425 | vn = sub i vs |
| 426 | i = skipws add i 1 z |
| 427 | if lt i z |
| 428 | if ne get src i 35 |
| 429 | ret false |
| 430 | end |
| 431 | end |
| 432 | mkkey ks kn |
| 433 | tset t vs vn |
| 434 | ret true |
| 435 | end |
| 436 | |
| 437 | fn setsec s ulong j ulong to void |
| 438 | n = sub j s |
| 439 | if gt n 8191 |
| 440 | over |
| 441 | end |
| 442 | for i ulong n |
| 443 | put secb i get src add s add 1 i |
| 444 | end |
| 445 | put secb sub n 1 46 |
| 446 | put secl 0 n |
| 447 | end |
| 448 | |
| 449 | fn secline ls ulong z ulong to void |
| 450 | s = skipws ls z |
| 451 | if ge s z |
| 452 | ret |
| 453 | end |
| 454 | if eq get src s 35 |
| 455 | ret |
| 456 | end |
| 457 | e = z |
| 458 | while gt e s bound 999999 |
| 459 | if not isws get src sub e 1 |
| 460 | break |
| 461 | end |
| 462 | e = sub e 1 |
| 463 | end |
| 464 | if ne get src s 91 |
| 465 | ret |
| 466 | end |
| 467 | j = skipkc add s 1 e |
| 468 | if eq j add s 1 |
| 469 | ret |
| 470 | end |
| 471 | if ge j e |
| 472 | ret |
| 473 | end |
| 474 | if ne get src j 93 |
| 475 | ret |
| 476 | end |
| 477 | i = skipws add j 1 e |
| 478 | if lt i e |
| 479 | if ne get src i 35 |
| 480 | ret |
| 481 | end |
| 482 | end |
| 483 | setsec s j |
| 484 | end |
| 485 | |
| 486 | fn parse t ulong to void |
| 487 | put secl 0 0 |
| 488 | ls = ulong 0 |
| 489 | n = get srcn 0 |
| 490 | while lt ls n bound 999999 |
| 491 | z = ls |
| 492 | while and lt z n ne get src z 10 bound 999999 |
| 493 | z = add z 1 |
| 494 | end |
| 495 | if ge z n |
| 496 | break |
| 497 | end |
| 498 | if not kvline t ls z |
| 499 | secline ls z |
| 500 | end |
| 501 | ls = add z 1 |
| 502 | end |
| 503 | end |
| 504 | |
| 505 | note ---- files ---- |
| 506 | |
| 507 | fn slurpf fd int to void |
| 508 | t = ulong 0 |
| 509 | while true bound 999999 |
| 510 | room = sub CAP t |
| 511 | if eq room 0 |
| 512 | over |
| 513 | end |
| 514 | r = read fd src t room |
| 515 | if lt r 0 |
| 516 | break |
| 517 | end |
| 518 | if eq r 0 |
| 519 | break |
| 520 | end |
| 521 | t = add t ulong r |
| 522 | end |
| 523 | put srcn 0 t |
| 524 | end |
| 525 | |
| 526 | fn dropnul to void |
| 527 | n = get srcn 0 |
| 528 | w = ulong 0 |
| 529 | for i ulong n |
| 530 | c = get src i |
| 531 | if ne c 0 |
| 532 | put src w c |
| 533 | w = add w 1 |
| 534 | end |
| 535 | end |
| 536 | put srcn 0 w |
| 537 | end |
| 538 | |
| 539 | fn loadm to void |
| 540 | put srcn 0 0 |
| 541 | fd = fopen fpath 0 get fpl 0 0 0 |
| 542 | if lt fd 0 |
| 543 | ret |
| 544 | end |
| 545 | slurpf int fd |
| 546 | r = fclose int fd |
| 547 | dropnul |
| 548 | end |
| 549 | |
| 550 | fn isregf to bool |
| 551 | r = stat fpath 0 get fpl 0 stb 0 128 |
| 552 | if lt r 0 |
| 553 | ret false |
| 554 | end |
| 555 | m = ulong get stb 16 |
| 556 | m = or m shl ulong get stb 17 8 |
| 557 | ret eq and m 61440 32768 |
| 558 | end |
| 559 | |
| 560 | note ---- children: /bin/sh replays the environment from a memfd, then exec "$@" ---- |
| 561 | |
| 562 | fn pk0 to void |
| 563 | put pkn 0 2 |
| 564 | put pkc 0 0 |
| 565 | end |
| 566 | |
| 567 | fn pka to void |
| 568 | n = get pkn 0 |
| 569 | m = get argl 0 |
| 570 | if gt add n add 2 m 4096 |
| 571 | over |
| 572 | end |
| 573 | put pk n uchar rem m 256 |
| 574 | put pk add n 1 uchar div m 256 |
| 575 | for i ulong m |
| 576 | put pk add n add 2 i get arg i |
| 577 | end |
| 578 | put pkn 0 add n add 2 m |
| 579 | c = add get pkc 0 1 |
| 580 | put pkc 0 c |
| 581 | put pk 0 uchar rem c 256 |
| 582 | put pk 1 uchar div c 256 |
| 583 | end |
| 584 | |
| 585 | fn pkt i ulong to void |
| 586 | kp i |
| 587 | pka |
| 588 | end |
| 589 | |
| 590 | fn pksh to void |
| 591 | pk0 |
| 592 | pkt 24 |
| 593 | pkt 25 |
| 594 | for i ulong len tsh |
| 595 | put arg i get tsh i |
| 596 | end |
| 597 | put argl 0 len tsh |
| 598 | pka |
| 599 | pkt 26 |
| 600 | for i ulong get epl 0 |
| 601 | put arg i get epath i |
| 602 | end |
| 603 | put argl 0 get epl 0 |
| 604 | pka |
| 605 | end |
| 606 | |
| 607 | fn envname l ulong to bool |
| 608 | if eq l 0 |
| 609 | ret false |
| 610 | end |
| 611 | for i ulong l |
| 612 | c = get ebuf i |
| 613 | ok = or and ge c 65 le c 90 and ge c 97 le c 122 |
| 614 | ok = or ok eq c 95 |
| 615 | if gt i 0 |
| 616 | ok = or ok and ge c 48 le c 57 |
| 617 | end |
| 618 | if not ok |
| 619 | ret false |
| 620 | end |
| 621 | end |
| 622 | ret true |
| 623 | end |
| 624 | |
| 625 | fn envone l ulong to void |
| 626 | e = ulong 0 |
| 627 | while and lt e l ne get ebuf e 61 bound 65536 |
| 628 | e = add e 1 |
| 629 | end |
| 630 | if eq e l |
| 631 | ret |
| 632 | end |
| 633 | if not envname e |
| 634 | ret |
| 635 | end |
| 636 | for i ulong e |
| 637 | put ewb i get ebuf i |
| 638 | end |
| 639 | n = e |
| 640 | put ewb n 61 |
| 641 | put ewb add n 1 39 |
| 642 | n = add n 2 |
| 643 | i = add e 1 |
| 644 | while lt i l bound 65536 |
| 645 | c = get ebuf i |
| 646 | if eq c 39 |
| 647 | put ewb n 39 |
| 648 | put ewb add n 1 92 |
| 649 | put ewb add n 2 39 |
| 650 | put ewb add n 3 39 |
| 651 | n = add n 4 |
| 652 | else |
| 653 | put ewb n c |
| 654 | n = add n 1 |
| 655 | end |
| 656 | i = add i 1 |
| 657 | end |
| 658 | put ewb n 39 |
| 659 | put ewb add n 1 10 |
| 660 | n = add n 2 |
| 661 | r = write int get efd 0 ewb 0 n |
| 662 | end |
| 663 | |
| 664 | fn envinit to void |
| 665 | kp 35 |
| 666 | f = memfd arg 0 get argl 0 0 |
| 667 | if lt f 0 |
| 668 | over |
| 669 | end |
| 670 | put efd 0 f |
| 671 | for i ulong ulong envcnt |
| 672 | l = envread i ebuf 0 65536 |
| 673 | if gt l 0 |
| 674 | envone ulong l |
| 675 | end |
| 676 | end |
| 677 | kp 27 |
| 678 | n = get argl 0 |
| 679 | for i ulong n |
| 680 | put epath i get arg i |
| 681 | end |
| 682 | v = ulong f |
| 683 | d = ulong 0 |
| 684 | while gt v 0 bound 24 |
| 685 | put nbuf d uchar rem v 10 |
| 686 | v = div v 10 |
| 687 | d = add d 1 |
| 688 | end |
| 689 | if eq d 0 |
| 690 | put nbuf 0 0 |
| 691 | d = ulong 1 |
| 692 | end |
| 693 | for i ulong d |
| 694 | put epath add n i add 48 get nbuf sub sub d 1 i |
| 695 | end |
| 696 | put epl 0 add n d |
| 697 | end |
| 698 | |
| 699 | note the value of the environment variable named by arg, into ev; -1 when unset |
| 700 | fn getenv to long |
| 701 | n = get argl 0 |
| 702 | for i ulong ulong envcnt |
| 703 | l = envread i ebuf 0 65536 |
| 704 | if gt l long n |
| 705 | if envpre n |
| 706 | ret envtake n ulong l |
| 707 | end |
| 708 | end |
| 709 | end |
| 710 | ret -1 |
| 711 | end |
| 712 | |
| 713 | fn envtake n ulong l ulong to long |
| 714 | m = sub l add n 1 |
| 715 | o = add n 1 |
| 716 | for j ulong m |
| 717 | put ev j get ebuf add o j |
| 718 | end |
| 719 | put evl 0 m |
| 720 | ret long m |
| 721 | end |
| 722 | |
| 723 | fn envpre n ulong to bool |
| 724 | for i ulong n |
| 725 | if ne get ebuf i get arg i |
| 726 | ret false |
| 727 | end |
| 728 | end |
| 729 | ret eq get ebuf n 61 |
| 730 | end |
| 731 | |
| 732 | note split ev on space, tab and newline, one packet record per word |
| 733 | fn pkwords to void |
| 734 | i = ulong 0 |
| 735 | n = get evl 0 |
| 736 | while lt i n bound 65536 |
| 737 | c = get ev i |
| 738 | if or eq c 32 or eq c 9 eq c 10 |
| 739 | i = add i 1 |
| 740 | else |
| 741 | w = ulong 0 |
| 742 | while and lt i n wordc get ev i bound 65536 |
| 743 | put arg w get ev i |
| 744 | w = add w 1 |
| 745 | i = add i 1 |
| 746 | end |
| 747 | put argl 0 w |
| 748 | pka |
| 749 | end |
| 750 | end |
| 751 | end |
| 752 | |
| 753 | fn wordc c uchar to bool |
| 754 | ret not or eq c 32 or eq c 9 eq c 10 |
| 755 | end |
| 756 | |
| 757 | fn child to void |
| 758 | w = int get pfd 4 |
| 759 | w = or w shl int get pfd 5 8 |
| 760 | r = dupfd w 1 0 |
| 761 | r = fclose w |
| 762 | r = fclose int get pfd 0 |
| 763 | r = execprog pk 0 get pkn 0 |
| 764 | exit 127 |
| 765 | end |
| 766 | |
| 767 | note read the child's stdout into cap; trailing newlines and NUL bytes dropped as $(...) does |
| 768 | fn slurpc fd int to void |
| 769 | t = ulong 0 |
| 770 | while true bound 999999 |
| 771 | room = sub CAP t |
| 772 | if eq room 0 |
| 773 | over |
| 774 | end |
| 775 | r = read fd cap t room |
| 776 | if le r 0 |
| 777 | break |
| 778 | end |
| 779 | t = add t ulong r |
| 780 | end |
| 781 | w = ulong 0 |
| 782 | for i ulong t |
| 783 | c = get cap i |
| 784 | if ne c 0 |
| 785 | put cap w c |
| 786 | w = add w 1 |
| 787 | end |
| 788 | end |
| 789 | while gt w 0 bound 999999 |
| 790 | if ne get cap sub w 1 10 |
| 791 | break |
| 792 | end |
| 793 | w = sub w 1 |
| 794 | end |
| 795 | put capn 0 w |
| 796 | end |
| 797 | |
| 798 | fn run to long |
| 799 | r = pipefds pfd 0 8 0 |
| 800 | if lt r 0 |
| 801 | ret -1 |
| 802 | end |
| 803 | pid = fork |
| 804 | if lt pid 0 |
| 805 | ret -1 |
| 806 | end |
| 807 | if eq pid 0 |
| 808 | child |
| 809 | end |
| 810 | w = int get pfd 4 |
| 811 | w = or w shl int get pfd 5 8 |
| 812 | r = fclose w |
| 813 | rd = int get pfd 0 |
| 814 | slurpc rd |
| 815 | r = fclose rd |
| 816 | r = waitpid int pid status 0 4 0 |
| 817 | if ne r pid |
| 818 | ret -1 |
| 819 | end |
| 820 | s = long get status 0 |
| 821 | s = or s shl long get status 1 8 |
| 822 | if eq and s 127 0 |
| 823 | ret shr s 8 |
| 824 | end |
| 825 | ret add 128 and s 127 |
| 826 | end |
| 827 | |
| 828 | |
| 829 | note ---- value and key helpers ---- |
| 830 | |
| 831 | fn kfind t ulong i ulong to long |
| 832 | kp i |
| 833 | ret tfind t |
| 834 | end |
| 835 | |
| 836 | fn vlen e long to ulong |
| 837 | if lt e 0 |
| 838 | ret 0 |
| 839 | end |
| 840 | ret get vln ulong e |
| 841 | end |
| 842 | |
| 843 | fn kpapp i ulong to void |
| 844 | s = ulong 0 |
| 845 | k = ulong 0 |
| 846 | while lt k i bound 8192 |
| 847 | if eq get tk s 10 |
| 848 | k = add k 1 |
| 849 | end |
| 850 | s = add s 1 |
| 851 | end |
| 852 | n = get argl 0 |
| 853 | while ne get tk s 10 bound 8191 |
| 854 | put arg n get tk s |
| 855 | n = add n 1 |
| 856 | s = add s 1 |
| 857 | end |
| 858 | put argl 0 n |
| 859 | end |
| 860 | |
| 861 | fn avapp e long to void |
| 862 | x = ulong e |
| 863 | o = get vof x |
| 864 | n = get vln x |
| 865 | b = get argl 0 |
| 866 | if gt add b n 8191 |
| 867 | over |
| 868 | end |
| 869 | for j ulong n |
| 870 | put arg add b j get pool add o j |
| 871 | end |
| 872 | put argl 0 add b n |
| 873 | end |
| 874 | |
| 875 | fn pkval e long to void |
| 876 | put argl 0 0 |
| 877 | avapp e |
| 878 | pka |
| 879 | end |
| 880 | |
| 881 | note does the key of entry x start with key-table entry i |
| 882 | fn haspre x ulong i ulong to bool |
| 883 | kp i |
| 884 | n = get argl 0 |
| 885 | if lt get kln x n |
| 886 | ret false |
| 887 | end |
| 888 | o = get kof x |
| 889 | for j ulong n |
| 890 | if ne get pool add o j get arg j |
| 891 | ret false |
| 892 | end |
| 893 | end |
| 894 | ret true |
| 895 | end |
| 896 | |
| 897 | note does the key of entry x, after its first 14 bytes (consumed_pins.), equal key-table entry i |
| 898 | fn keytail x ulong i ulong to bool |
| 899 | kp i |
| 900 | n = get argl 0 |
| 901 | if ne get kln x add n 14 |
| 902 | ret false |
| 903 | end |
| 904 | o = add get kof x 14 |
| 905 | for j ulong n |
| 906 | if ne get pool add o j get arg j |
| 907 | ret false |
| 908 | end |
| 909 | end |
| 910 | ret true |
| 911 | end |
| 912 | |
| 913 | fn oname x ulong to void |
| 914 | opool add get kof x 14 sub get kln x 14 |
| 915 | end |
| 916 | |
| 917 | note ---- the label of a comparison ---- |
| 918 | |
| 919 | fn lab0 to void |
| 920 | put labl 0 0 |
| 921 | end |
| 922 | |
| 923 | fn labm i ulong to void |
| 924 | b = get obl 0 |
| 925 | om i |
| 926 | n = get obl 0 |
| 927 | l = get labl 0 |
| 928 | for j ulong sub n b |
| 929 | put lab add l j get obuf add b j |
| 930 | end |
| 931 | put labl 0 add l sub n b |
| 932 | put obl 0 b |
| 933 | end |
| 934 | |
| 935 | fn labk i ulong to void |
| 936 | kp i |
| 937 | l = get labl 0 |
| 938 | for j ulong get argl 0 |
| 939 | put lab add l j get arg j |
| 940 | end |
| 941 | put labl 0 add l get argl 0 |
| 942 | end |
| 943 | |
| 944 | fn labx x ulong to void |
| 945 | l = get labl 0 |
| 946 | o = get kof x |
| 947 | n = sub get kln x 14 |
| 948 | for j ulong n |
| 949 | put lab add l j get pool add o add 14 j |
| 950 | end |
| 951 | put labl 0 add l n |
| 952 | end |
| 953 | |
| 954 | fn olab to void |
| 955 | b = get obl 0 |
| 956 | for j ulong get labl 0 |
| 957 | put obuf add b j get lab j |
| 958 | end |
| 959 | put obl 0 add b get labl 0 |
| 960 | end |
| 961 | |
| 962 | note ---- lock slots: 0 sovereign omega.lock, 1 Cargo.lock aien-protocols, 2 omega physics.lock, |
| 963 | note 3 omega aienos.lock, 4 omega argus.lock, 5 the last Cargo.lock revision ---- |
| 964 | |
| 965 | fn slotok s ulong to bool |
| 966 | ret eq get lkl s 40 |
| 967 | end |
| 968 | |
| 969 | fn oslot s ulong to void |
| 970 | b = get obl 0 |
| 971 | for j ulong 40 |
| 972 | put obuf add b j get lk add mul s 40 j |
| 973 | end |
| 974 | put obl 0 add b 40 |
| 975 | end |
| 976 | |
| 977 | fn vslot e long s ulong to bool |
| 978 | if ne vlen e 40 |
| 979 | ret false |
| 980 | end |
| 981 | o = get vof ulong e |
| 982 | for j ulong 40 |
| 983 | if ne get pool add o j get lk add mul s 40 j |
| 984 | ret false |
| 985 | end |
| 986 | end |
| 987 | ret true |
| 988 | end |
| 989 | |
| 990 | fn slotcp a ulong b ulong to void |
| 991 | for j ulong 40 |
| 992 | put lk add mul b 40 j get lk add mul a 40 j |
| 993 | end |
| 994 | put lkl b get lkl a |
| 995 | end |
| 996 | |
| 997 | note same <label in lab> <pinned entry e> <consumed slot s> |
| 998 | fn same e long s ulong to void |
| 999 | if eq vlen e 0 |
| 1000 | fail0 |
| 1001 | olab |
| 1002 | om 6 |
| 1003 | fail1 |
| 1004 | ret |
| 1005 | end |
| 1006 | if vslot e s |
| 1007 | put obl 0 0 |
| 1008 | om 3 |
| 1009 | olab |
| 1010 | om 7 |
| 1011 | oslot s |
| 1012 | oc 10 |
| 1013 | oflush 1 |
| 1014 | ret |
| 1015 | end |
| 1016 | fail0 |
| 1017 | olab |
| 1018 | om 8 |
| 1019 | oval e |
| 1020 | om 9 |
| 1021 | oslot s |
| 1022 | fail1 |
| 1023 | end |
| 1024 | |
| 1025 | note ---- file_at <repo key i> <sha entry e> <path key j>: the file into cap, exit status returned ---- |
| 1026 | |
| 1027 | fn fileat i ulong e long j ulong to long |
| 1028 | pksh |
| 1029 | kp 23 |
| 1030 | l = getenv |
| 1031 | if gt l 0 |
| 1032 | pkwords |
| 1033 | pkt i |
| 1034 | pkval e |
| 1035 | pkt j |
| 1036 | else |
| 1037 | pkt 28 |
| 1038 | pkt 29 |
| 1039 | pkt 30 |
| 1040 | pkt 31 |
| 1041 | kp 32 |
| 1042 | kpapp i |
| 1043 | kpapp 33 |
| 1044 | kpapp j |
| 1045 | kpapp 34 |
| 1046 | avapp e |
| 1047 | pka |
| 1048 | end |
| 1049 | ret run |
| 1050 | end |
| 1051 | |
| 1052 | fn ishex c uchar to bool |
| 1053 | ret or and ge c 48 le c 57 and ge c 97 le c 102 |
| 1054 | end |
| 1055 | |
| 1056 | note the first line of cap that is not blank and not a comment, trimmed: a..b (b = a when none) |
| 1057 | fn firstln to ulong |
| 1058 | n = get capn 0 |
| 1059 | ls = ulong 0 |
| 1060 | while lt ls n bound 999999 |
| 1061 | z = ls |
| 1062 | while and lt z n ne get cap z 10 bound 999999 |
| 1063 | z = add z 1 |
| 1064 | end |
| 1065 | a = ls |
| 1066 | while and lt a z isws get cap a bound 999999 |
| 1067 | a = add a 1 |
| 1068 | end |
| 1069 | b = z |
| 1070 | while gt b a bound 999999 |
| 1071 | if not isws get cap sub b 1 |
| 1072 | break |
| 1073 | end |
| 1074 | b = sub b 1 |
| 1075 | end |
| 1076 | if lt a b |
| 1077 | if ne get cap a 35 |
| 1078 | put fla 0 a |
| 1079 | ret b |
| 1080 | end |
| 1081 | end |
| 1082 | ls = add z 1 |
| 1083 | end |
| 1084 | put fla 0 0 |
| 1085 | ret 0 |
| 1086 | end |
| 1087 | |
| 1088 | note read_lock: the file's pin into slot s; false (slot empty) when unreadable or not 40 hex |
| 1089 | fn readlock i ulong e long j ulong s ulong to bool |
| 1090 | put lkl s 0 |
| 1091 | if ne fileat i e j 0 |
| 1092 | ret false |
| 1093 | end |
| 1094 | b = firstln |
| 1095 | a = get fla 0 |
| 1096 | if ne sub b a 40 |
| 1097 | ret false |
| 1098 | end |
| 1099 | for k ulong 40 |
| 1100 | if not ishex get cap add a k |
| 1101 | ret false |
| 1102 | end |
| 1103 | put lk add mul s 40 k get cap add a k |
| 1104 | end |
| 1105 | put lkl s 40 |
| 1106 | ret true |
| 1107 | end |
| 1108 | |
| 1109 | note ---- cargo_rev: the git revisions of package i in the Cargo.lock held in cap ---- |
| 1110 | |
| 1111 | note does cap[p..z) start with key-table entry i; the length matched (0 when not) |
| 1112 | fn capk p ulong z ulong i ulong to ulong |
| 1113 | kp i |
| 1114 | n = get argl 0 |
| 1115 | if gt add p n z |
| 1116 | ret 0 |
| 1117 | end |
| 1118 | for j ulong n |
| 1119 | if ne get cap add p j get arg j |
| 1120 | ret 0 |
| 1121 | end |
| 1122 | end |
| 1123 | ret n |
| 1124 | end |
| 1125 | |
| 1126 | fn linepre ls ulong z ulong i ulong to bool |
| 1127 | n = capk ls z 36 |
| 1128 | if eq n 0 |
| 1129 | ret false |
| 1130 | end |
| 1131 | p = add ls n |
| 1132 | n = capk p z i |
| 1133 | if eq n 0 |
| 1134 | ret false |
| 1135 | end |
| 1136 | p = add p n |
| 1137 | p = add p capk p z 38 |
| 1138 | p = add p capk p z 37 |
| 1139 | if ge p z |
| 1140 | ret false |
| 1141 | end |
| 1142 | c = get cap p |
| 1143 | ret or eq c 63 eq c 35 |
| 1144 | end |
| 1145 | |
| 1146 | fn hexat p ulong z ulong to bool |
| 1147 | if gt add p 42 z |
| 1148 | ret false |
| 1149 | end |
| 1150 | if ne get cap p 35 |
| 1151 | ret false |
| 1152 | end |
| 1153 | if ne get cap add p 41 34 |
| 1154 | ret false |
| 1155 | end |
| 1156 | for k ulong 40 |
| 1157 | if not ishex get cap add p add 1 k |
| 1158 | ret false |
| 1159 | end |
| 1160 | end |
| 1161 | ret true |
| 1162 | end |
| 1163 | |
| 1164 | fn revadd p ulong to void |
| 1165 | n = get revn 0 |
| 1166 | if ge n 256 |
| 1167 | over |
| 1168 | end |
| 1169 | for k ulong 40 |
| 1170 | put revs add mul n 40 k get cap add p add 1 k |
| 1171 | end |
| 1172 | put revn 0 add n 1 |
| 1173 | end |
| 1174 | |
| 1175 | fn scanhex ls ulong z ulong to void |
| 1176 | i = ls |
| 1177 | while lt i z bound 999999 |
| 1178 | if hexat i z |
| 1179 | revadd i |
| 1180 | i = add i 42 |
| 1181 | else |
| 1182 | i = add i 1 |
| 1183 | end |
| 1184 | end |
| 1185 | end |
| 1186 | |
| 1187 | fn revless a ulong b ulong to bool |
| 1188 | for k ulong 40 |
| 1189 | x = get revs add mul a 40 k |
| 1190 | y = get revs add mul b 40 k |
| 1191 | if ne x y |
| 1192 | ret lt x y |
| 1193 | end |
| 1194 | end |
| 1195 | ret false |
| 1196 | end |
| 1197 | |
| 1198 | fn revswap a ulong b ulong to void |
| 1199 | for k ulong 40 |
| 1200 | x = get revs add mul a 40 k |
| 1201 | put revs add mul a 40 k get revs add mul b 40 k |
| 1202 | put revs add mul b 40 k x |
| 1203 | end |
| 1204 | end |
| 1205 | |
| 1206 | fn reveq a ulong b ulong to bool |
| 1207 | for k ulong 40 |
| 1208 | if ne get revs add mul a 40 k get revs add mul b 40 k |
| 1209 | ret false |
| 1210 | end |
| 1211 | end |
| 1212 | ret true |
| 1213 | end |
| 1214 | |
| 1215 | note sort the revisions and drop repeats; revn becomes the unique count |
| 1216 | fn revsort to void |
| 1217 | n = get revn 0 |
| 1218 | for i ulong n |
| 1219 | j = i |
| 1220 | while gt j 0 bound 256 |
| 1221 | if not revless j sub j 1 |
| 1222 | break |
| 1223 | end |
| 1224 | revswap j sub j 1 |
| 1225 | j = sub j 1 |
| 1226 | end |
| 1227 | end |
| 1228 | u = ulong 0 |
| 1229 | for i ulong n |
| 1230 | if eq i 0 |
| 1231 | u = ulong 1 |
| 1232 | else |
| 1233 | if not reveq i sub u 1 |
| 1234 | if ne i u |
| 1235 | revswap u i |
| 1236 | end |
| 1237 | u = add u 1 |
| 1238 | end |
| 1239 | end |
| 1240 | end |
| 1241 | put revn 0 u |
| 1242 | end |
| 1243 | |
| 1244 | fn cargorev i ulong to bool |
| 1245 | put revn 0 0 |
| 1246 | n = get capn 0 |
| 1247 | ls = ulong 0 |
| 1248 | while lt ls n bound 999999 |
| 1249 | z = ls |
| 1250 | while and lt z n ne get cap z 10 bound 999999 |
| 1251 | z = add z 1 |
| 1252 | end |
| 1253 | if linepre ls z i |
| 1254 | scanhex ls z |
| 1255 | end |
| 1256 | ls = add z 1 |
| 1257 | end |
| 1258 | revsort |
| 1259 | if ne get revn 0 1 |
| 1260 | ret false |
| 1261 | end |
| 1262 | for k ulong 40 |
| 1263 | put lk add 200 k get revs k |
| 1264 | end |
| 1265 | put lkl 5 40 |
| 1266 | ret true |
| 1267 | end |
| 1268 | |
| 1269 | fn orevs to void |
| 1270 | n = get revn 0 |
| 1271 | if eq n 0 |
| 1272 | om 25 |
| 1273 | ret |
| 1274 | end |
| 1275 | om 26 |
| 1276 | for i ulong n |
| 1277 | if gt i 0 |
| 1278 | oc 32 |
| 1279 | end |
| 1280 | b = get obl 0 |
| 1281 | for k ulong 40 |
| 1282 | put obuf add b k get revs add mul i 40 k |
| 1283 | end |
| 1284 | put obl 0 add b 40 |
| 1285 | end |
| 1286 | end |
| 1287 | |
| 1288 | note one Cargo.lock pair: package key p, manifest key q |
| 1289 | fn cargopair p ulong q ulong to void |
| 1290 | if intree p q |
| 1291 | ret |
| 1292 | end |
| 1293 | if cargorev p |
| 1294 | lab0 |
| 1295 | labm 11 |
| 1296 | labk p |
| 1297 | labm 12 |
| 1298 | labk q |
| 1299 | same kfind 0 q 5 |
| 1300 | if eq p 7 |
| 1301 | slotcp 5 1 |
| 1302 | end |
| 1303 | ret |
| 1304 | end |
| 1305 | fail0 |
| 1306 | om 11 |
| 1307 | kp p |
| 1308 | oarg |
| 1309 | om 13 |
| 1310 | orevs |
| 1311 | if ge q 5 |
| 1312 | treehint p add q 34 |
| 1313 | end |
| 1314 | fail1 |
| 1315 | end |
| 1316 | |
| 1317 | note ---- in-tree contracts: contracts.<name>-consumed = "in-tree" (key q + 34), Cargo.lock path packages ---- |
| 1318 | |
| 1319 | note the revisions in revs, separated by a space |
| 1320 | fn orevl to void |
| 1321 | for i ulong get revn 0 |
| 1322 | if gt i 0 |
| 1323 | oc 32 |
| 1324 | end |
| 1325 | b = get obl 0 |
| 1326 | for k ulong 40 |
| 1327 | put obuf add b k get revs add mul i 40 k |
| 1328 | end |
| 1329 | put obl 0 add b 40 |
| 1330 | end |
| 1331 | end |
| 1332 | |
| 1333 | note does the value of entry e equal key-table entry i |
| 1334 | fn valis e long i ulong to bool |
| 1335 | kp i |
| 1336 | n = get argl 0 |
| 1337 | if ne vlen e n |
| 1338 | ret false |
| 1339 | end |
| 1340 | o = get vof ulong e |
| 1341 | for j ulong n |
| 1342 | if ne get pool add o j get arg j |
| 1343 | ret false |
| 1344 | end |
| 1345 | end |
| 1346 | ret true |
| 1347 | end |
| 1348 | |
| 1349 | note is cap[ls..z) the name line of package p: `name = "` p, then `"` or the line end (awk sub, as Core's gate) |
| 1350 | fn nameis ls ulong z ulong p ulong to bool |
| 1351 | n = capk ls z 43 |
| 1352 | if eq n 0 |
| 1353 | ret false |
| 1354 | end |
| 1355 | q = add ls n |
| 1356 | if ge q z |
| 1357 | ret false |
| 1358 | end |
| 1359 | if ne get cap q 34 |
| 1360 | ret false |
| 1361 | end |
| 1362 | q = add q 1 |
| 1363 | m = capk q z p |
| 1364 | if eq m 0 |
| 1365 | ret false |
| 1366 | end |
| 1367 | q = add q m |
| 1368 | if ge q z |
| 1369 | ret true |
| 1370 | end |
| 1371 | ret eq get cap q 34 |
| 1372 | end |
| 1373 | |
| 1374 | note does the Cargo.lock in cap hold a [[package]] named p with no source line (a path package) |
| 1375 | note Same state machine as the awk of sovereign-core scripts/check-release-candidate.sh (ce792cf5): a line |
| 1376 | note starting [[package]] closes the block before it, `name = ` sets the name, `source = ` marks a source. |
| 1377 | fn pathpkg p ulong to bool |
| 1378 | n = get capn 0 |
| 1379 | ls = ulong 0 |
| 1380 | nm = false |
| 1381 | sr = false |
| 1382 | while lt ls n bound 999999 |
| 1383 | z = ls |
| 1384 | while and lt z n ne get cap z 10 bound 999999 |
| 1385 | z = add z 1 |
| 1386 | end |
| 1387 | if gt capk ls z 42 0 |
| 1388 | if and nm not sr |
| 1389 | ret true |
| 1390 | end |
| 1391 | nm = false |
| 1392 | sr = false |
| 1393 | else |
| 1394 | if gt capk ls z 43 0 |
| 1395 | nm = nameis ls z p |
| 1396 | end |
| 1397 | if gt capk ls z 44 0 |
| 1398 | sr = true |
| 1399 | end |
| 1400 | end |
| 1401 | ls = add z 1 |
| 1402 | end |
| 1403 | ret and nm not sr |
| 1404 | end |
| 1405 | |
| 1406 | note an undeclared contract with no git revision: name a path package, the in-tree form not stated |
| 1407 | fn treehint p ulong c ulong to void |
| 1408 | if gt get revn 0 0 |
| 1409 | ret |
| 1410 | end |
| 1411 | if not pathpkg p |
| 1412 | ret |
| 1413 | end |
| 1414 | om 34 |
| 1415 | kp p |
| 1416 | oarg |
| 1417 | om 35 |
| 1418 | kp c |
| 1419 | oarg |
| 1420 | om 36 |
| 1421 | end |
| 1422 | |
| 1423 | note the manifest states contract q as built in-tree: check it here and return true; false when not stated |
| 1424 | fn intree p ulong q ulong to bool |
| 1425 | if lt q 5 |
| 1426 | ret false |
| 1427 | end |
| 1428 | c = add q 34 |
| 1429 | e = kfind 0 c |
| 1430 | if lt e 0 |
| 1431 | ret false |
| 1432 | end |
| 1433 | itcheck p c e |
| 1434 | ret true |
| 1435 | end |
| 1436 | |
| 1437 | fn itbad c ulong e long to void |
| 1438 | fail0 |
| 1439 | kp c |
| 1440 | oarg |
| 1441 | om 32 |
| 1442 | oval e |
| 1443 | om 33 |
| 1444 | fail1 |
| 1445 | end |
| 1446 | |
| 1447 | fn itfail p ulong c ulong to void |
| 1448 | fail0 |
| 1449 | om 11 |
| 1450 | kp p |
| 1451 | oarg |
| 1452 | om 12 |
| 1453 | kp c |
| 1454 | oarg |
| 1455 | end |
| 1456 | |
| 1457 | fn itcheck p ulong c ulong e long to void |
| 1458 | if not valis e 41 |
| 1459 | itbad c e |
| 1460 | ret |
| 1461 | end |
| 1462 | r = cargorev p |
| 1463 | if gt get revn 0 0 |
| 1464 | itfail p c |
| 1465 | om 30 |
| 1466 | orevl |
| 1467 | fail1 |
| 1468 | ret |
| 1469 | end |
| 1470 | if not pathpkg p |
| 1471 | itfail p c |
| 1472 | om 31 |
| 1473 | kp p |
| 1474 | oarg |
| 1475 | fail1 |
| 1476 | ret |
| 1477 | end |
| 1478 | put obl 0 0 |
| 1479 | om 3 |
| 1480 | om 11 |
| 1481 | kp p |
| 1482 | oarg |
| 1483 | om 12 |
| 1484 | kp c |
| 1485 | oarg |
| 1486 | om 28 |
| 1487 | oval kfind 0 0 |
| 1488 | om 29 |
| 1489 | oc 10 |
| 1490 | oflush 1 |
| 1491 | end |
| 1492 | |
| 1493 | fn consumed1 x ulong to void |
| 1494 | s = ulong 6 |
| 1495 | if keytail x 18 |
| 1496 | s = ulong 0 |
| 1497 | end |
| 1498 | if keytail x 19 |
| 1499 | s = ulong 1 |
| 1500 | end |
| 1501 | if keytail x 20 |
| 1502 | s = ulong 2 |
| 1503 | end |
| 1504 | if keytail x 21 |
| 1505 | s = ulong 3 |
| 1506 | end |
| 1507 | if keytail x 22 |
| 1508 | s = ulong 4 |
| 1509 | end |
| 1510 | if eq s 6 |
| 1511 | put obl 0 0 |
| 1512 | om 19 |
| 1513 | oname x |
| 1514 | om 20 |
| 1515 | oc 10 |
| 1516 | oflush 1 |
| 1517 | ret |
| 1518 | end |
| 1519 | if not slotok s |
| 1520 | fail0 |
| 1521 | om 21 |
| 1522 | oname x |
| 1523 | om 22 |
| 1524 | fail1 |
| 1525 | ret |
| 1526 | end |
| 1527 | lab0 |
| 1528 | labm 21 |
| 1529 | labx x |
| 1530 | same long x s |
| 1531 | end |
| 1532 | |
| 1533 | fn consumed to void |
| 1534 | for b ulong get nbk 0 |
| 1535 | e = get kbk b |
| 1536 | while ne e 0 bound 8192 |
| 1537 | x = sub e 1 |
| 1538 | if haspre x 17 |
| 1539 | consumed1 x |
| 1540 | end |
| 1541 | e = get knx x |
| 1542 | end |
| 1543 | end |
| 1544 | end |
| 1545 | |
| 1546 | fn usage to int |
| 1547 | put obl 0 0 |
| 1548 | om 0 |
| 1549 | b = get obl 0 |
| 1550 | for i ulong get a0l 0 |
| 1551 | put obuf add b i get a0 i |
| 1552 | end |
| 1553 | put obl 0 add b get a0l 0 |
| 1554 | om 1 |
| 1555 | oc 10 |
| 1556 | oflush 2 |
| 1557 | ret 1 |
| 1558 | end |
| 1559 | |
| 1560 | fn cannot i ulong e long to void |
| 1561 | fail0 |
| 1562 | om i |
| 1563 | oval e |
| 1564 | fail1 |
| 1565 | end |
| 1566 | |
| 1567 | fn omegaside omg long to void |
| 1568 | r = readlock 16 omg 12 2 |
| 1569 | r = readlock 16 omg 13 3 |
| 1570 | r = readlock 16 omg 14 4 |
| 1571 | if slotok 3 |
| 1572 | lab0 |
| 1573 | labm 15 |
| 1574 | same kfind 0 2 3 |
| 1575 | else |
| 1576 | cannot 16 omg |
| 1577 | end |
| 1578 | if gt vlen kfind 0 3 0 |
| 1579 | if slotok 2 |
| 1580 | lab0 |
| 1581 | labm 17 |
| 1582 | same kfind 0 3 2 |
| 1583 | else |
| 1584 | cannot 18 omg |
| 1585 | end |
| 1586 | end |
| 1587 | end |
| 1588 | |
| 1589 | fn main to int |
| 1590 | l = argread 0 a0 0 4095 |
| 1591 | if lt l 0 |
| 1592 | l = long 0 |
| 1593 | end |
| 1594 | put a0l 0 ulong l |
| 1595 | if lt argcnt 2 |
| 1596 | ret usage |
| 1597 | end |
| 1598 | l = argread 1 fpath 0 4095 |
| 1599 | if lt l 0 |
| 1600 | l = long 0 |
| 1601 | end |
| 1602 | put fpl 0 ulong l |
| 1603 | if not isregf |
| 1604 | ret usage |
| 1605 | end |
| 1606 | envinit |
| 1607 | treset 0 |
| 1608 | treset 1 |
| 1609 | put pooln 0 0 |
| 1610 | put failf 0 0 |
| 1611 | loadm |
| 1612 | parse 0 |
| 1613 | for s ulong 6 |
| 1614 | put lkl s 0 |
| 1615 | end |
| 1616 | sc = kfind 0 0 |
| 1617 | omg = kfind 0 1 |
| 1618 | if or eq vlen sc 0 eq vlen omg 0 |
| 1619 | fail0 |
| 1620 | om 4 |
| 1621 | fail1 |
| 1622 | ret 1 |
| 1623 | end |
| 1624 | if readlock 15 sc 10 0 |
| 1625 | lab0 |
| 1626 | labm 5 |
| 1627 | same omg 0 |
| 1628 | else |
| 1629 | cannot 10 sc |
| 1630 | end |
| 1631 | r = fileat 15 sc 11 |
| 1632 | if and eq r 0 gt get capn 0 0 |
| 1633 | cargopair 7 4 |
| 1634 | cargopair 8 5 |
| 1635 | cargopair 9 6 |
| 1636 | else |
| 1637 | cannot 14 sc |
| 1638 | end |
| 1639 | omegaside omg |
| 1640 | consumed |
| 1641 | if ne get failf 0 0 |
| 1642 | put obl 0 0 |
| 1643 | om 24 |
| 1644 | ofile |
| 1645 | oc 10 |
| 1646 | oflush 2 |
| 1647 | ret 1 |
| 1648 | end |
| 1649 | put obl 0 0 |
| 1650 | om 23 |
| 1651 | ofile |
| 1652 | oc 10 |
| 1653 | oflush 1 |
| 1654 | ret 0 |
| 1655 | end |