diff --git a/Cargo.lock b/Cargo.lock index a4a216b..b784304 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -35,7 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.16", "once_cell", "version_check", "zerocopy", @@ -106,19 +106,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" dependencies = [ "backtrace", ] @@ -162,7 +163,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -173,9 +174,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "block-buffer" @@ -188,15 +189,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] name = "byteorder" @@ -206,36 +207,34 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "bzip2" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47" dependencies = [ "bzip2-sys", - "libc", ] [[package]] name = "bzip2-sys" -version = "0.1.11+1.0.8" +version = "0.1.13+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" dependencies = [ "cc", - "libc", "pkg-config", ] [[package]] name = "cc" -version = "1.2.1" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" dependencies = [ "jobserver", "libc", @@ -260,7 +259,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -309,9 +308,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" @@ -321,15 +320,15 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "console" -version = "0.15.8" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "unicode-width 0.1.14", - "windows-sys 0.52.0", + "once_cell", + "unicode-width", + "windows-sys 0.59.0", ] [[package]] @@ -356,9 +355,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -402,18 +401,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -430,18 +429,18 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" @@ -455,7 +454,7 @@ dependencies = [ [[package]] name = "dadk" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "clap", @@ -478,7 +477,7 @@ dependencies = [ [[package]] name = "dadk-config" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "cfg-if", @@ -495,7 +494,7 @@ dependencies = [ [[package]] name = "dadk-user" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "chrono", @@ -515,9 +514,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ "darling_core", "darling_macro", @@ -525,9 +524,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", @@ -539,9 +538,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.10" +version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", @@ -570,9 +569,9 @@ checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" [[package]] name = "deranged" -version = "0.3.11" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", ] @@ -643,15 +642,15 @@ dependencies = [ [[package]] name = "either" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "encoding_rs" @@ -664,9 +663,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", "regex", @@ -674,44 +673,44 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" dependencies = [ "anstream", "anstyle", "env_filter", - "humantime", + "jiff", "log", ] [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "miniz_oxide", @@ -848,13 +847,27 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", + "js-sys", "libc", - "wasi", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", ] [[package]] @@ -865,9 +878,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "h2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" dependencies = [ "atomic-waker", "bytes", @@ -900,12 +913,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hmac" version = "0.12.1" @@ -917,9 +924,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -938,12 +945,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", - "futures-util", + "futures-core", "http", "http-body", "pin-project-lite", @@ -951,21 +958,21 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.5" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "humantime" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" [[package]] name = "hyper" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", @@ -983,9 +990,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http", @@ -1016,9 +1023,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" dependencies = [ "bytes", "futures-channel", @@ -1026,6 +1033,7 @@ dependencies = [ "http", "http-body", "hyper", + "libc", "pin-project-lite", "socket2", "tokio", @@ -1035,14 +1043,15 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.61" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", + "log", "wasm-bindgen", "windows-core", ] @@ -1097,9 +1106,9 @@ dependencies = [ [[package]] name = "icu_locid_transform_data" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" [[package]] name = "icu_normalizer" @@ -1121,9 +1130,9 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" [[package]] name = "icu_properties" @@ -1142,9 +1151,9 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" [[package]] name = "icu_provider" @@ -1203,9 +1212,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -1213,22 +1222,22 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.9" +version = "0.17.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" +checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" dependencies = [ "console", "number_prefix", "portable-atomic", - "unicode-width 0.2.0", + "unicode-width", "web-time", ] [[package]] name = "inferno" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a5d75fee4d36809e6b021e4b96b686e763d365ffdb03af2bd00786353f84fe" +checksum = "2094aecddc672e902cd773bad7071542f63641e01e9187c3bba4b43005e837e9" dependencies = [ "ahash", "clap", @@ -1248,18 +1257,18 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "generic-array", ] [[package]] name = "ipnet" -version = "2.10.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is_terminal_polyfill" @@ -1269,25 +1278,51 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jiff" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a064218214dc6a10fbae5ec5fa888d80c45d611aba169222fc272072bf7aef6" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "199b7932d97e325aff3a7030e141eafe7f2c6268e1d1b24859b753a627f45254" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom 0.3.2", "libc", ] [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -1299,21 +1334,21 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.165" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "litemap" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "lock_api" @@ -1325,17 +1360,11 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "lockfree-object-pool" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" - [[package]] name = "log" -version = "0.4.22" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lzma-rs" @@ -1347,6 +1376,17 @@ dependencies = [ "crc", ] +[[package]] +name = "lzma-sys" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1361,30 +1401,29 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] [[package]] name = "native-tls" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" dependencies = [ "libc", "log", @@ -1430,24 +1469,24 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.20.2" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" dependencies = [ "bitflags", "cfg-if", @@ -1471,15 +1510,15 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" dependencies = [ "cc", "libc", @@ -1497,7 +1536,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1518,9 +1557,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1530,87 +1569,63 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "portable-atomic" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" [[package]] -name = "powerfmt" -version = "0.2.0" +name = "portable-atomic-util" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] [[package]] -name = "ppv-lite86" -version = "0.2.20" +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" -version = "0.37.1" +version = "0.37.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22f29bdff3987b4d8632ef95fd6424ec7e4e0a57e2f4fc63e489e75357f6a03" +checksum = "a4ce8c88de324ff838700f36fb6ab86c96df0e3c4ab6ef3a9b2044465cce1369" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" +name = "r-efi" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "rayon" @@ -1634,9 +1649,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags", ] @@ -1672,9 +1687,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ "base64", "bytes", @@ -1706,6 +1721,7 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", + "tower", "tower-service", "url", "wasm-bindgen", @@ -1725,15 +1741,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom", + "getrandom 0.2.16", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -1746,22 +1761,22 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.41" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.18" +version = "0.23.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" +checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" dependencies = [ "once_cell", "rustls-pki-types", @@ -1781,26 +1796,32 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" dependencies = [ "ring", "rustls-pki-types", "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "schannel" @@ -1832,9 +1853,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -1842,18 +1863,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -1862,9 +1883,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -1927,26 +1948,20 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -1973,9 +1988,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.89" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -2025,12 +2040,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.14.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", "fastrand", + "getrandom 0.3.2", "once_cell", "rustix", "windows-sys 0.59.0", @@ -2066,31 +2081,11 @@ dependencies = [ "test-context", ] -[[package]] -name = "thiserror" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "time" -version = "0.3.36" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "num-conv", @@ -2101,9 +2096,9 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "tinystr" @@ -2117,9 +2112,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.41.1" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", @@ -2142,20 +2137,19 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.26.0" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ "rustls", - "rustls-pki-types", "tokio", ] [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" dependencies = [ "bytes", "futures-core", @@ -2166,9 +2160,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" dependencies = [ "serde", "serde_spanned", @@ -2187,9 +2181,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -2198,6 +2192,27 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.3" @@ -2206,9 +2221,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-core", @@ -2231,21 +2246,15 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unicode-ident" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" - -[[package]] -name = "unicode-width" -version = "0.1.14" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-width" @@ -2315,26 +2324,35 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -2343,21 +2361,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2365,9 +2384,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -2378,15 +2397,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -2404,41 +2426,81 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.52.0" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings 0.4.0", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ - "windows-targets", + "proc-macro2", + "quote", + "syn", ] +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + [[package]] name = "windows-registry" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ "windows-result", - "windows-strings", - "windows-targets", + "windows-strings 0.3.1", + "windows-targets 0.53.0", ] [[package]] name = "windows-result" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" dependencies = [ - "windows-targets", + "windows-link", ] [[package]] name = "windows-strings" -version = "0.1.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" dependencies = [ - "windows-result", - "windows-targets", + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", ] [[package]] @@ -2447,7 +2509,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2456,7 +2518,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2465,14 +2527,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -2481,57 +2559,114 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "63d3fcd9bba44b03821e7d699eeee959f3126dcc4aa8e4ae18ec617c2a5cea10" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + [[package]] name = "write16" version = "1.0.0" @@ -2544,6 +2679,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "xz2" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" +dependencies = [ + "lzma-sys", +] + [[package]] name = "yoke" version = "0.7.5" @@ -2574,7 +2718,6 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "byteorder", "zerocopy-derive", ] @@ -2591,18 +2734,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", @@ -2654,9 +2797,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" +checksum = "1dcb24d0152526ae49b9b96c1dcf71850ca1e0b882e4e28ed898a93c41334744" dependencies = [ "aes", "arbitrary", @@ -2665,17 +2808,16 @@ dependencies = [ "crc32fast", "crossbeam-utils", "deflate64", - "displaydoc", "flate2", + "getrandom 0.3.2", "hmac", "indexmap", "lzma-rs", "memchr", "pbkdf2", - "rand", "sha1", - "thiserror", "time", + "xz2", "zeroize", "zopfli", "zstd", @@ -2683,41 +2825,39 @@ dependencies = [ [[package]] name = "zopfli" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +checksum = "edfc5ee405f504cd4984ecc6f14d02d55cfda60fa4b689434ef4102aae150cd7" dependencies = [ "bumpalo", "crc32fast", - "lockfree-object-pool", "log", - "once_cell", "simd-adler32", ] [[package]] name = "zstd" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.2.1" +version = "7.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" +version = "2.0.15+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" dependencies = [ "cc", "pkg-config", diff --git a/crates/test_base/src/dadk_config.rs b/crates/test_base/src/dadk_config.rs index 815a44e..a6d249b 100644 --- a/crates/test_base/src/dadk_config.rs +++ b/crates/test_base/src/dadk_config.rs @@ -42,9 +42,7 @@ impl TestContext for DadkConfigTestContext { // 设置workdir std::env::set_current_dir(&test_base_path).expect("Failed to setup test base path"); - let r = DadkConfigTestContext { test_base_path }; - - r + DadkConfigTestContext { test_base_path } } } diff --git a/dadk-config/Cargo.toml b/dadk-config/Cargo.toml index f220512..222b5df 100644 --- a/dadk-config/Cargo.toml +++ b/dadk-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dadk-config" -version = "0.3.0" +version = "0.3.1" edition = "2021" authors = [ "longjin ", diff --git a/dadk-config/src/common/target_arch.rs b/dadk-config/src/common/target_arch.rs index a34031e..6860773 100644 --- a/dadk-config/src/common/target_arch.rs +++ b/dadk-config/src/common/target_arch.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + use serde::{Deserialize, Deserializer, Serialize}; /// 目标处理器架构 @@ -75,6 +77,17 @@ impl Serialize for TargetArch { } } +impl Display for TargetArch { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TargetArch::X86_64 => write!(f, "x86_64"), + TargetArch::RiscV64 => write!(f, "riscv64"), + TargetArch::AArch64 => write!(f, "aarch64"), + TargetArch::LoongArch64 => write!(f, "loongarch64"), + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/dadk-config/src/common/task.rs b/dadk-config/src/common/task.rs index 24f348d..3bdca97 100644 --- a/dadk-config/src/common/task.rs +++ b/dadk-config/src/common/task.rs @@ -69,7 +69,7 @@ impl BuildConfig { } pub fn validate(&self) -> Result<()> { - return Ok(()); + Ok(()) } pub fn trim(&mut self) { @@ -101,7 +101,7 @@ impl InstallConfig { "InstallConfig: in_dragonos_path should be an Absolute path", )); } - return Ok(()); + Ok(()) } pub fn trim(&mut self) {} @@ -121,7 +121,7 @@ impl CleanConfig { } pub fn validate(&self) -> Result<()> { - return Ok(()); + Ok(()) } pub fn trim(&mut self) { @@ -153,7 +153,7 @@ impl Dependency { if self.version.is_empty() { return Err(Error::msg("version is empty")); } - return Ok(()); + Ok(()) } pub fn trim(&mut self) { @@ -162,7 +162,7 @@ impl Dependency { } pub fn name_version(&self) -> String { - return format!("{}-{}", self.name, self.version); + format!("{}-{}", self.name, self.version) } } @@ -200,7 +200,7 @@ impl TaskEnv { if self.key.is_empty() { return Err(Error::msg("Env: key is empty")); } - return Ok(()); + Ok(()) } } diff --git a/dadk-config/src/manifest.rs b/dadk-config/src/manifest.rs index 31fa0b9..055bf97 100644 --- a/dadk-config/src/manifest.rs +++ b/dadk-config/src/manifest.rs @@ -58,6 +58,11 @@ fn check_used_default() -> bool { pub struct Metadata { /// Target processor architecture pub arch: TargetArch, + + /// DADK builder version for isolating unstable features + #[serde(default = "default_dadk_builder_version", rename = "builder-version")] + pub builder_version: String, + /// Rootfs configuration file path #[serde(default = "default_rootfs_config_path", rename = "rootfs-config")] pub rootfs_config: PathBuf, @@ -88,6 +93,10 @@ pub struct Metadata { pub user_config_dir: PathBuf, } +fn default_dadk_builder_version() -> String { + "v1".to_string() +} + /// Returns the default path for the rootfs configuration file. fn default_rootfs_config_path() -> PathBuf { set_used_default(); @@ -247,7 +256,7 @@ mod tests { temp_file.write_all(toml_content.as_bytes())?; let path = temp_file.path().to_path_buf(); let manifest = DadkManifestFile::load(&path)?; - assert_eq!(manifest.used_default, true); + assert!(manifest.used_default); assert_eq!( manifest.metadata.rootfs_config, PathBuf::from("config/rootfs.toml") diff --git a/dadk-config/src/rootfs/fstype.rs b/dadk-config/src/rootfs/fstype.rs index 19e3573..0b426f5 100644 --- a/dadk-config/src/rootfs/fstype.rs +++ b/dadk-config/src/rootfs/fstype.rs @@ -33,7 +33,7 @@ mod tests { #[test] fn test_deserialize_fat32_lowercase() { let r = deserialize_fs_type("fat32"); - assert_eq!(r.is_ok(), true); + assert!(r.is_ok()); let fs_type = r.unwrap(); assert_eq!(fs_type, FsType::Fat32); } @@ -41,7 +41,7 @@ mod tests { #[test] fn test_deserialize_fat32_mixed_case() { let r = deserialize_fs_type("FAT32"); - assert_eq!(r.is_ok(), true); + assert!(r.is_ok()); let fs_type = r.unwrap(); assert_eq!(fs_type, FsType::Fat32); } diff --git a/dadk-config/src/rootfs/mod.rs b/dadk-config/src/rootfs/mod.rs index f5bfaa2..d4e757f 100644 --- a/dadk-config/src/rootfs/mod.rs +++ b/dadk-config/src/rootfs/mod.rs @@ -3,7 +3,10 @@ pub mod partition; mod utils; -use std::{fs, path::PathBuf}; +use std::{ + fs, + path::{Path, PathBuf}, +}; use anyhow::Result; use fstype::FsType; @@ -20,7 +23,7 @@ pub struct RootFSConfigFile { impl RootFSConfigFile { pub const LBA_SIZE: usize = 512; - pub fn load(path: &PathBuf) -> Result { + pub fn load(path: &Path) -> Result { // 读取文件内容 let content = fs::read_to_string(path)?; Self::load_from_str(&content) diff --git a/dadk-config/src/utils.rs b/dadk-config/src/utils.rs index 66abe02..cedd97d 100644 --- a/dadk-config/src/utils.rs +++ b/dadk-config/src/utils.rs @@ -90,12 +90,10 @@ pub fn apply_kv_array( key_strings.insert(key, arg.to_owned()); continue; + } else if single_value_keys.contains(&arg.as_str()) || multi_value_keys.contains(arg) { + return Err(anyhow!("Invalid argument: {}", arg)); } else { - if single_value_keys.contains(&arg.as_str()) || multi_value_keys.contains(arg) { - return Err(anyhow!("Invalid argument: {}", arg)); - } else { - key_strings.insert(arg.to_owned(), arg.to_owned()); - } + key_strings.insert(arg.to_owned(), arg.to_owned()); } } diff --git a/dadk-config/templates/dadk-manifest.toml b/dadk-config/templates/dadk-manifest.toml index d7df3a6..fed1beb 100644 --- a/dadk-config/templates/dadk-manifest.toml +++ b/dadk-config/templates/dadk-manifest.toml @@ -15,10 +15,10 @@ rootfs-config = "config/rootfs.toml" boot-config = "config/boot.toml" # System root directory folder (DADK will copy the files in this directory to the root directory of the disk image) -sysroot-dir = "bin/sysroot" +sysroot-dir = "bin/x86_64/sysroot" # DADK Root Cache directory path -cache-root-dir = "bin/dadk_cache" +cache-root-dir = "bin/x86_64/dadk_cache" # User configuration directory path # 这个字段只是临时用于兼容旧版本,v0.2版本重构完成后会删除 diff --git a/dadk-config/tests/test_boot_config.rs b/dadk-config/tests/test_boot_config.rs index bee458d..67d68ab 100644 --- a/dadk-config/tests/test_boot_config.rs +++ b/dadk-config/tests/test_boot_config.rs @@ -11,8 +11,8 @@ const BOOT_CONFIG_FILE_NAME: &str = "config/boot.toml"; #[test] fn test_load_boot_config_template(ctx: &DadkConfigTestContext) { let boot_config_path = ctx.templates_dir().join(BOOT_CONFIG_FILE_NAME); - assert_eq!(boot_config_path.exists(), true); - assert_eq!(boot_config_path.is_file(), true); + assert!(boot_config_path.exists()); + assert!(boot_config_path.is_file()); let _manifest = BootConfigFile::load(&boot_config_path).expect("Failed to load boot config"); // TODO 校验 manifest 中的字段是否齐全 } diff --git a/dadk-config/tests/test_dadk_manifest.rs b/dadk-config/tests/test_dadk_manifest.rs index 0704681..81faa23 100644 --- a/dadk-config/tests/test_dadk_manifest.rs +++ b/dadk-config/tests/test_dadk_manifest.rs @@ -11,9 +11,9 @@ const DADK_MANIFEST_FILE_NAME: &str = "dadk-manifest.toml"; #[test] fn test_load_dadk_manifest_template(ctx: &DadkConfigTestContext) { let manifest_path = ctx.templates_dir().join(DADK_MANIFEST_FILE_NAME); - assert_eq!(manifest_path.exists(), true); - assert_eq!(manifest_path.is_file(), true); + assert!(manifest_path.exists()); + assert!(manifest_path.is_file()); let manifest = DadkManifestFile::load(&manifest_path).expect("Failed to load manifest"); // 验证 dadk-manifest.toml 已经包含了所有字段 - assert_eq!(manifest.used_default, false); + assert!(!manifest.used_default); } diff --git a/dadk-config/tests/test_rootfs_config.rs b/dadk-config/tests/test_rootfs_config.rs index 7b894eb..e6f27bd 100644 --- a/dadk-config/tests/test_rootfs_config.rs +++ b/dadk-config/tests/test_rootfs_config.rs @@ -14,8 +14,8 @@ const ROOTFS_CONFIG_FILE_NAME: &str = "config/rootfs.toml"; #[test] fn test_load_rootfs_manifest_template(ctx: &DadkConfigTestContext) { let rootfs_manifest_path = ctx.templates_dir().join(ROOTFS_CONFIG_FILE_NAME); - assert_eq!(rootfs_manifest_path.exists(), true); - assert_eq!(rootfs_manifest_path.is_file(), true); + assert!(rootfs_manifest_path.exists()); + assert!(rootfs_manifest_path.is_file()); let manifest = RootFSConfigFile::load(&rootfs_manifest_path).expect("Failed to load rootfs manifest"); assert_eq!(manifest.partition.partition_type, PartitionType::None); diff --git a/dadk-user/Cargo.toml b/dadk-user/Cargo.toml index 7799737..31a2a4a 100644 --- a/dadk-user/Cargo.toml +++ b/dadk-user/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dadk-user" -version = "0.3.0" +version = "0.3.1" edition = "2021" description = "DragonOS Application Development Kit - user prog build" license = "GPL-2.0-only" @@ -9,7 +9,7 @@ license = "GPL-2.0-only" anyhow = { version = "1.0.90", features = ["std", "backtrace"] } chrono = { version = "=0.4.35", features = ["serde"] } clap = { version = "=4.5.20", features = ["derive"] } -dadk-config = { version = "0.3.0", path = "../dadk-config" } +dadk-config = { version = "0.3.1", path = "../dadk-config" } derive_builder = "0.20.0" lazy_static = "1.4.0" log = "0.4.17" diff --git a/dadk-user/src/executor/cache.rs b/dadk-user/src/executor/cache.rs index e077bc5..903b9ff 100644 --- a/dadk-user/src/executor/cache.rs +++ b/dadk-user/src/executor/cache.rs @@ -1,5 +1,5 @@ use std::{ - path::PathBuf, + path::{Path, PathBuf}, sync::{Arc, Once}, }; @@ -86,7 +86,7 @@ pub fn cache_root_init(path: Option) -> Result<(), ExecutorError> { // 设置环境变量 std::env::set_var("DADK_CACHE_ROOT", CACHE_ROOT.get().to_str().unwrap()); info!("Cache root dir: {:?}", CACHE_ROOT.get()); - return Ok(()); + Ok(()) } #[derive(Debug, Clone, Copy)] @@ -122,7 +122,7 @@ impl CacheDir { result.create()?; - return Ok(result); + Ok(result) } fn get_path(task: &DADKTask, cache_type: CacheDirType) -> PathBuf { @@ -143,33 +143,33 @@ impl CacheDir { ) } }; - abs_path(&PathBuf::from(cache_dir)) + abs_path(Path::new(&cache_dir)) } pub fn build_dir(entity: Arc) -> Result { - return Ok(Self::new(entity.clone(), CacheDirType::Build)?.path); + Ok(Self::new(entity.clone(), CacheDirType::Build)?.path) } pub fn source_dir(entity: Arc) -> Result { - return Ok(Self::new(entity.clone(), CacheDirType::Source)?.path); + Ok(Self::new(entity.clone(), CacheDirType::Source)?.path) } pub fn build_dir_env_key(entity: &Arc) -> Result { let name_version_env = entity.task().name_version_env(); - return Ok(format!( + Ok(format!( "{}_{}", Self::DADK_BUILD_CACHE_DIR_ENV_KEY_PREFIX, name_version_env - )); + )) } pub fn source_dir_env_key(entity: &Arc) -> Result { let name_version_env = entity.task().name_version_env(); - return Ok(format!( + Ok(format!( "{}_{}", Self::DADK_SOURCE_CACHE_DIR_ENV_KEY_PREFIX, name_version_env - )); + )) } pub fn need_source_cache(entity: &Arc) -> bool { @@ -210,7 +210,7 @@ impl CacheDir { )); } - return Ok(()); + Ok(()) } /// 判断缓存目录是否为空 @@ -223,7 +223,7 @@ impl CacheDir { return Ok(false); } - return Ok(true); + Ok(true) } /// # 递归删除自身目录 @@ -235,7 +235,7 @@ impl CacheDir { if path.exists() { std::fs::remove_dir_all(path).map_err(|e| ExecutorError::IoError(e.to_string()))?; } - return Ok(()); + Ok(()) } } @@ -248,7 +248,7 @@ impl TaskDataDir { const TASK_LOG_FILE_NAME: &'static str = "task_log.toml"; pub fn new(entity: Arc) -> Result { let dir = CacheDir::new(entity.clone(), CacheDirType::TaskData)?; - return Ok(Self { dir }); + Ok(Self { dir }) } /// # 获取任务日志 @@ -257,9 +257,9 @@ impl TaskDataDir { if path.exists() { let content = std::fs::read_to_string(&path).unwrap(); let task_log: TaskLog = toml::from_str(&content).unwrap(); - return task_log; + task_log } else { - return TaskLog::new(); + TaskLog::new() } } @@ -267,7 +267,7 @@ impl TaskDataDir { pub fn save_task_log(&self, task_log: &TaskLog) -> Result<(), ExecutorError> { let path = self.dir.path.join(Self::TASK_LOG_FILE_NAME); let content = toml::to_string(task_log).unwrap(); - std::fs::write(&path, content).map_err(|e| ExecutorError::IoError(e.to_string()))?; - return Ok(()); + std::fs::write(path, content).map_err(|e| ExecutorError::IoError(e.to_string()))?; + Ok(()) } } diff --git a/dadk-user/src/executor/mod.rs b/dadk-user/src/executor/mod.rs index 877358a..e960989 100644 --- a/dadk-user/src/executor/mod.rs +++ b/dadk-user/src/executor/mod.rs @@ -1,7 +1,7 @@ use std::{ collections::{BTreeMap, VecDeque}, env::Vars, - path::PathBuf, + path::{Path, PathBuf}, process::{Command, Stdio}, sync::{Arc, RwLock}, time::SystemTime, @@ -89,7 +89,7 @@ impl Executor { dragonos_sysroot, }; - return Ok(result); + Ok(result) } /// # 执行任务 @@ -107,7 +107,7 @@ impl Executor { let r = self.do_execute(); self.save_task_data(r.clone()); info!("Task {} finished", self.entity.task().name_version()); - return r; + r } /// # 保存任务数据 @@ -174,7 +174,7 @@ impl Executor { } } - return Ok(()); + Ok(()) } fn pre_build(&mut self) -> Result<(), ExecutorError> { @@ -217,7 +217,7 @@ impl Executor { } } - return self.do_build(); + self.do_build() } fn post_build(&mut self) -> Result<(), ExecutorError> { @@ -256,7 +256,7 @@ impl Executor { self.entity.task().name_version(), ); } - return Ok(()); + Ok(()) } fn install(&self) -> Result<(), ExecutorError> { @@ -284,7 +284,7 @@ impl Executor { "dadk-user: to do install {}", self.entity.task().name_version() ); - return self.do_install(); + self.do_install() } /// # 执行安装操作,把构建结果安装到DragonOS @@ -309,16 +309,15 @@ impl Executor { debug!("install_path: {:?}", install_path); // 创建安装路径 std::fs::create_dir_all(&install_path).map_err(|e| { - ExecutorError::InstallError(format!("Failed to create install path: {}", e.to_string())) + ExecutorError::InstallError(format!("Failed to create install path: {}", e)) })?; // 拷贝构建结果到安装路径 let build_dir: PathBuf = self.build_dir.path.clone(); - FileUtils::copy_dir_all(&build_dir, &install_path) - .map_err(|e| ExecutorError::InstallError(e))?; + FileUtils::copy_dir_all(&build_dir, &install_path).map_err(ExecutorError::InstallError)?; info!("Task {} installed.", self.entity.task().name_version()); - return Ok(()); + Ok(()) } fn clean(&self) -> Result<(), ExecutorError> { @@ -353,7 +352,7 @@ impl Executor { return Err(e); } - return Ok(()); + Ok(()) } fn clean_all(&self) -> Result<(), ExecutorError> { @@ -363,7 +362,7 @@ impl Executor { self.clean_target()?; // 清理缓存 self.clean_cache()?; - return Ok(()); + Ok(()) } /// 在源文件目录执行清理 @@ -381,7 +380,7 @@ impl Executor { let cmd = cmd.unwrap(); self.run_command(cmd)?; - return Ok(()); + Ok(()) } /// 清理构建输出目录 @@ -392,7 +391,7 @@ impl Executor { self.build_dir.path ); - return self.build_dir.remove_self_recursive(); + self.build_dir.remove_self_recursive() } /// 清理下载缓存 @@ -407,7 +406,7 @@ impl Executor { self.entity.task().name_version(), self.src_work_dir().display() ); - return cache_dir.unwrap().remove_self_recursive(); + cache_dir.unwrap().remove_self_recursive() } /// 获取源文件的工作目录 @@ -415,11 +414,11 @@ impl Executor { if let Some(local_path) = self.entity.task().source_path() { return local_path; } - return self.source_dir.as_ref().unwrap().path.clone(); + self.source_dir.as_ref().unwrap().path.clone() } fn task_log(&self) -> TaskLog { - return self.task_data_dir.task_log(); + self.task_data_dir.task_log() } /// 为任务创建命令 @@ -472,7 +471,7 @@ impl Executor { command.env(key, value.value.clone()); } - return Ok(Some(command)); + Ok(Some(command)) } /// # 准备工作线程本地环境变量 @@ -493,7 +492,7 @@ impl Executor { self.build_dir.path.to_str().unwrap().to_string(), )); - return Ok(()); + Ok(()) } fn prepare_input(&self) -> Result<(), ExecutorError> { @@ -508,7 +507,7 @@ impl Executor { match cs { CodeSource::Git(git) => { git.prepare(source_dir) - .map_err(|e| ExecutorError::PrepareEnvError(e))?; + .map_err(ExecutorError::PrepareEnvError)?; } // 本地源文件,不需要拉取 CodeSource::Local(_) => return Ok(()), @@ -516,7 +515,7 @@ impl Executor { CodeSource::Archive(archive) => { archive .download_unzip(source_dir) - .map_err(|e| ExecutorError::PrepareEnvError(e))?; + .map_err(ExecutorError::PrepareEnvError)?; } } } @@ -526,21 +525,21 @@ impl Executor { PrebuiltSource::Local(local_source) => { let local_path = local_source.path(); let target_path = &self.build_dir.path; - FileUtils::copy_dir_all(&local_path, &target_path) - .map_err(|e| ExecutorError::TaskFailed(e))?; // let mut cmd = "cp -r ".to_string(); + FileUtils::copy_dir_all(local_path, target_path) + .map_err(ExecutorError::TaskFailed)?; // let mut cmd = "cp -r ".to_string(); return Ok(()); } // 在线压缩包,需要下载 PrebuiltSource::Archive(archive) => { archive .download_unzip(&self.build_dir) - .map_err(|e| ExecutorError::PrepareEnvError(e))?; + .map_err(ExecutorError::PrepareEnvError)?; } } } } - return Ok(()); + Ok(()) } fn run_command(&self, mut command: Command) -> Result<(), ExecutorError> { @@ -557,7 +556,7 @@ impl Executor { if r.is_ok() { let r = r.unwrap(); if r.success() { - return Ok(()); + Ok(()) } else { // 执行失败,获取最后100行stderr输出 let errmsg = format!( @@ -584,7 +583,7 @@ impl Executor { for line in last_100_outputs { error!("{}", line); } - return Err(ExecutorError::TaskFailed(errmsg)); + Err(ExecutorError::TaskFailed(errmsg)) } } else { let errmsg = format!( @@ -593,7 +592,7 @@ impl Executor { r.err().unwrap() ); error!("{errmsg}"); - return Err(ExecutorError::TaskFailed(errmsg)); + Err(ExecutorError::TaskFailed(errmsg)) } } } @@ -603,6 +602,12 @@ pub struct EnvMap { pub envs: BTreeMap, } +impl Default for EnvMap { + fn default() -> Self { + Self::new() + } +} + impl EnvMap { pub fn new() -> Self { Self { @@ -664,7 +669,7 @@ pub fn prepare_env( // 写入全局环境变量列表 let mut global_env_list = ENV_LIST.write().unwrap(); *global_env_list = env_list; - return Ok(()); + Ok(()) } /// # 创建全局环境变量列表 @@ -681,7 +686,7 @@ fn create_global_env_list( // 导出任务的构建目录环境变量 let build_dir = CacheDir::build_dir(entity.clone())?; - let build_dir_key = CacheDir::build_dir_env_key(&entity)?; + let build_dir_key = CacheDir::build_dir_env_key(entity)?; env_list.add(EnvVar::new( build_dir_key, build_dir.to_str().unwrap().to_string(), @@ -690,7 +695,7 @@ fn create_global_env_list( // 如果需要源码缓存目录,则导出 if CacheDir::need_source_cache(entity) { let source_dir = CacheDir::source_dir(entity.clone())?; - let source_dir_key = CacheDir::source_dir_env_key(&entity)?; + let source_dir_key = CacheDir::source_dir_env_key(entity)?; env_list.add(EnvVar::new( source_dir_key, source_dir.to_str().unwrap().to_string(), @@ -702,7 +707,7 @@ fn create_global_env_list( let target_arch = execute_ctx.target_arch(); env_list.add(EnvVar::new("ARCH".to_string(), (*target_arch).into())); - return Ok(env_list); + Ok(env_list) } /// # 获取文件最后的更新时间 @@ -712,11 +717,11 @@ fn create_global_env_list( /// * `last_modified` - 最后的更新时间 /// * `build_time` - 构建时间 fn last_modified_time( - path: &PathBuf, + path: &Path, build_time: &DateTime, ) -> Result, ExecutorError> { let mut queue = VecDeque::new(); - queue.push_back(path.clone()); + queue.push_back(path.to_path_buf()); let mut last_modified = DateTime::::from(SystemTime::UNIX_EPOCH); @@ -726,28 +731,26 @@ fn last_modified_time( .map_err(|e| ExecutorError::InstallError(e.to_string()))?; if metadata.is_dir() { - for r in std::fs::read_dir(¤t_path).unwrap() { - if let Ok(entry) = r { - // 忽略编译产物目录 - if entry.file_name() == "target" { - continue; - } + for entry in std::fs::read_dir(¤t_path).unwrap().flatten() { + // 忽略编译产物目录 + if entry.file_name() == "target" { + continue; + } - let entry_path = entry.path(); - let entry_metadata = entry.metadata().unwrap(); - // 比较文件的修改时间和last_modified,取最大值 - let file_modified = DateTime::::from(entry_metadata.modified().unwrap()); - last_modified = std::cmp::max(last_modified, file_modified); + let entry_path = entry.path(); + let entry_metadata = entry.metadata().unwrap(); + // 比较文件的修改时间和last_modified,取最大值 + let file_modified = DateTime::::from(entry_metadata.modified().unwrap()); + last_modified = std::cmp::max(last_modified, file_modified); - // 如果其中某一个文件的修改时间在build_time之后,则直接返回,不用继续搜索 - if last_modified > *build_time { - return Ok(last_modified); - } + // 如果其中某一个文件的修改时间在build_time之后,则直接返回,不用继续搜索 + if last_modified > *build_time { + return Ok(last_modified); + } - if entry_metadata.is_dir() { - // 如果是子目录,则将其加入队列 - queue.push_back(entry_path); - } + if entry_metadata.is_dir() { + // 如果是子目录,则将其加入队列 + queue.push_back(entry_path); } } } else { diff --git a/dadk-user/src/executor/source.rs b/dadk-user/src/executor/source.rs index ef3eac2..d9d0a8d 100644 --- a/dadk-user/src/executor/source.rs +++ b/dadk-user/src/executor/source.rs @@ -53,17 +53,13 @@ impl GitSource { return Err(Error::msg("branch and revision are both specified")); } - if self.branch.is_some() { - if self.branch.as_ref().unwrap().is_empty() { - return Err(Error::msg("branch is empty")); - } + if self.branch.is_some() && self.branch.as_ref().unwrap().is_empty() { + return Err(Error::msg("branch is empty")); } - if self.revision.is_some() { - if self.revision.as_ref().unwrap().is_empty() { - return Err(Error::msg("revision is empty")); - } + if self.revision.is_some() && self.revision.as_ref().unwrap().is_empty() { + return Err(Error::msg("revision is empty")); } - return Ok(()); + Ok(()) } pub fn trim(&mut self) { @@ -116,7 +112,7 @@ impl GitSource { self.pull(target_dir)?; - return Ok(()); + Ok(()) } fn check_repo(&self, target_dir: &CacheDir) -> Result { @@ -140,11 +136,11 @@ impl GitSource { r.pop(); Ok(r == self.url) } else { - return Err(format!( + Err(format!( "git remote get-url origin failed, status: {:?}, stderr: {:?}", output.status, StdioUtils::tail_n_str(StdioUtils::stderr_to_lines(&output.stderr), 5) - )); + )) } } @@ -236,10 +232,10 @@ impl GitSource { String::from_utf8_lossy(&suboutput.stdout) )); } - return Ok(()); + Ok(()) }; - if let Err(_) = do_checkout() { + if do_checkout().is_err() { // 如果切换分支失败,则尝试重新fetch if self.revision.is_some() { self.set_fetch_config(target_dir)?; @@ -250,7 +246,7 @@ impl GitSource { do_checkout()?; } - return Ok(()); + Ok(()) } pub fn clone_repo(&self, cache_dir: &CacheDir) -> Result<(), String> { @@ -308,7 +304,7 @@ impl GitSource { StdioUtils::tail_n_str(StdioUtils::stderr_to_lines(&suboutput.stderr), 5) )); } - return Ok(()); + Ok(()) } /// 设置fetch所有分支 @@ -333,11 +329,11 @@ impl GitSource { StdioUtils::tail_n_str(StdioUtils::stderr_to_lines(&output.stderr), 5) )); } - return Ok(()); + Ok(()) } /// # 把浅克隆的仓库变成深克隆 fn unshallow(&self, target_dir: &CacheDir) -> Result<(), String> { - if self.is_shallow(target_dir)? == false { + if !(self.is_shallow(target_dir)?) { return Ok(()); } @@ -361,7 +357,7 @@ impl GitSource { StdioUtils::tail_n_str(StdioUtils::stderr_to_lines(&output.stderr), 5) )); } - return Ok(()); + Ok(()) } /// 判断当前仓库是否是浅克隆 @@ -385,7 +381,7 @@ impl GitSource { } let is_shallow = String::from_utf8_lossy(&output.stdout).trim() == "true"; - return Ok(is_shallow); + Ok(is_shallow) } fn fetch_all(&self, target_dir: &CacheDir) -> Result<(), String> { @@ -412,12 +408,12 @@ impl GitSource { )); } - return Ok(()); + Ok(()) } fn pull(&self, target_dir: &CacheDir) -> Result<(), String> { // 如果没有指定branch,则不执行pull - if !self.branch.is_some() { + if self.branch.is_none() { return Ok(()); } info!("git pulling: {}", target_dir.path.display()); @@ -445,7 +441,7 @@ impl GitSource { )); } - return Ok(()); + Ok(()) } } @@ -480,7 +476,7 @@ impl LocalSource { } } - return Ok(()); + Ok(()) } pub fn trim(&mut self) {} @@ -518,7 +514,7 @@ impl ArchiveSource { } else { return Err(Error::msg(format!("url {:?} is not a valid url", self.url))); } - return Ok(()); + Ok(()) } pub fn trim(&mut self) { @@ -565,7 +561,7 @@ impl ArchiveSource { archive_file.unzip()?; //删除创建的临时文件夹 std::fs::remove_dir_all(path).map_err(|e| e.to_string())?; - return Ok(()); + Ok(()) } } @@ -642,7 +638,7 @@ impl ArchiveFile { } ArchiveType::Zip => { - let file = File::open(&self.archive_path.join(&self.archive_name)) + let file = File::open(self.archive_path.join(&self.archive_name)) .map_err(|e| e.to_string())?; let mut archive = ZipArchive::new(file).map_err(|e| e.to_string())?; for i in 0..archive.len() { @@ -656,7 +652,7 @@ impl ArchiveFile { } else { if let Some(p) = outpath.parent() { if !p.exists() { - std::fs::create_dir_all(&p).map_err(|e| e.to_string())?; + std::fs::create_dir_all(p).map_err(|e| e.to_string())?; } } let mut outfile = File::create(&outpath).map_err(|e| e.to_string())?; @@ -686,12 +682,12 @@ impl ArchiveFile { for entry in path.read_dir().map_err(|e| e.to_string())? { let entry = entry.map_err(|e| e.to_string())?; let path = entry.path(); - FileUtils::move_files(&path, &self.archive_path.parent().unwrap()) + FileUtils::move_files(&path, self.archive_path.parent().unwrap()) .map_err(|e| e.to_string())?; //删除空的单独文件夹 std::fs::remove_dir_all(&path).map_err(|e| e.to_string())?; } - return Ok(()); + Ok(()) } } diff --git a/dadk-user/src/executor/tests.rs b/dadk-user/src/executor/tests.rs index 7423650..d3cbeaa 100644 --- a/dadk-user/src/executor/tests.rs +++ b/dadk-user/src/executor/tests.rs @@ -38,8 +38,7 @@ fn setup_executor(config_file: PathBuf, ctx: &T) -> Executor assert!(executor.is_ok(), "Create executor error: {:?}", executor); - let executor = executor.unwrap(); - return executor; + executor.unwrap() } /// 测试能否正确设置本地环境变量 diff --git a/dadk-user/src/parser/mod.rs b/dadk-user/src/parser/mod.rs index 0f7ecc2..f77e264 100644 --- a/dadk-user/src/parser/mod.rs +++ b/dadk-user/src/parser/mod.rs @@ -147,7 +147,7 @@ impl Parser { if r.is_err() { error!("Error while parsing config files: {:?}", r); } - return r; + r } /// # 扫描配置文件目录,找到所有配置文件 @@ -158,9 +158,9 @@ impl Parser { // 将config目录加入队列 dir_queue.push(self.config_dir.clone()); - while !dir_queue.is_empty() { + while let Some(dir) = dir_queue.pop() { // 扫描目录,找到所有*.dadk文件 - let dir = dir_queue.pop().unwrap(); + let entries: ReadDir = std::fs::read_dir(&dir)?; for entry in entries { @@ -175,7 +175,7 @@ impl Parser { continue; } let extension: &std::ffi::OsStr = extension.unwrap(); - if extension.to_ascii_lowercase() != "toml" { + if !extension.eq_ignore_ascii_case("toml") { continue; } // 找到一个配置文件, 加入列表 @@ -184,7 +184,7 @@ impl Parser { } } - return Ok(()); + Ok(()) } /// # 解析所有配置文件,生成任务列表 @@ -203,7 +203,7 @@ impl Parser { result_vec.push((config_file.clone(), task)); } - return Ok(result_vec); + Ok(result_vec) } /// # 解析单个配置文件,生成任务 @@ -227,7 +227,7 @@ impl Parser { // 校验DADKTask的参数是否合法 task.validate()?; - return Ok(task); + Ok(task) } /// 解析toml文件,生成DADKTask diff --git a/dadk-user/src/parser/task.rs b/dadk-user/src/parser/task.rs index aba8dda..93ec5e7 100644 --- a/dadk-user/src/parser/task.rs +++ b/dadk-user/src/parser/task.rs @@ -95,7 +95,7 @@ impl DADKTask { /// 从环境变量`ARCH`中获取,如果没有设置,则默认为`x86_64` pub fn default_target_arch() -> TargetArch { let s = std::env::var("ARCH").unwrap_or("x86_64".to_string()); - return TargetArch::try_from(s.as_str()).unwrap(); + TargetArch::try_from(s.as_str()).unwrap() } fn default_target_arch_vec() -> Vec { @@ -118,7 +118,7 @@ impl DADKTask { self.validate_envs()?; self.validate_target_arch()?; - return Ok(()); + Ok(()) } pub fn trim(&mut self) { @@ -137,7 +137,7 @@ impl DADKTask { for depend in &self.depends { depend.validate()?; } - return Ok(()); + Ok(()) } fn trim_depends(&mut self) { @@ -152,14 +152,14 @@ impl DADKTask { env.validate()?; } } - return Ok(()); + Ok(()) } fn validate_target_arch(&self) -> Result<()> { if self.target_arch.is_empty() { return Err(anyhow::Error::msg("target_arch is empty")); } - return Ok(()); + Ok(()) } fn trim_envs(&mut self) { @@ -186,7 +186,7 @@ impl DADKTask { } } } - return Ok(()); + Ok(()) } pub fn name_version(&self) -> String { @@ -194,11 +194,11 @@ impl DADKTask { for (src, dst) in &NAME_VERSION_REPLACE_TABLE { name_version = name_version.replace(src, dst); } - return name_version; + name_version } pub fn name_version_env(&self) -> String { - return Self::name_version_uppercase(&self.name, &self.version); + Self::name_version_uppercase(&self.name, &self.version) } pub fn name_version_uppercase(name: &str, version: &str) -> String { @@ -206,7 +206,7 @@ impl DADKTask { for (src, dst) in &NAME_VERSION_REPLACE_TABLE { name_version = name_version.replace(src, dst); } - return name_version; + name_version } /// # 获取源码目录 @@ -215,20 +215,12 @@ impl DADKTask { pub fn source_path(&self) -> Option { match &self.task_type { TaskType::BuildFromSource(cs) => match cs { - CodeSource::Local(lc) => { - return Some(lc.path().clone()); - } - _ => { - return None; - } + CodeSource::Local(lc) => Some(lc.path().clone()), + _ => None, }, TaskType::InstallFromPrebuilt(ps) => match ps { - PrebuiltSource::Local(lc) => { - return Some(lc.path().clone()); - } - _ => { - return None; - } + PrebuiltSource::Local(lc) => Some(lc.path().clone()), + _ => None, }, } } diff --git a/dadk-user/src/parser/task_log.rs b/dadk-user/src/parser/task_log.rs index b09db2b..b4a9f01 100644 --- a/dadk-user/src/parser/task_log.rs +++ b/dadk-user/src/parser/task_log.rs @@ -32,6 +32,12 @@ where Ok(r.unwrap_or_default()) } +impl Default for TaskLog { + fn default() -> Self { + Self::new() + } +} + impl TaskLog { pub fn new() -> Self { Self { diff --git a/dadk-user/src/scheduler/mod.rs b/dadk-user/src/scheduler/mod.rs index 2744018..e85d7c2 100644 --- a/dadk-user/src/scheduler/mod.rs +++ b/dadk-user/src/scheduler/mod.rs @@ -109,7 +109,7 @@ impl SchedEntity { zero_child.push(child.clone()); } } - return zero_child; + zero_child } } @@ -122,6 +122,12 @@ pub struct SchedEntities { id2entity: RwLock>>, } +impl Default for SchedEntities { + fn default() -> Self { + Self::new() + } +} + impl SchedEntities { pub fn new() -> Self { Self { @@ -147,7 +153,7 @@ impl SchedEntities { return Some(e.1.clone()); } } - return None; + None } pub fn entities(&self) -> Vec> { @@ -155,7 +161,7 @@ impl SchedEntities { for e in self.id2entity.read().unwrap().iter() { v.push(e.1.clone()); } - return v; + v } pub fn id2entity(&self) -> BTreeMap> { @@ -192,7 +198,7 @@ impl SchedEntities { } } } - return result; + result } fn dfs( @@ -244,7 +250,7 @@ impl SchedEntities { } visited.insert(entity.id(), true); result.push(entity.clone()); - return Ok(()); + Ok(()) } } @@ -316,7 +322,7 @@ impl Scheduler { return Err(r.err().unwrap()); } - return Ok(scheduler); + Ok(scheduler) } /// # 添加多个任务 @@ -333,7 +339,7 @@ impl Scheduler { } } - return Ok(()); + Ok(()) } /// # 任务是否匹配当前目标架构 @@ -387,12 +393,12 @@ impl Scheduler { self.target.add(entity.clone()); info!("Task added: {}", entity.task().name_version()); - return Ok(entity); + Ok(entity) } fn generate_task_id(&self) -> i32 { static TASK_ID: AtomicI32 = AtomicI32::new(0); - return TASK_ID.fetch_add(1, Ordering::SeqCst); + TASK_ID.fetch_add(1, Ordering::SeqCst) } /// # 执行调度器中的所有任务 @@ -408,7 +414,7 @@ impl Scheduler { Action::Clean(_) => self.run_without_topo_sort()?, } - return Ok(()); + Ok(()) } /// Action需要按照拓扑序执行 @@ -425,7 +431,7 @@ impl Scheduler { // 对调度实体进行拓扑排序 let r: Vec> = self.target.topo_sort(); - let action = self.action.clone(); + let action = self.action; let dragonos_dir = self.sysroot_dir.clone(); let id2entity = self.target.id2entity(); let count = r.len(); @@ -437,13 +443,13 @@ impl Scheduler { handler.join().expect("Could not join deamon"); - return Ok(()); + Ok(()) } /// Action不需要按照拓扑序执行 fn run_without_topo_sort(&self) -> Result<(), SchedulerError> { // 启动守护线程 - let action = self.action.clone(); + let action = self.action; let dragonos_dir = self.sysroot_dir.clone(); let mut r = self.target.entities(); let handler = std::thread::spawn(move || { @@ -451,11 +457,11 @@ impl Scheduler { }); handler.join().expect("Could not join deamon"); - return Ok(()); + Ok(()) } pub fn execute(action: Action, dragonos_dir: PathBuf, entity: Arc) { - let mut executor = Executor::new(entity.clone(), action.clone(), dragonos_dir.clone()) + let mut executor = Executor::new(entity.clone(), action, dragonos_dir.clone()) .map_err(|e| { error!( "Error while creating executor for task {} : {:?}", @@ -512,7 +518,7 @@ impl Scheduler { // 将入度为0的任务实体加入任务队列中,直至没有入度为0的任务实体 或 任务队列满了 while !zero_entity.is_empty() && guard.build_install_task( - action.clone(), + action, dragonos_dir.clone(), zero_entity.last().unwrap().clone(), ) @@ -534,7 +540,7 @@ impl Scheduler { } return false; } - return true; + true }) } } @@ -564,10 +570,10 @@ impl Scheduler { for entity in self.target.entities().iter() { for dependency in entity.task().depends.iter() { let name_version = (dependency.name.clone(), dependency.version.clone()); - if !self + if self .target .get_by_name_version(&name_version.0, &name_version.1) - .is_some() + .is_none() { return Err(SchedulerError::DependencyNotFound( entity.clone(), @@ -577,7 +583,7 @@ impl Scheduler { } } - return Ok(()); + Ok(()) } } @@ -634,7 +640,7 @@ impl DependencyCycleError { let mut tmp = self.dependencies.clone(); tmp.reverse(); - let mut ret = format!("Dependency cycle detected: \nStart ->\n"); + let mut ret = "Dependency cycle detected: \nStart ->\n".to_string(); for (current, dep) in tmp.iter() { ret.push_str(&format!( "->\t{} ({})\t--depends-->\t{} ({})\n", @@ -645,6 +651,6 @@ impl DependencyCycleError { )); } ret.push_str("-> End"); - return ret; + ret } } diff --git a/dadk-user/src/scheduler/task_deque.rs b/dadk-user/src/scheduler/task_deque.rs index 90f50f4..bf0c70e 100644 --- a/dadk-user/src/scheduler/task_deque.rs +++ b/dadk-user/src/scheduler/task_deque.rs @@ -56,7 +56,7 @@ impl TaskDeque { self.queue.push(handler); return true; } - return false; + false } /// 将清理DADK任务添加到任务队列中 @@ -80,11 +80,11 @@ impl TaskDeque { } pub fn queue(&self) -> &Vec> { - return &self.queue; + &self.queue } pub fn queue_mut(&mut self) -> &mut Vec> { - return &mut self.queue; + &mut self.queue } pub fn set_thread(&mut self, mut thread: usize) { diff --git a/dadk-user/src/utils/lazy_init.rs b/dadk-user/src/utils/lazy_init.rs index 6a4d51c..6d31b08 100644 --- a/dadk-user/src/utils/lazy_init.rs +++ b/dadk-user/src/utils/lazy_init.rs @@ -33,6 +33,12 @@ pub struct Lazy { initialized: AtomicBool, } +impl Default for Lazy { + fn default() -> Self { + Self::new() + } +} + impl Lazy { /// Creates a new `Lazy` value that will be initialized with the /// result of the closure `init`. @@ -51,7 +57,7 @@ impl Lazy { if initialized { return true; } - return false; + false } /// Ensures that this lazy value is initialized. If the value has not @@ -84,7 +90,7 @@ impl Lazy { /// This will initialize the value if it has not yet been initialized. pub fn get(&self) -> &T { self.ensure(); - return unsafe { self.get_unchecked() }; + unsafe { self.get_unchecked() } } /// Returns a reference to the value if it has been initialized. @@ -93,7 +99,7 @@ impl Lazy { if self.initialized() { return Some(unsafe { self.get_unchecked() }); } - return None; + None } /// Forces the evaluation of this lazy value and returns a mutable @@ -102,17 +108,17 @@ impl Lazy { /// been initialized. pub fn get_mut(&mut self) -> &mut T { self.ensure(); - return unsafe { self.get_mut_unchecked() }; + unsafe { self.get_mut_unchecked() } } #[inline(always)] pub unsafe fn get_unchecked(&self) -> &T { - return &*(*self.value.get()).as_ptr(); + &*(*self.value.get()).as_ptr() } #[inline(always)] pub unsafe fn get_mut_unchecked(&mut self) -> &mut T { - return &mut *(*self.value.get()).as_mut_ptr(); + &mut *(*self.value.get()).as_mut_ptr() } } @@ -121,23 +127,23 @@ impl Deref for Lazy { #[inline(always)] fn deref(&self) -> &T { - return self.get(); + self.get() } } impl DerefMut for Lazy { #[inline(always)] fn deref_mut(&mut self) -> &mut T { - return self.get_mut(); + self.get_mut() } } impl Debug for Lazy { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { if let Some(value) = self.try_get() { - return write!(f, "Lazy({:?})", value); + write!(f, "Lazy({:?})", value) } else { - return write!(f, "Lazy(uninitialized)"); + write!(f, "Lazy(uninitialized)") } } } diff --git a/dadk-user/src/utils/path.rs b/dadk-user/src/utils/path.rs index 03cf607..1669e5c 100644 --- a/dadk-user/src/utils/path.rs +++ b/dadk-user/src/utils/path.rs @@ -1,7 +1,7 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; /// 获取给定路径的绝对路径 -pub fn abs_path(path: &PathBuf) -> PathBuf { +pub fn abs_path(path: &Path) -> PathBuf { if path.is_absolute() { path.to_path_buf() } else { diff --git a/dadk-user/src/utils/stdio.rs b/dadk-user/src/utils/stdio.rs index f4aa93f..f8c647e 100644 --- a/dadk-user/src/utils/stdio.rs +++ b/dadk-user/src/utils/stdio.rs @@ -4,7 +4,7 @@ impl StdioUtils { /// # 将标准错误输出转换为行列表 pub fn stderr_to_lines(stderr: &[u8]) -> Vec { let stderr = String::from_utf8_lossy(stderr); - return stderr.lines().map(|s| s.to_string()).collect(); + stderr.lines().map(|s| s.to_string()).collect() } /// 获取标准错误输出的最后n行, 以字符串形式返回. @@ -14,8 +14,8 @@ impl StdioUtils { let start = if lines.len() > n { lines.len() - n } else { 0 }; for line in lines.iter().skip(start) { result.push_str(line); - result.push_str("\n"); + result.push('\n'); } - return result; + result } } diff --git a/dadk/Cargo.toml b/dadk/Cargo.toml index 7c04294..90b404f 100644 --- a/dadk/Cargo.toml +++ b/dadk/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "xuzihao " ] -version = "0.3.0" +version = "0.3.1" edition = "2021" description = "DragonOS Application Development Kit\nDragonOS应用开发工具" license = "GPL-2.0-only" diff --git a/dadk/src/actions/profile/mod.rs b/dadk/src/actions/profile/mod.rs index f038728..239eb50 100644 --- a/dadk/src/actions/profile/mod.rs +++ b/dadk/src/actions/profile/mod.rs @@ -71,7 +71,7 @@ impl Sample { } fn push_new_line(&mut self, line: &str) { - if line.starts_with("#") { + if line.starts_with('#') { self.parse_frame_line(line); } else { self.parse_thread_line(line); @@ -81,7 +81,7 @@ impl Sample { fn parse_frame_line(&mut self, line: &str) { let line = line.trim(); // todo: 支持调整删除的`<>`的层级,以便打印更详细的信息 - let line = remove_angle_bracket_content(&line); + let line = remove_angle_bracket_content(line); let line = remove_guest_address(&line); let mut line = remove_rust_impl_pattern(&line); line = line.replace("(...)", ""); @@ -109,8 +109,10 @@ impl Sample { .unwrap(), ); - if !self.data.contains_key(&self.current_cpu.unwrap()) { - self.data.insert(self.current_cpu.unwrap(), Vec::new()); + if let std::collections::btree_map::Entry::Vacant(e) = + self.data.entry(self.current_cpu.unwrap()) + { + e.insert(Vec::new()); } else { log::error!( "current cpu {} is already set in hashmap", @@ -395,10 +397,10 @@ impl ToString for FoldedSampleBuffer { } } -impl Into for FoldedSampleBuffer { - fn into(self) -> SampleBuffer { +impl From for SampleBuffer { + fn from(val: FoldedSampleBuffer) -> Self { let mut samples = SampleBuffer::new(); - for (stack, count) in self.data { + for (stack, count) in val.data { let mut sample = Sample::new(0, 0); for frame in stack.split(';').rev() { sample.push_new_line(frame); diff --git a/dadk/src/actions/rootfs/disk_img.rs b/dadk/src/actions/rootfs/disk_img.rs index 3f38693..4fa3076 100644 --- a/dadk/src/actions/rootfs/disk_img.rs +++ b/dadk/src/actions/rootfs/disk_img.rs @@ -1,10 +1,27 @@ -use std::{fs::File, io::Write, mem::ManuallyDrop, path::PathBuf, process::Command}; +use std::path::Path; +use std::sync::OnceLock; +use std::{fs::File, io::Write, mem::ManuallyDrop, process::Command}; use crate::context::DADKExecContext; use anyhow::{anyhow, Result}; use dadk_config::rootfs::{fstype::FsType, partition::PartitionType}; -use super::loopdev::LoopDeviceBuilder; +use super::loopdev_v1::LoopDeviceBuilder as LoopDeviceBuilderV1; +use super::loopdev_v2::LoopDeviceBuilder as LoopDeviceBuilderV2; +use crate::actions::rootfs::BuilderVersion; +pub static BUILDER_VERSION: OnceLock = OnceLock::new(); + +pub fn set_builder_version(ctx: &DADKExecContext) { + let version = BuilderVersion::from_str(ctx.manifest().metadata.builder_version.as_str()); + BUILDER_VERSION + .set(version) + .expect("Failed to set builder version"); +} + +pub fn get_builder_version() -> BuilderVersion { + BUILDER_VERSION.get().cloned().unwrap_or(BuilderVersion::V1) +} + pub(super) fn create(ctx: &DADKExecContext, skip_if_exists: bool) -> Result<()> { let disk_image_path = ctx.disk_image_path(); if disk_image_path.exists() { @@ -36,7 +53,6 @@ pub(super) fn create(ctx: &DADKExecContext, skip_if_exists: bool) -> Result<()> } r } - pub(super) fn delete(ctx: &DADKExecContext, skip_if_not_exists: bool) -> Result<()> { let disk_image_path = ctx.disk_image_path(); if !disk_image_path.exists() { @@ -54,7 +70,6 @@ pub(super) fn delete(ctx: &DADKExecContext, skip_if_not_exists: bool) -> Result< .map_err(|e| anyhow!("Failed to remove disk image: {}", e))?; Ok(()) } - pub fn mount(ctx: &DADKExecContext) -> Result<()> { let disk_image_path = ctx.disk_image_path(); if !disk_image_path.exists() { @@ -79,33 +94,10 @@ pub fn mount(ctx: &DADKExecContext) -> Result<()> { log::info!("Disk image mounted at {}", disk_mount_path.display()); Ok(()) } - -fn mount_partitioned_image( - ctx: &DADKExecContext, - disk_image_path: &PathBuf, - disk_mount_path: &PathBuf, -) -> Result<()> { - let mut loop_device = ManuallyDrop::new( - LoopDeviceBuilder::new() - .img_path(disk_image_path.clone()) - .build() - .map_err(|e| anyhow!("Failed to create loop device: {}", e))?, - ); - - loop_device - .attach() - .map_err(|e| anyhow!("Failed to attach loop device: {}", e))?; - - let dev_path = loop_device.partition_path(1)?; - mount_unpartitioned_image(ctx, &dev_path, disk_mount_path)?; - - Ok(()) -} - fn mount_unpartitioned_image( _ctx: &DADKExecContext, - disk_image_path: &PathBuf, - disk_mount_path: &PathBuf, + disk_image_path: &Path, + disk_mount_path: &Path, ) -> Result<()> { let cmd = Command::new("mount") .arg(disk_image_path) @@ -120,64 +112,8 @@ fn mount_unpartitioned_image( } Ok(()) } - -pub fn umount(ctx: &DADKExecContext) -> Result<()> { - let disk_img_path = ctx.disk_image_path(); - let disk_mount_path = ctx.disk_mount_path(); - let mut loop_device = LoopDeviceBuilder::new().img_path(disk_img_path).build(); - - let should_detach_loop_device: bool; - if let Ok(loop_device) = loop_device.as_mut() { - if let Err(e) = loop_device.attach_by_exists() { - log::trace!("umount: Failed to attach loop device: {}", e); - } - - should_detach_loop_device = loop_device.attached(); - } else { - should_detach_loop_device = false; - } - - if disk_mount_path.exists() { - let cmd = Command::new("umount") - .arg(disk_mount_path) - .output() - .map_err(|e| anyhow!("Failed to umount disk image: {}", e)); - match cmd { - Ok(cmd) => { - if !cmd.status.success() { - let e = anyhow!( - "Failed to umount disk image: {}", - String::from_utf8_lossy(&cmd.stderr) - ); - if should_detach_loop_device { - log::error!("{}", e); - } else { - return Err(e); - } - } - } - Err(e) => { - if should_detach_loop_device { - log::error!("{}", e); - } else { - return Err(e); - } - } - } - } - - if let Ok(mut loop_device) = loop_device { - let loop_dev_path = loop_device.dev_path().cloned(); - loop_device.detach().ok(); - - log::info!("Loop device detached: {:?}", loop_dev_path); - } - - Ok(()) -} - /// Ensures the provided disk image path is not a device node. -fn disk_path_safety_check(disk_image_path: &PathBuf) -> Result<()> { +fn disk_path_safety_check(disk_image_path: &Path) -> Result<()> { const DONT_ALLOWED_PREFIX: [&str; 5] = ["/dev/sd", "/dev/hd", "/dev/vd", "/dev/nvme", "/dev/mmcblk"]; let path = disk_image_path.to_str().ok_or(anyhow!( @@ -192,33 +128,13 @@ fn disk_path_safety_check(disk_image_path: &PathBuf) -> Result<()> { Ok(()) } -fn create_partitioned_image(ctx: &DADKExecContext, disk_image_path: &PathBuf) -> Result<()> { - let part_type = ctx.rootfs().partition.partition_type; - DiskPartitioner::create_partitioned_image(disk_image_path, part_type)?; - // 挂载loop设备 - let mut loop_device = LoopDeviceBuilder::new() - .img_path(disk_image_path.clone()) - .build() - .map_err(|e| anyhow!("Failed to create loop device: {}", e))?; - loop_device - .attach() - .map_err(|e| anyhow!("Failed to attach loop device: {}", e))?; - - let partition_path = loop_device.partition_path(1)?; - let fs_type = ctx.rootfs().metadata.fs_type; - DiskFormatter::format_disk(&partition_path, &fs_type)?; - loop_device.detach()?; - Ok(()) -} - -fn create_unpartitioned_image(ctx: &DADKExecContext, disk_image_path: &PathBuf) -> Result<()> { +fn create_unpartitioned_image(ctx: &DADKExecContext, disk_image_path: &Path) -> Result<()> { // 直接对整块磁盘镜像进行格式化 let fs_type = ctx.rootfs().metadata.fs_type; DiskFormatter::format_disk(disk_image_path, &fs_type) } - /// 创建全0的raw镜像 -fn create_raw_img(disk_image_path: &PathBuf, image_size: usize) -> Result<()> { +fn create_raw_img(disk_image_path: &Path, image_size: usize) -> Result<()> { log::trace!("Creating raw disk image: {}", disk_image_path.display()); // 创建父目录 if let Some(parent) = disk_image_path.parent() { @@ -243,7 +159,6 @@ fn create_raw_img(disk_image_path: &PathBuf, image_size: usize) -> Result<()> { Ok(()) } - pub fn check_disk_image_exists(ctx: &DADKExecContext) -> Result<()> { let disk_image_path = ctx.disk_image_path(); if disk_image_path.exists() { @@ -259,22 +174,10 @@ pub fn show_mount_point(ctx: &DADKExecContext) -> Result<()> { println!("{}", disk_mount_path.display()); Ok(()) } - -pub fn show_loop_device(ctx: &DADKExecContext) -> Result<()> { - let disk_image_path = ctx.disk_image_path(); - let mut loop_device = LoopDeviceBuilder::new().img_path(disk_image_path).build()?; - if let Err(e) = loop_device.attach_by_exists() { - log::error!("Failed to attach loop device: {}", e); - } else { - println!("{}", loop_device.dev_path().unwrap()); - } - Ok(()) -} - struct DiskPartitioner; impl DiskPartitioner { - fn create_partitioned_image(disk_image_path: &PathBuf, part_type: PartitionType) -> Result<()> { + fn create_partitioned_image(disk_image_path: &Path, part_type: PartitionType) -> Result<()> { match part_type { PartitionType::None => { // This case should not be reached as we are in the partitioned image creation function @@ -292,7 +195,7 @@ impl DiskPartitioner { Ok(()) } - fn create_mbr_partitioned_image(disk_image_path: &PathBuf) -> Result<()> { + fn create_mbr_partitioned_image(disk_image_path: &Path) -> Result<()> { let disk_image_path_str = disk_image_path.to_str().expect("Invalid path"); // 检查 fdisk 是否存在 @@ -324,7 +227,7 @@ impl DiskPartitioner { Ok(()) } - fn create_gpt_partitioned_image(_disk_image_path: &PathBuf) -> Result<()> { + fn create_gpt_partitioned_image(_disk_image_path: &Path) -> Result<()> { // Implement the logic to create a GPT partitioned disk image // This is a placeholder for the actual implementation unimplemented!("Not implemented: create_gpt_partitioned_image"); @@ -334,13 +237,13 @@ impl DiskPartitioner { struct DiskFormatter; impl DiskFormatter { - fn format_disk(disk_image_path: &PathBuf, fs_type: &FsType) -> Result<()> { + fn format_disk(disk_image_path: &Path, fs_type: &FsType) -> Result<()> { match fs_type { FsType::Fat32 => Self::format_fat32(disk_image_path), } } - fn format_fat32(disk_image_path: &PathBuf) -> Result<()> { + fn format_fat32(disk_image_path: &Path) -> Result<()> { // Use the `mkfs.fat` command to format the disk image as FAT32 let status = Command::new("mkfs.fat") .arg("-F32") @@ -355,6 +258,216 @@ impl DiskFormatter { } } +fn mount_partitioned_image( + ctx: &DADKExecContext, + disk_image_path: &Path, + disk_mount_path: &Path, +) -> Result<()> { + match get_builder_version() { + BuilderVersion::V2 => mount_partitioned_image_v2(ctx, disk_image_path, disk_mount_path), + BuilderVersion::V1 => mount_partitioned_image_v1(ctx, disk_image_path, disk_mount_path), + } +} +fn create_partitioned_image(ctx: &DADKExecContext, disk_image_path: &Path) -> Result<()> { + match get_builder_version() { + BuilderVersion::V2 => create_partitioned_image_v2(ctx, disk_image_path), + BuilderVersion::V1 => create_partitioned_image_v1(ctx, disk_image_path), + } +} + +pub fn show_loop_device(ctx: &DADKExecContext) -> Result<()> { + match BUILDER_VERSION + .get() + .expect("Builder version is not set") + .clone() + { + BuilderVersion::V2 => show_loop_device_v2(ctx), + BuilderVersion::V1 => show_loop_device_v1(ctx), + } +} + +fn mount_partitioned_image_v1( + ctx: &DADKExecContext, + disk_image_path: &Path, + disk_mount_path: &Path, +) -> Result<()> { + let mut loop_device = ManuallyDrop::new( + LoopDeviceBuilderV1::new() + .img_path(disk_image_path) + .build() + .map_err(|e| anyhow!("Failed to create loop device: {}", e))?, + ); + + loop_device.set_try_detach_when_drop(false); + + loop_device + .attach() + .map_err(|e| anyhow!("mount: Failed to attach loop device: {}", e))?; + + let dev_path = loop_device.partition_path(1)?; + mount_unpartitioned_image(ctx, &dev_path, disk_mount_path)?; + + Ok(()) +} +fn mount_partitioned_image_v2( + ctx: &DADKExecContext, + disk_image_path: &Path, + disk_mount_path: &Path, +) -> Result<()> { + let loop_device = ManuallyDrop::new( + LoopDeviceBuilderV2::new() + .img_path(disk_image_path) + .detach_on_drop(false) + .build() + .map_err(|e| anyhow!("Failed to create loop device: {}", e))?, + ); + + let dev_path = loop_device.partition_path(1)?; + mount_unpartitioned_image(ctx, &dev_path, disk_mount_path)?; + + Ok(()) +} +pub fn umount(ctx: &DADKExecContext) -> Result<()> { + match get_builder_version() { + BuilderVersion::V2 => umount_v2(ctx), + BuilderVersion::V1 => umount_v1(ctx), + } +} +pub fn umount_v1(ctx: &DADKExecContext) -> Result<()> { + let disk_img_path = ctx.disk_image_path(); + let disk_mount_path = ctx.disk_mount_path(); + let mut loop_device = LoopDeviceBuilderV1::new().img_path(&disk_img_path).build(); + let should_detach_loop_device: bool; + if let Ok(loop_device) = loop_device.as_mut() { + if let Err(e) = loop_device.attach_by_exists() { + log::trace!("umount: Failed to attach loop device: {}", e); + } + + should_detach_loop_device = loop_device.attached(); + } else { + should_detach_loop_device = false; + } + + if disk_mount_path.exists() { + let cmd = Command::new("umount") + .arg(disk_mount_path) + .output() + .map_err(|e| anyhow!("Failed to umount disk image: {}", e)); + match cmd { + Ok(cmd) => { + if !cmd.status.success() { + let e = anyhow!( + "Failed to umount disk image: {}", + String::from_utf8_lossy(&cmd.stderr) + ); + if should_detach_loop_device { + log::error!("{}", e); + } else { + return Err(e); + } + } + } + Err(e) => { + if should_detach_loop_device { + log::error!("{}", e); + } else { + return Err(e); + } + } + } + } + + if let Ok(loop_device) = loop_device { + let loop_dev_path = loop_device.dev_path().cloned(); + + log::info!("Loop device going to detached: {:?}", loop_dev_path); + } + + Ok(()) +} +pub fn umount_v2(ctx: &DADKExecContext) -> Result<()> { + let disk_img_path = ctx.disk_image_path(); + let disk_mount_path = ctx.disk_mount_path(); + + if disk_mount_path.exists() { + log::trace!("Unmounted disk image at {}", disk_mount_path.display()); + + let cmd = Command::new("umount").arg(disk_mount_path).output()?; + + if !cmd.status.success() { + return Err(anyhow!( + "Failed to umount disk image: {}", + String::from_utf8_lossy(&cmd.stderr) + )); + } + + let loop_device = LoopDeviceBuilderV2::new() + .img_path(&disk_img_path) + .detach_on_drop(true) + .build()?; + // the loop device will be detached automatically when _loop_device is dropped + log::trace!("Detaching {}", loop_device.dev_path()); + Ok(()) + } else { + Err(anyhow!( + "Disk image mount point does not exist: {}", + disk_mount_path.display() + )) + } +} +fn create_partitioned_image_v1(ctx: &DADKExecContext, disk_image_path: &Path) -> Result<()> { + let part_type = ctx.rootfs().partition.partition_type; + DiskPartitioner::create_partitioned_image(disk_image_path, part_type)?; + // 挂载loop设备 + let mut loop_device = LoopDeviceBuilderV1::new() + .img_path(disk_image_path) + .build() + .map_err(|e| anyhow!("Failed to create loop device: {}", e))?; + loop_device + .attach() + .map_err(|e| anyhow!("creat: Failed to attach loop device: {}", e))?; + + let partition_path = loop_device.partition_path(1)?; + let fs_type = ctx.rootfs().metadata.fs_type; + DiskFormatter::format_disk(&partition_path, &fs_type)?; + Ok(()) +} +fn create_partitioned_image_v2(ctx: &DADKExecContext, disk_image_path: &Path) -> Result<()> { + let part_type = ctx.rootfs().partition.partition_type; + DiskPartitioner::create_partitioned_image(disk_image_path, part_type)?; + // 挂载loop设备 + let loop_device = LoopDeviceBuilderV2::new() + .img_path(disk_image_path) + .detach_on_drop(false) + .build()?; + + let partition_path = loop_device.partition_path(1)?; + let fs_type = ctx.rootfs().metadata.fs_type; + DiskFormatter::format_disk(&partition_path, &fs_type)?; + Ok(()) +} +pub fn show_loop_device_v1(ctx: &DADKExecContext) -> Result<()> { + let disk_image_path = ctx.disk_image_path(); + let mut loop_device = LoopDeviceBuilderV1::new() + .img_path(&disk_image_path) + .build()?; + loop_device.set_try_detach_when_drop(false); + if let Err(e) = loop_device.attach_by_exists() { + log::error!("Failed to attach loop device: {}", e); + } else { + println!("{}", loop_device.dev_path().unwrap()); + } + Ok(()) +} +pub fn show_loop_device_v2(ctx: &DADKExecContext) -> Result<()> { + let disk_image_path = ctx.disk_image_path(); + let loop_device = LoopDeviceBuilderV2::new() + .img_path(&disk_image_path) + .detach_on_drop(false) + .build()?; + println!("{}", loop_device.dev_path()); + Ok(()) +} #[cfg(test)] mod tests { use super::*; diff --git a/dadk/src/actions/rootfs/loopdev.rs b/dadk/src/actions/rootfs/loopdev_v1.rs similarity index 97% rename from dadk/src/actions/rootfs/loopdev.rs rename to dadk/src/actions/rootfs/loopdev_v1.rs index 76c02e8..4958506 100644 --- a/dadk/src/actions/rootfs/loopdev.rs +++ b/dadk/src/actions/rootfs/loopdev_v1.rs @@ -1,5 +1,10 @@ use core::str; -use std::{path::PathBuf, process::Command, thread::sleep, time::Duration}; +use std::{ + path::{Path, PathBuf}, + process::Command, + thread::sleep, + time::Duration, +}; use anyhow::{anyhow, Result}; use regex::Regex; @@ -171,8 +176,8 @@ impl LoopDeviceBuilder { } } - pub fn img_path(mut self, img_path: PathBuf) -> Self { - self.img_path = Some(abs_path(&img_path)); + pub fn img_path(mut self, img_path: &Path) -> Self { + self.img_path = Some(abs_path(img_path)); self } diff --git a/dadk/src/actions/rootfs/loopdev_v2.rs b/dadk/src/actions/rootfs/loopdev_v2.rs new file mode 100644 index 0000000..4838f64 --- /dev/null +++ b/dadk/src/actions/rootfs/loopdev_v2.rs @@ -0,0 +1,450 @@ +use core::str; +use std::{ + path::{Path, PathBuf}, + process::Command, + thread::sleep, + time::Duration, +}; + +use regex::Regex; + +use crate::utils::abs_path; + +const LOOP_DEVICE_LOSETUP_A_REGEX: &str = r"^/dev/loop(\d+)"; + +pub struct LoopDevice { + path: PathBuf, + detach_on_drop: bool, + mapper: Mapper, +} + +impl LoopDevice { + fn new(img_path: PathBuf, detach_on_drop: bool) -> Result { + if !img_path.exists() { + return Err(LoopError::ImageNotFound); + } + let str_img_path = img_path.to_str().ok_or(LoopError::InvalidUtf8)?; + + let may_attach = attach_exists_loop_by_image(str_img_path); + + let loop_device_path = match may_attach { + Ok(loop_device_path) => { + log::trace!("Loop device already attached: {}", loop_device_path); + loop_device_path + } + Err(LoopError::LoopDeviceNotFound) => { + log::trace!("No loop device found, try to attach"); + attach_loop_by_image(str_img_path)? + } + Err(err) => { + log::error!("Failed to attach loop device: {}", err); + return Err(err); + } + }; + + let path = PathBuf::from(loop_device_path); + sleep(Duration::from_millis(100)); + if !path.exists() { + return Err(LoopError::LoopDeviceNotFound); + } + + let mapper = Mapper::new(path.clone(), detach_on_drop).map_err(|err| { + log::error!("No loop mapper is available: {}", err); + let _ = LosetupCmd::new() + .arg("-d") + .arg(path.to_str().unwrap()) + .output(); + err + })?; + + Ok(Self { + path, + detach_on_drop, + mapper, + }) + } + + pub fn dev_path(&self) -> String { + self.path.to_string_lossy().to_string() + } + + pub fn partition_path(&self, nth: u8) -> Result { + self.mapper.partition_path(nth) + } +} +impl Drop for LoopDevice { + fn drop(&mut self) { + if !self.detach_on_drop { + return; + } + log::trace!( + "Detach loop device: {}, exists: {}", + &self.path.display(), + self.path.exists() + ); + if self.path.exists() { + let path = self.path.to_string_lossy(); + if let Err(err) = LosetupCmd::new().arg("-d").arg(&path).output() { + log::error!("Failed to detach loop device: {}", err); + } + } + } +} + +pub struct LoopDeviceBuilder { + img_path: Option, + detach_on_drop: bool, +} + +impl LoopDeviceBuilder { + pub fn new() -> Self { + LoopDeviceBuilder { + img_path: None, + detach_on_drop: true, + } + } + + pub fn img_path(mut self, img_path: &Path) -> Self { + self.img_path = Some(abs_path(img_path)); + self + } + + #[allow(dead_code)] + pub fn detach_on_drop(mut self, detach_on_drop: bool) -> Self { + self.detach_on_drop = detach_on_drop; + self + } + + pub fn build(self) -> Result { + if self.img_path.is_none() { + return Err(LoopError::ImageNotFound); + } + + let img_path = self.img_path.unwrap(); + + log::trace!( + "Try to attach loop device by exists: image path: {}", + img_path.display() + ); + + let loop_device = LoopDevice::new(img_path, self.detach_on_drop)?; + Ok(loop_device) + } +} + +fn __loop_device_path_by_disk_image_path( + disk_img_path: &str, + losetup_a_output: &str, +) -> Result { + let re = Regex::new(LOOP_DEVICE_LOSETUP_A_REGEX).unwrap(); + for line in losetup_a_output.lines() { + if !line.contains(disk_img_path) { + continue; + } + let caps = re.captures(line); + if caps.is_none() { + continue; + } + let caps = caps.unwrap(); + let loop_device = caps.get(1).unwrap().as_str().trim(); + let loop_device = format!("/dev/loop{}", loop_device); + return Ok(loop_device); + } + Err(LoopError::LoopDeviceNotFound) +} +#[derive(Debug)] +pub enum LoopError { + InvalidUtf8, + ImageNotFound, + LoopDeviceNotFound, + NoMapperAvailable, + NoPartitionAvailable, + Losetup(String), + Kpartx(String), + #[allow(dead_code)] + Other(anyhow::Error), +} + +impl From for LoopError { + fn from(_: std::string::FromUtf8Error) -> Self { + LoopError::InvalidUtf8 + } +} + +impl std::fmt::Display for LoopError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + LoopError::InvalidUtf8 => write!(f, "Invalid UTF-8"), + LoopError::ImageNotFound => write!(f, "Image not found"), + LoopError::LoopDeviceNotFound => write!(f, "Loop device not found"), + LoopError::NoMapperAvailable => write!(f, "No mapper available"), + LoopError::NoPartitionAvailable => write!(f, "No partition available"), + LoopError::Losetup(err) => write!(f, "Losetup error: {}", err), + LoopError::Kpartx(err) => write!(f, "Kpartx error: {}", err), + LoopError::Other(err) => write!(f, "Other error: {}", err), + } + } +} + +impl std::error::Error for LoopError {} + +fn attach_loop_by_image(img_path: &str) -> Result { + LosetupCmd::new() + .arg("-f") + .arg("--show") + .arg("-P") + .arg(img_path) + .output() + .map(|output_path| output_path.trim().to_string()) +} + +fn attach_exists_loop_by_image(img_path: &str) -> Result { + // losetup -a 查看是否有已经attach了的,如果有,就附着上去 + let output = LosetupCmd::new().arg("-a").output()?; + + __loop_device_path_by_disk_image_path(img_path, &output) +} + +struct LosetupCmd { + inner: Command, +} + +impl LosetupCmd { + fn new() -> Self { + LosetupCmd { + inner: Command::new("losetup"), + } + } + + fn arg(&mut self, arg: &str) -> &mut Self { + self.inner.arg(arg); + self + } + + fn output(&mut self) -> Result { + let output = self + .inner + .output() + .map_err(|e| LoopError::Losetup(e.to_string()))?; + if output.status.success() { + let stdout = String::from_utf8(output.stdout)?; + Ok(stdout) + } else { + Err(LoopError::Losetup(format!( + "losetup failed: {}", + String::from_utf8_lossy(&output.stderr) + ))) + } + } +} + +struct Mapper { + dev_path: PathBuf, + detach_on_drop: bool, + use_kpartx: bool, + partitions: Vec, +} + +impl Mapper { + fn new(path: PathBuf, detach_on_drop: bool) -> Result { + // check if raw part mapper is available, if {device_dir}/loopXpX + let mut parts = Vec::new(); + let partition_name_prefix = format!("{}p", path.file_name().unwrap().to_str().unwrap()); + let device_dir = path.parent().unwrap(); + + for entry in device_dir.read_dir().unwrap().flatten() { + let entry = entry.file_name().into_string().unwrap(); + if entry.starts_with(&partition_name_prefix) { + parts.push(entry); + } + } + + if !parts.is_empty() { + log::trace!("Found raw part mapper: {:?}", parts); + return Ok(Self { + dev_path: path.to_path_buf(), + detach_on_drop, + partitions: parts, + use_kpartx: false, + }); + } + + // check if mapper is created, found if {device_dir}/mapper/loopX + let mapper_path = device_dir.join("mapper"); + + for entry in mapper_path.read_dir().unwrap().flatten() { + let entry = entry.file_name().into_string().unwrap(); + if entry.starts_with(&partition_name_prefix) { + parts.push(entry); + } + } + + if !parts.is_empty() { + log::trace!("Found kpartx mapper exist: {:?}", parts); + return Ok(Self { + dev_path: path, + detach_on_drop, + partitions: parts, + use_kpartx: true, + }); + } + + KpartxCmd::new() + .arg("-a") + .arg(path.to_str().unwrap()) + .output()?; + for entry in mapper_path.read_dir().unwrap().flatten() { + let entry = entry.file_name().into_string().unwrap(); + if entry.starts_with(&partition_name_prefix) { + parts.push(entry); + } + } + + if !parts.is_empty() { + log::trace!("New kpartx with parts: {:?}", parts); + return Ok(Self { + dev_path: path, + detach_on_drop, + partitions: parts, + use_kpartx: true, + }); + } + + Err(LoopError::NoMapperAvailable) + } + + fn partition_path(&self, nth: u8) -> Result { + if self.partitions.is_empty() { + // unlikely, already checked in new() + log::warn!("No partition available, but the mapper device exists!"); + return Err(LoopError::NoPartitionAvailable); + } + let map_root = if !self.use_kpartx { + self.dev_path + .parent() + .unwrap() + .to_string_lossy() + .into_owned() + } else { + // kpartx mapper device + self.dev_path + .with_file_name("mapper") + .to_string_lossy() + .into_owned() + }; + let partition = PathBuf::from(format!( + "{}/{}", + map_root, + self.partitions + .get((nth - 1) as usize) + .ok_or(LoopError::NoPartitionAvailable)?, + )); + if !partition.exists() { + log::warn!("Partition exists, but the specified partition does not exist!"); + log::warn!("Available partitions: {:?}", self.partitions); + log::warn!("Try to find partition: {}", partition.display()); + return Err(LoopError::NoPartitionAvailable); + } + Ok(partition) + } +} + +impl Drop for Mapper { + fn drop(&mut self) { + if !self.detach_on_drop { + return; + } + if self.dev_path.exists() { + let path = self.dev_path.to_string_lossy(); + if self.use_kpartx { + if let Err(err) = KpartxCmd::new().arg("-d").arg(&path).output() { + log::error!("Failed to detach mapper device: {}", err); + } + } + } + } +} + +struct KpartxCmd { + inner: Command, +} + +impl KpartxCmd { + fn new() -> Self { + KpartxCmd { + inner: Command::new("kpartx"), + } + } + + fn arg(&mut self, arg: &str) -> &mut Self { + self.inner.arg(arg); + self + } + + fn output(&mut self) -> Result { + let output = self + .inner + .output() + .map_err(|e| LoopError::Kpartx(e.to_string()))?; + if output.status.success() { + let stdout = String::from_utf8(output.stdout)?; + Ok(stdout) + } else { + Err(LoopError::Kpartx(format!( + "kpartx failed execute: {:?}, Result: {}", + self.inner.get_args(), + String::from_utf8_lossy(&output.stderr) + ))) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_regex_find_loop_device() { + const DEVICE_NAME_SHOULD_MATCH: [&str; 3] = + ["/dev/loop11", "/dev/loop11p1", "/dev/loop11p1 "]; + let device_name = "/dev/loop11"; + let re = Regex::new(LOOP_DEVICE_LOSETUP_A_REGEX).unwrap(); + for name in DEVICE_NAME_SHOULD_MATCH { + assert!(re.find(name).is_some(), "{} should match", name); + assert_eq!( + re.find(name).unwrap().as_str(), + device_name, + "{} should match {}", + name, + device_name + ); + } + } + + #[test] + fn test_parse_losetup_a_output() { + let losetup_a_output = r#"/dev/loop1: []: (/data/bin/x86_64/disk.img) +/dev/loop29: []: (/var/lib/abc.img) +/dev/loop13: []: (/var/lib/snapd/snaps/gtk-common-themes_1535.snap +/dev/loop19: []: (/var/lib/snapd/snaps/gnome-42-2204_172.snap)"#; + let disk_img_path = "/data/bin/x86_64/disk.img"; + let loop_device_path = + __loop_device_path_by_disk_image_path(disk_img_path, losetup_a_output).unwrap(); + assert_eq!(loop_device_path, "/dev/loop1"); + } + + #[test] + fn test_parse_lsblk_output_not_match() { + let losetup_a_output = r#"/dev/loop1: []: (/data/bin/x86_64/disk.img) +/dev/loop29: []: (/var/lib/abc.img) +/dev/loop13: []: (/var/lib/snapd/snaps/gtk-common-themes_1535.snap +/dev/loop19: []: (/var/lib/snapd/snaps/gnome-42-2204_172.snap)"#; + let disk_img_path = "/data/bin/riscv64/disk.img"; + let loop_device_path = + __loop_device_path_by_disk_image_path(disk_img_path, losetup_a_output); + assert!( + loop_device_path.is_err(), + "should not match any loop device" + ); + } +} diff --git a/dadk/src/actions/rootfs/mod.rs b/dadk/src/actions/rootfs/mod.rs index 7c84e86..95fd8a7 100644 --- a/dadk/src/actions/rootfs/mod.rs +++ b/dadk/src/actions/rootfs/mod.rs @@ -1,11 +1,26 @@ use crate::{console::rootfs::RootFSCommand, context::DADKExecContext}; use anyhow::Result; +use disk_img::set_builder_version; -mod disk_img; -mod loopdev; +pub mod disk_img; +mod loopdev_v1; +mod loopdev_v2; mod sysroot; - -pub(super) fn run(ctx: &DADKExecContext, rootfs_cmd: &RootFSCommand) -> Result<()> { +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum BuilderVersion { + V1, + V2, +} +impl BuilderVersion { + fn from_str(version: &str) -> Self { + match version { + "v2" => BuilderVersion::V2, + "v1" | _ => BuilderVersion::V1, + } + } +} +pub fn run(ctx: &DADKExecContext, rootfs_cmd: &RootFSCommand) -> Result<()> { + set_builder_version(ctx); match rootfs_cmd { RootFSCommand::Create(param) => disk_img::create(ctx, param.skip_if_exists), RootFSCommand::Delete => disk_img::delete(ctx, false), diff --git a/dadk/src/actions/rootfs/sysroot.rs b/dadk/src/actions/rootfs/sysroot.rs index 9a33400..2a868e0 100644 --- a/dadk/src/actions/rootfs/sysroot.rs +++ b/dadk/src/actions/rootfs/sysroot.rs @@ -15,7 +15,7 @@ pub(super) fn delete(ctx: &DADKExecContext) -> Result<()> { } // 检查 sysroot_dir 是否是当前工作目录的子目录 - if !sysroot_dir.starts_with(&ctx.workdir()) { + if !sysroot_dir.starts_with(ctx.workdir()) { return Err(anyhow!( "Sysroot directory must be a subdirectory of the current working directory" )); diff --git a/dadk/src/console/mod.rs b/dadk/src/console/mod.rs index d065621..1aaf90c 100644 --- a/dadk/src/console/mod.rs +++ b/dadk/src/console/mod.rs @@ -51,6 +51,6 @@ impl Action { if matches!(self, Action::Profile(_)) { return false; } - return true; + true } } diff --git a/dadk/src/console/profile.rs b/dadk/src/console/profile.rs index 7adcfc5..3b02516 100644 --- a/dadk/src/console/profile.rs +++ b/dadk/src/console/profile.rs @@ -16,7 +16,7 @@ pub struct ProfileSampleArgs { #[clap( long = "kernel", help = "Path to the kernel image to use", - default_value = "./bin/kernel/kernel.elf" + // default_value = "./bin/kernel/kernel.elf" )] pub kernel: PathBuf, #[clap( diff --git a/dadk/src/console/tests.rs b/dadk/src/console/tests.rs index ea010ee..a17bc97 100644 --- a/dadk/src/console/tests.rs +++ b/dadk/src/console/tests.rs @@ -5,7 +5,7 @@ use super::*; #[test] fn test_command_line_args_default() { - let args = CommandLineArgs::parse_from(&["dadk", "kernel"]); + let args = CommandLineArgs::parse_from(["dadk", "kernel"]); assert_eq!(args.action, Action::Kernel); assert_eq!(args.manifest_path, "dadk-manifest.toml"); } @@ -13,19 +13,19 @@ fn test_command_line_args_default() { #[test] fn test_command_line_args_with_manifest() { // test short - let args = CommandLineArgs::parse_from(&["dadk", "-f", "custom-manifest.toml", "kernel"]); + let args = CommandLineArgs::parse_from(["dadk", "-f", "custom-manifest.toml", "kernel"]); assert_eq!(args.action, Action::Kernel); assert_eq!(args.manifest_path, "custom-manifest.toml"); // test long let args = - CommandLineArgs::parse_from(&["dadk", "--manifest", "custom-manifest.toml", "kernel"]); + CommandLineArgs::parse_from(["dadk", "--manifest", "custom-manifest.toml", "kernel"]); assert_eq!(args.action, Action::Kernel); assert_eq!(args.manifest_path, "custom-manifest.toml"); } #[test] fn test_command_line_args_rootfs_subcommand() { - let args = CommandLineArgs::parse_from(&["dadk", "rootfs", "create"]); + let args = CommandLineArgs::parse_from(["dadk", "rootfs", "create"]); assert!(matches!( args.action, Action::Rootfs(RootFSCommand::Create(CreateCommandParam { @@ -33,7 +33,7 @@ fn test_command_line_args_rootfs_subcommand() { })) )); - let args = CommandLineArgs::parse_from(&["dadk", "rootfs", "create", "--skip-if-exists"]); + let args = CommandLineArgs::parse_from(["dadk", "rootfs", "create", "--skip-if-exists"]); assert!(matches!( args.action, Action::Rootfs(RootFSCommand::Create(CreateCommandParam { @@ -44,7 +44,7 @@ fn test_command_line_args_rootfs_subcommand() { #[test] fn test_show_mountpoint() { - let args = CommandLineArgs::parse_from(&["dadk", "rootfs", "show-mountpoint"]); + let args = CommandLineArgs::parse_from(["dadk", "rootfs", "show-mountpoint"]); assert!(matches!( args.action, Action::Rootfs(RootFSCommand::ShowMountPoint) @@ -53,7 +53,7 @@ fn test_show_mountpoint() { #[test] fn test_command_line_args_user() { - let args = CommandLineArgs::parse_from(&["dadk", "user", "build"]); + let args = CommandLineArgs::parse_from(["dadk", "user", "build"]); assert!(matches!(args.action, Action::User(UserCommand::Build))); } @@ -61,7 +61,7 @@ fn test_command_line_args_user() { /// 该函数测试CommandLineArgs解析器是否正确解析`dadk user clean`命令 #[test] fn test_command_line_args_user_clean() { - let args = CommandLineArgs::parse_from(&["dadk", "user", "clean"]); + let args = CommandLineArgs::parse_from(["dadk", "user", "clean"]); assert!(matches!(args.action, Action::User(UserCommand::Clean(_)))); if let Action::User(UserCommand::Clean(args)) = args.action { assert_eq!(args.level, UserCleanLevel::All); @@ -70,7 +70,7 @@ fn test_command_line_args_user_clean() { } // 检查 `--level` 参数 - let args = CommandLineArgs::parse_from(&["dadk", "user", "clean", "--level", "in-src"]); + let args = CommandLineArgs::parse_from(["dadk", "user", "clean", "--level", "in-src"]); if let Action::User(UserCommand::Clean(args)) = args.action { assert_eq!(args.level, UserCleanLevel::InSrc); } else { @@ -78,7 +78,7 @@ fn test_command_line_args_user_clean() { } // 检查 `--task` 参数 - let args = CommandLineArgs::parse_from(&["dadk", "user", "clean", "--task", "a-0.1.0"]); + let args = CommandLineArgs::parse_from(["dadk", "user", "clean", "--task", "a-0.1.0"]); if let Action::User(UserCommand::Clean(args)) = args.action { assert_eq!(args.task, Some("a-0.1.0".to_string())); } else { diff --git a/dadk/src/console/user.rs b/dadk/src/console/user.rs index 2914049..9fa6c18 100644 --- a/dadk/src/console/user.rs +++ b/dadk/src/console/user.rs @@ -27,9 +27,9 @@ pub enum UserCleanLevel { Output, } -impl Into for UserCleanLevel { - fn into(self) -> dadk_config::user::UserCleanLevel { - match self { +impl From for dadk_config::user::UserCleanLevel { + fn from(val: UserCleanLevel) -> Self { + match val { UserCleanLevel::All => dadk_config::user::UserCleanLevel::All, UserCleanLevel::InSrc => dadk_config::user::UserCleanLevel::InSrc, UserCleanLevel::Output => dadk_config::user::UserCleanLevel::Output, @@ -37,9 +37,9 @@ impl Into for UserCleanLevel { } } -impl Into for UserCommand { - fn into(self) -> dadk_user::context::Action { - match self { +impl From for dadk_user::context::Action { + fn from(val: UserCommand) -> Self { + match val { UserCommand::Build => dadk_user::context::Action::Build, UserCommand::Install => dadk_user::context::Action::Install, UserCommand::Clean(args) => dadk_user::context::Action::Clean(args.level.into()), diff --git a/dadk/src/context/mod.rs b/dadk/src/context/mod.rs index 54fc3ef..e67a5a6 100644 --- a/dadk/src/context/mod.rs +++ b/dadk/src/context/mod.rs @@ -1,3 +1,4 @@ +use std::path::Path; use std::{cell::OnceCell, path::PathBuf}; use anyhow::Result; @@ -8,11 +9,12 @@ use dadk_config::{ use derive_builder::Builder; use manifest::parse_manifest; +use crate::actions::rootfs::disk_img::get_builder_version; +use crate::actions::rootfs::BuilderVersion; use crate::{ console::CommandLineArgs, utils::{abs_path, check_dir_exists}, }; - mod manifest; /// DADK的执行上下文 @@ -43,12 +45,12 @@ pub fn build_exec_context() -> Result { impl DADKExecContext { /// 获取工作目录的绝对路径 pub fn workdir(&self) -> PathBuf { - abs_path(&PathBuf::from(&self.command.workdir)) + abs_path(Path::new(&self.command.workdir)) } /// 设置进程的工作目录 fn setup_workdir(&self) -> Result<()> { - std::env::set_current_dir(&self.workdir()).expect("Failed to set current directory"); + std::env::set_current_dir(self.workdir()).expect("Failed to set current directory"); Ok(()) } /// Get rootfs configuration @@ -68,7 +70,7 @@ impl DADKExecContext { /// If the directory does not exist, or the path is not a folder, an error is returned pub fn sysroot_dir(&self) -> Result { check_dir_exists(&self.manifest().metadata.sysroot_dir) - .map(|p| p.clone()) + .cloned() .map_err(|e| anyhow::anyhow!("Failed to get sysroot dir: {}", e)) } @@ -77,14 +79,14 @@ impl DADKExecContext { /// If the directory does not exist, or the path is not a folder, an error is returned pub fn cache_root_dir(&self) -> Result { check_dir_exists(&self.manifest().metadata.cache_root_dir) - .map(|p| p.clone()) + .cloned() .map_err(|e| anyhow::anyhow!("Failed to get cache root dir: {}", e)) } #[deprecated] pub fn user_config_dir(&self) -> Result { check_dir_exists(&self.manifest().metadata.user_config_dir) - .map(|p| p.clone()) + .cloned() .map_err(|e| anyhow::anyhow!("Failed to get user config dir: {}", e)) } @@ -92,19 +94,43 @@ impl DADKExecContext { self.manifest().metadata.arch } - /// 获取磁盘镜像的路径,路径由工作目录、架构和固定文件名组成 pub fn disk_image_path(&self) -> PathBuf { + match get_builder_version() { + BuilderVersion::V1 => self.disk_image_path_v1(), + BuilderVersion::V2 => self.disk_image_path_v2(), + } + } + /// 获取磁盘镜像的路径,路径由工作目录、架构和固定文件名组成 + pub fn disk_image_path_v2(&self) -> PathBuf { self.workdir() - .join(format!("bin/{}.img", self.disk_image_basename())) + .join(format!("bin/{}/disk.img", self.target_arch())) //这个是新版本路径 } /// 获取磁盘挂载路径 + pub fn disk_image_path_v1(&self) -> PathBuf { + self.workdir() + .join(format!("bin/{}.img", self.disk_image_basename_v1())) //这个是旧版本路径 + } + pub fn disk_mount_path(&self) -> PathBuf { + match get_builder_version() { + BuilderVersion::V1 => self.disk_mount_path_v1(), + BuilderVersion::V2 => self.disk_mount_path_v2(), + } + } + + pub fn disk_mount_path_v2(&self) -> PathBuf { + self.workdir() + .join(format!("bin/{}/mnt", self.target_arch())) + } + + /// 获取磁盘挂载路径 + pub fn disk_mount_path_v1(&self) -> PathBuf { self.workdir() - .join(format!("bin/mnt/{}", self.disk_image_basename())) + .join(format!("bin/mnt/{}", self.disk_image_basename_v1())) } - fn disk_image_basename(&self) -> String { + fn disk_image_basename_v1(&self) -> String { let arch: String = self.target_arch().into(); format!("disk-image-{}", arch) } diff --git a/dadk/src/utils.rs b/dadk/src/utils.rs index 53945aa..00ad1a3 100644 --- a/dadk/src/utils.rs +++ b/dadk/src/utils.rs @@ -1,9 +1,9 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use anyhow::{anyhow, Result}; /// 检查目录是否存在 -pub(super) fn check_dir_exists<'a>(path: &'a PathBuf) -> Result<&'a PathBuf> { +pub(super) fn check_dir_exists(path: &PathBuf) -> Result<&PathBuf> { if !path.exists() { return Err(anyhow!("Path '{}' not exists", path.display())); } @@ -11,11 +11,11 @@ pub(super) fn check_dir_exists<'a>(path: &'a PathBuf) -> Result<&'a PathBuf> { return Err(anyhow!("Path '{}' is not a directory", path.display())); } - return Ok(path); + Ok(path) } /// 获取给定路径的绝对路径 -pub fn abs_path(path: &PathBuf) -> PathBuf { +pub fn abs_path(path: &Path) -> PathBuf { if path.is_absolute() { path.to_path_buf() } else { diff --git a/tests/data/dadk-manifest.toml b/tests/data/dadk-manifest.toml index 9e7d79e..d2575fa 100644 --- a/tests/data/dadk-manifest.toml +++ b/tests/data/dadk-manifest.toml @@ -5,6 +5,11 @@ # Target architecture. Options: x86_64, riscv64 arch = "x86_64" +# Builer version, affect the behavior of image generation +# Options: v1, v2 +# Default: v1, to be compatible with the old version +builder-version = "v2" + # Hypervisor config path hypervisor-config = "config/hypervisor.toml"