commit d0d083098a4865c39a1bc11ebbfe291cf9f596f2 Author: Pavel Isaev Date: Thu Nov 5 21:27:25 2026 +0300 Initialize cli experimental implementation and documentation diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..bffb4e5 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1009 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "serde", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "archipelago" +version = "0.0.0" +dependencies = [ + "archipelago-builder", + "archipelago-contracts", + "archipelago-installer", + "archipelago-registry", + "archipelago-system", + "serde_json", +] + +[[package]] +name = "archipelago-builder" +version = "0.0.0" +dependencies = [ + "archipelago-contracts", +] + +[[package]] +name = "archipelago-contracts" +version = "0.0.0" +dependencies = [ + "jsonschema", + "regex", + "serde_json", + "yaml-rust2", +] + +[[package]] +name = "archipelago-installer" +version = "0.0.0" + +[[package]] +name = "archipelago-registry" +version = "0.0.0" + +[[package]] +name = "archipelago-system" +version = "0.0.0" +dependencies = [ + "serde_json", +] + +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "borrow-or-share" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0b364ead1874514c8c2855ab558056ebfeb775653e7ae45ff72f28f8f3166c" + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytecount" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" +dependencies = [ + "serde", +] + +[[package]] +name = "fancy-regex" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" +dependencies = [ + "bit-set", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "fluent-uri" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1918b65d96df47d3591bed19c5cca17e3fa5d0707318e4b5ef2eae01764df7e5" +dependencies = [ + "borrow-or-share", + "ref-cast", + "serde", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "fraction" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076045bb43dac435333ed5f04caf35c7463631d0dae2deb2638d94dd0a5b872" +dependencies = [ + "lazy_static", + "num", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "jsonschema" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d46662859bc5f60a145b75f4632fbadc84e829e45df6c5de74cfc8e05acb96b5" +dependencies = [ + "ahash", + "base64", + "bytecount", + "email_address", + "fancy-regex", + "fraction", + "idna", + "itoa", + "num-cmp", + "num-traits", + "once_cell", + "percent-encoding", + "referencing", + "regex", + "regex-syntax", + "serde", + "serde_json", + "uuid-simd", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-cmp" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "outref" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "referencing" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9c261f7ce75418b3beadfb3f0eb1299fe8eb9640deba45ffa2cb783098697d" +dependencies = [ + "ahash", + "fluent-uri", + "once_cell", + "parking_lot", + "percent-encoding", + "serde_json", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "uuid" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "uuid-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b082222b4f6619906941c17eb2297fff4c2fb96cb60164170522942a200bd8" +dependencies = [ + "outref", + "uuid", + "vsimd", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yaml-rust2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9" +dependencies = [ + "arraydeque", + "hashlink", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..859478d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "archipelago" +version = "0.0.0" +edition = "2024" +rust-version = "1.90" +publish = false + +[dependencies] +serde_json = "1" +archipelago-builder = { path = "../builder" } +archipelago-installer = { path = "../installer" } +archipelago-system = { path = "../system" } +archipelago-registry = { path = "../registry" } +archipelago-contracts = { path = "../contracts" } diff --git a/README.md b/README.md new file mode 100644 index 0000000..88e31b8 --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# archipelago — experimental Core vertical slice + +Единый Rust executable связывает `builder`, `installer`, `system`; snapshot-specific +адаптеры штатных инструментов встроены в binary. Это экспериментальный фиксированный +Core профиль из `../manifests/CORE-EXPERIMENT.md`, не полноценная реализация всех RFC. + +Сборка на superserv1, репозитории расположены рядом: + +```sh +export RUSTUP_HOME=/hdd/archipelago/cache/rustup +export CARGO_HOME=/hdd/archipelago/cache/cargo +export CARGO_TARGET_DIR=/hdd/archipelago/cache/target +export TMPDIR=/hdd/archipelago/tmp +export PATH="$CARGO_HOME/bin:$PATH" +cargo build --offline --locked --release +sudo "$CARGO_TARGET_DIR/release/archipelago" build iso \ + /hdd/archipelago/runs/core-iso-new \ + /hdd/archipelago/cache/bootstrap/archlinux-bootstrap-2026.11.01-x86_64.tar.zst +``` + +Bootstrap принимается только с проверенным SHA-256 из E01; сборщик не исполняет +произвольный архив под этим именем. Результат — `WORKDIR/output/archipelago-core-latest.iso`. +Для новой сборки использовать новый WORKDIR. Работа с live rootfs хоста через pacman +не выполняется: package/image operations находятся в nspawn. + +На ZFS сборщик создаёт в WORKDIR разреженный ext4-образ 32 GiB для рабочего дерева: +это обходит обнаруженное ожидание ZFS txg при OSTree O_TMPFILE/linkat и обеспечивает +обычные ACL/xattrs. Все данные по-прежнему находятся на `/hdd`. ISO и evidence +копируются наружу перед размонтированием. Требуются host `mkfs.ext4`, loop и mount. +`ARCHIPELAGO_PACKAGE_CACHE` позволяет явно переиспользовать каталог пакетов между +прогонами; подписи/контрольные суммы всё равно проверяет pacman. + +### Пакет в экспериментальном образе + +`packaging/PKGBUILD` упаковывает бинарник и runtime-инфраструктуру: systemd units, +presets, ALPM guard, tmpfiles, конфигурацию initramfs и шаблоны defaults. +Builder запускает makepkg от непривилегированного пользователя в Arch nspawn, +подписывает пакет и локальный репозиторий лабораторным ключом и устанавливает +`archipelago` через pacstrap/pacman в Core и live. Рецепт с checksums и публичный +ключ сохраняются в evidence; пакет и подписи — в `output/packages`. +Лабораторный ключ не определяет будущую публичную trust/signing policy. + +`archipelago self-check` проверяет владельца бинарника через pacman, `pacman -Qkk` +и manifest прав каждого регулярного файла пакета: бинарник `0755 root:root`, +данные `0644 root:root`. Проверка обязательна при сборке обоих rootfs и в VM +до установки, после первого входа и после активации каждого расширения. +Само наличие этих проверок не означает прохождения VM-приёмки. + +### Repository-backed Host Extensions + +```sh +sudo archipelago extension add nano +sudo archipelago extension add mc htop +sudo archipelago status +sudo systemctl reboot +sudo archipelago extension add tree +``` + +Имена разрешаются через pacman из закреплённой базы репозиториев выбранного image; +зависимости устанавливаются автоматически. Повторные вызовы дополняют pending-набор, +а после загрузки — набор загруженного deployment. Уже запрошенный пакет — no-op. +Каждая новая композиция начинается с исходной managed-базы и полного явного набора, +а не с изменённой package DB предыдущего Host Extension. `status` отдельно показывает +booted/pending и их запросы. Активация — только после явной перезагрузки. + +Транзакции выполняются в nspawn через `pacman -S --needed`; `-Sy/-Syu` не выполняется. +Недоступность закреплённого пакета — ошибка. Для другого транспорта можно задать +`/etc/archipelago/extensions-mirrorlist` в обычном формате mirrorlist; это не меняет +версии/checksums выбранного snapshot. История, точные пакеты, зависимости и журналы +сохраняются в `/var/lib/archipelago/host-extensions/generations/`. + +Неадаптированные hooks/scriptlets, kernel/DKMS и payload на persistent-путях +отклоняются с диагностикой, а не пропускаются молча. Замена пакетов базы через `add` +запрещена. Локальные файлы, remove/update/rebase workflows требуют отдельных команд. +Контракт прототипа: `../system/EXTENSIONS.md`; результаты проверок — в `test-lab`. diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD new file mode 100644 index 0000000..e7a8d09 --- /dev/null +++ b/packaging/PKGBUILD @@ -0,0 +1,31 @@ +# Experimental binary package. The Rust executable is built on the designated +# host; both inputs are pinned below by the builder before makepkg is invoked. +pkgname=archipelago +pkgver=0.0.0.@BUILD_ID@ +pkgrel=1 +pkgdesc='Archipelago Core build, installation and deployment control' +arch=('x86_64') +depends=('bash' 'coreutils' 'util-linux' 'ostree' 'pacman' 'shadow' 'sudo' + 'openssh' 'systemd' 'gptfdisk' 'parted' 'dosfstools' 'e2fsprogs' + 'arch-install-scripts' 'diffutils') +options=('!strip' '!debug') +source=('archipelago' 'runtime.tar') +sha256sums=('@BINARY_SHA256@' '@RUNTIME_SHA256@') + +package() { + cp -a "$srcdir/runtime/usr" "$pkgdir/" + find "$pkgdir" -type d -exec chmod 0755 '{}' + + find "$pkgdir" -type f -exec chmod 0644 '{}' + + install -Dm0755 "$srcdir/archipelago" "$pkgdir/usr/bin/archipelago" + chown -R 0:0 "$pkgdir" + install -d "$pkgdir/usr/share/archipelago" + # Manifest covers every packaged regular file, including itself. No setuid, + # setgid or writable-by-group/world files are required by this package. + touch "$pkgdir/usr/share/archipelago/permissions.tsv" + chmod 0644 "$pkgdir/usr/share/archipelago/permissions.tsv" + (cd "$pkgdir" && find usr -type f -printf '%m %U %G %p\n' | LC_ALL=C sort) \ + > "$pkgdir/usr/share/archipelago/permissions.tsv" + # OSTree materializes regular files with epoch mtimes. Match the package's + # mtree to that representation so strict ALPM checks also pass after deploy. + find "$pkgdir" -exec touch -h -d @0 '{}' + +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..c3891f0 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.90.0" +profile = "minimal" diff --git a/src/infrastructure.rs b/src/infrastructure.rs new file mode 100644 index 0000000..fe3476a --- /dev/null +++ b/src/infrastructure.rs @@ -0,0 +1,111 @@ +//! Interim infrastructure control, configured on the coordinator only. +use serde_json::{json, Value}; +use std::{env, fs, path::{Path, PathBuf}, process::Command, time::{SystemTime, UNIX_EPOCH}}; + +fn text<'a>(v: &'a Value, key: &str) -> Result<&'a str, String> { + v[key].as_str().filter(|s| !s.is_empty()).ok_or_else(|| format!("missing infrastructure setting: {key}")) +} +fn reason(s: &str) -> Result<&str, String> { + if s.trim().is_empty() || s.len() > 2048 || s.chars().any(char::is_control) { + Err("provide a nonempty, single-line release reason (up to 2048 bytes)".into()) + } else { Ok(s) } +} +fn command(config: &Value, key: &str, candidates: Option<&Path>) -> Result, String> { + let values = config[key].as_array().filter(|v| !v.is_empty()).ok_or("missing configured command")?; + values.iter().map(|v| { + let s = v.as_str().ok_or("invalid command argument")?; + if s == "{candidates}" { + Ok(candidates.ok_or("candidate path required")?.to_str().ok_or("invalid path")?.into()) + } else { Ok(s.into()) } + }).collect() +} +fn output(args: &[&str]) -> Result { + let out = Command::new(args[0]).args(&args[1..]).output().map_err(|e| e.to_string())?; + if !out.status.success() { return Err(String::from_utf8_lossy(&out.stderr).into()); } + Ok(String::from_utf8_lossy(&out.stdout).into()) +} +fn start(config: &Value, operation: &str, why: &str, args: &[String]) -> Result<(), String> { + reason(why)?; + if output(&["id", "-u"])?.trim() != "0" { return Err("Run as root on the coordinator".into()); } + let root = Path::new(text(config, "control_root")?); + fs::create_dir_all(root).map_err(|e| e.to_string())?; + let lock = fs::File::options().create(true).truncate(false).write(true).open(root.join("control.lock")).map_err(|e| e.to_string())?; + lock.try_lock().map_err(|e| format!("infrastructure operation busy: {e}"))?; + let unit = text(config, "unit")?; + let active = output(&["systemctl", "show", unit, "-p", "ActiveState", "--value"])?; + if matches!(active.trim(), "active" | "activating" | "deactivating") { return Err("infrastructure operation already running".into()); } + let id = SystemTime::now().duration_since(UNIX_EPOCH).map_err(|e| e.to_string())?.as_nanos().to_string(); + let log = root.join(format!("{id}.log")); + let record = root.join(format!("{id}.json")); + let mut request = json!({"id":id,"operation":operation,"reason":why,"unit":unit, + "state":"submitted","log":log,"command":args}); + fs::write(&record, serde_json::to_vec_pretty(&request).unwrap()).map_err(|e| e.to_string())?; + let status = Command::new("systemd-run").args(["--collect", &format!("--unit={unit}"), + "--property=RuntimeMaxSec=12h", &format!("--property=StandardOutput=append:{}", log.display()), + &format!("--property=StandardError=append:{}", log.display()), + &format!("--setenv=ARCHIPELAGO_RELEASE_REASON={why}")]) + .args(["python3", text(config, "job_runner")?]).arg(&record).status().map_err(|e| e.to_string())?; + if !status.success() { + request["state"] = json!("launch-failed"); + fs::write(&record, serde_json::to_vec_pretty(&request).unwrap()).map_err(|e| e.to_string())?; + return Err(format!("systemd-run: {status}")); + } + println!("{}", serde_json::to_string_pretty(&request).unwrap()); + Ok(()) +} +pub fn dispatch(args: &[String]) -> Result<(), String> { + let path = env::var_os("ARCHIPELAGO_INFRA_CONFIG").map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from("/etc/archipelago/infrastructure.json")); + let config: Value = serde_json::from_slice(&fs::read(&path).map_err(|e| format!("infrastructure is not configured at {}: {e}", path.display()))?).map_err(|e| e.to_string())?; + if config["version"] != 1 { return Err("unsupported infrastructure configuration".into()); } + match args.iter().map(String::as_str).collect::>().as_slice() { + ["pipeline", "run", "--reason", why] => start(&config, "pipeline-run", why, &command(&config, "run_command", None)?), + ["pipeline", "status"] => { + let status = output(&["systemctl", "show", text(&config, "unit")?, "-p", "ActiveState", "-p", "SubState", "-p", "Result"])?; + let root = Path::new(text(&config, "control_root")?); + let mut requests = Vec::new(); + if root.exists() { + for entry in fs::read_dir(root).map_err(|e| e.to_string())? { + let p = entry.map_err(|e| e.to_string())?.path(); + if p.extension().is_some_and(|e| e == "json") { + requests.push(serde_json::from_slice::(&fs::read(p).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?); + } + } + } + requests.sort_by(|a,b| a["id"].as_str().cmp(&b["id"].as_str())); + println!("{}", serde_json::to_string_pretty(&json!({"unit_status":status,"requests":requests})).unwrap()); + Ok(()) + } + ["pipeline", "logs", id] if id.bytes().all(|c| c.is_ascii_digit()) && !id.is_empty() => { + let p = Path::new(text(&config, "control_root")?).join(format!("{id}.log")); + let status = Command::new("tail").args(["-n", "200"]).arg(p).status().map_err(|e| e.to_string())?; + if status.success() { Ok(()) } else { Err("log unavailable".into()) } + } + ["release", operation, candidate, "--reason", why] if matches!(*operation, "plan" | "publish") => { + reason(why)?; + let candidate = fs::canonicalize(candidate).map_err(|e| e.to_string())?; + let allowed = fs::canonicalize(text(&config, "candidate_root")?).map_err(|e| e.to_string())?; + if !candidate.starts_with(allowed) { return Err("candidate must be in the configured private artifact root".into()); } + let mut cmd = command(&config, "publish_command", Some(&candidate))?; + if *operation == "plan" { + cmd.push("--check-only".into()); + let status = Command::new(&cmd[0]).args(&cmd[1..]).status().map_err(|e| e.to_string())?; + if status.success() { Ok(()) } else { Err(format!("candidate verification: {status}")) } + } else { start(&config, "release-publish", why, &cmd) } + } + _ => Err("Supported: pipeline status | logs ID | run --reason TEXT; release plan|publish CANDIDATES.json --reason TEXT".into()), + } +} + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn reason_and_arguments_are_not_shell_commands() { + assert!(reason(" ").is_err()); + assert!(reason("fix\nreboot").is_err()); + let c = json!({"run_command":["python3", "a; reboot"]}); + assert_eq!(command(&c, "run_command", None).unwrap(), ["python3", "a; reboot"]); + assert!(command(&json!({"run_command":["{candidates}"]}), "run_command", None).is_err()); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3f40a5b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,68 @@ +use std::{env, process::{Command, ExitCode}}; +mod self_check; +mod infrastructure; + +fn run(script: &str, args: &[String]) -> Result<(), String> { + let status = Command::new("/usr/bin/bash") + .args(["-euo", "pipefail", "-c", script, "archipelago-adapter"]) + .args(args).status().map_err(|e| e.to_string())?; + if status.success() { Ok(()) } else { Err(format!("operation failed: {status}")) } +} + +fn main() -> ExitCode { + let args: Vec = env::args().skip(1).collect(); + let result = match args.iter().map(String::as_str).collect::>().as_slice() { + ["pipeline", ..] | ["release", "plan", ..] | ["release", "publish", ..] => infrastructure::dispatch(&args), + ["build", "gnome-probe", work, bootstrap] => archipelago_builder::build_gnome_probe_script() + .and_then(|script| env::current_exe().map_err(|e| e.to_string()).and_then(|binary| + run(&script, &[work.to_string(), bootstrap.to_string(), binary.display().to_string(), "gnome-probe".into()]))), + ["desktop", "reconcile"] => archipelago_system::desktop::reconcile(), + ["desktop", "seed-flatpaks"] => archipelago_system::desktop::seed_flatpaks(), + ["layer", "validate", path] => std::fs::read_to_string(path).map_err(|e| e.to_string()) + .and_then(|text| archipelago_contracts::layer::validate(&text)) + .map(|_| println!("Layer v1 syntax, schema and source-local checks passed; resolution/build checks still required")), + ["registry", "init", path] => archipelago_registry::init(path), + ["registry", "verify", path] => archipelago_registry::verify(path), + ["build", "iso", work, bootstrap] => { + match env::current_exe() { + Ok(binary) => run(&archipelago_builder::build_iso_script(), + &[work.to_string(), bootstrap.to_string(), binary.display().to_string()]), + Err(e) => Err(e.to_string()), + } + } + ["install", device, "--erase"] => run(archipelago_installer::INSTALL, &[device.to_string()]), + ["firstboot"] => run(archipelago_system::FIRSTBOOT, &[]), + ["self-check"] => self_check::check(), + ["status"] => run(archipelago_system::HOST, &args).and_then(|_| archipelago_system::extensions::describe()), + ["boot-sync"] => run(archipelago_system::HOST, &args), + ["extension", "add", ..] => archipelago_system::extensions::add(&args[2..]), + ["update", "check"] => archipelago_system::updates::plan(false), + ["update", "plan"] => archipelago_system::updates::plan(true), + ["update", "apply", "--plan", id] => archipelago_system::updates::apply(id), + ["overlay", "apply", "test-marker"] => { + run(archipelago_system::HOST, &args) + } + _ => { + eprintln!("Experimental Core profile\n\ + archipelago build iso WORKDIR BOOTSTRAP.tar.zst\n\ + archipelago build gnome-probe WORKDIR BOOTSTRAP.tar.zst (private integration probe)\n\ + archipelago registry init|verify REPOSITORY\n\ + archipelago layer validate MANIFEST.yaml\n\ + archipelago desktop reconcile|seed-flatpaks\n\ + archipelago install /dev/DEVICE --erase\n\ + archipelago firstboot | status | self-check\n\ + archipelago overlay apply test-marker\n\ + archipelago extension add PACKAGE...\n\ + archipelago update check|plan\n\ + archipelago update apply --plan PLAN_SHA256\n\ + archipelago pipeline status|logs|run --reason TEXT (configured infrastructure host)\n\ + archipelago release plan|publish CANDIDATES.json --reason TEXT (infrastructure host)\n\ + Activation happens on the next explicit reboot."); + return ExitCode::from(2); + } + }; + match result { + Ok(()) => ExitCode::SUCCESS, + Err(error) => { eprintln!("archipelago: {error}"); ExitCode::FAILURE } + } +} diff --git a/src/self_check.rs b/src/self_check.rs new file mode 100644 index 0000000..188e0ac --- /dev/null +++ b/src/self_check.rs @@ -0,0 +1,32 @@ +use std::{fs, os::unix::fs::MetadataExt, process::Command}; + +pub fn check() -> Result<(), String> { + let owner = Command::new("pacman").args(["-Qoq", "/usr/bin/archipelago"]) + .output().map_err(|e| e.to_string())?; + if !owner.status.success() || owner.stdout != b"archipelago\n" { + return Err("binary is not owned by the archipelago package".into()); + } + let status = Command::new("pacman").args(["-Qkk", "archipelago"]) + .status().map_err(|e| e.to_string())?; + if !status.success() { return Err("package integrity check failed".into()); } + let manifest = fs::read_to_string("/usr/share/archipelago/permissions.tsv") + .map_err(|e| e.to_string())?; + let mut binary_seen = false; + for line in manifest.lines() { + let fields: Vec<_> = line.split_whitespace().collect(); + if fields.len() != 4 || !fields[3].starts_with("usr/") || fields[3].split('/').any(|p| p == "..") { + return Err(format!("invalid permissions entry: {line}")); + } + let path = format!("/{}", fields[3]); + let metadata = fs::symlink_metadata(&path).map_err(|e| format!("{path}: {e}"))?; + let expected = if path == "/usr/bin/archipelago" { binary_seen = true; "755" } else { "644" }; + if fields[0] != expected || fields[1] != "0" || fields[2] != "0" + || !metadata.is_file() || metadata.uid() != 0 || metadata.gid() != 0 + || format!("{:o}", metadata.mode() & 0o7777) != expected { + return Err(format!("incorrect type, ownership or permissions: {path}")); + } + } + if !binary_seen { return Err("permissions manifest omits binary".into()); } + println!("ARCHIPELAGO_SELF_CHECK_OK: package integrity, root:root ownership and permissions"); + Ok(()) +}