cargo vendor

This commit is contained in:
Сергей Конев 2024-10-28 18:16:01 +03:00
parent e0cff923ae
commit 685ab6f86c
4513 changed files with 1246903 additions and 75043 deletions

View File

@ -1,20 +1,24 @@
# [source.crates-io]
# replace-with = "vendored-sources"
[source.crates-io]
replace-with = "vendored-sources"
# [source."git+git://git.proxmox.com/git/perlmod.git"]
# git = "git://git.proxmox.com/git/perlmod.git"
# replace-with = "vendored-sources"
[source."git+git://git.proxmox.com/git/perlmod.git"]
git = "git://git.proxmox.com/git/perlmod.git"
replace-with = "vendored-sources"
# [source."git+git://git.proxmox.com/git/proxmox-resource-scheduling.git"]
# git = "git://git.proxmox.com/git/proxmox-resource-scheduling.git"
# replace-with = "vendored-sources"
[source."git+git://git.proxmox.com/git/proxmox-resource-scheduling.git"]
git = "git://git.proxmox.com/git/proxmox-resource-scheduling.git"
replace-with = "vendored-sources"
# [source."git+https://gitea.basealt.ru/konevsa/proxmox.newest.git"]
# git = "https://gitea.basealt.ru/konevsa/proxmox.newest.git"
# replace-with = "vendored-sources"
[source."git+https://gitea.basealt.ru/konevsa/apt-pkg-native"]
git = "https://gitea.basealt.ru/konevsa/apt-pkg-native"
replace-with = "vendored-sources"
# [source.vendored-sources]
# directory = "vendor"
[source."git+https://gitea.basealt.ru/konevsa/proxmox.newest.git"]
git = "https://gitea.basealt.ru/konevsa/proxmox.newest.git"
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
# Local path overrides
# NOTE: You must run `cargo update` after changing this for it to take effect!

416
pve-rs/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"01913c77e69a9646b0a0e05faecabadbbb0e25c6881cd20f9881d8253fe7fffb","Cargo.lock":"f9ade5097a66241857a25f0777fe609b53a75c545a6f387fdea959bd6ad846f0","Cargo.toml":"860f20b5774b91eaa65069229364ae565d0685202650dc41b0fcb46aa85a4685","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"e99d88d232bf57d70f0fb87f6b496d44b6653f99f8a63d250a54c61ea4bcde40","README.md":"704f9c668989619bdb2f57217db47ac8ca5c468007b083c985b5595b69d303d3","src/bin/addr2line.rs":"727dc70cbb9d7ecc0fd44149df35ea7a4a372ca29e52260fd31232932cd3171e","src/frame.rs":"de3b23388c36a0874db5569d1f49ce6cc52ef2006b9ae9b9a3eba7654b201e2b","src/function.rs":"7fc741622c44c24fdf54c8a44cbdee058d49da33974bc86cd45b70c143071e68","src/lazy.rs":"ec230b69a0d194fe253227a41903231ca70a88f896af7a6f8a5a7d9ac63bf618","src/lib.rs":"fafd0bcb6fdd8f700c3660ce82f4d3f728fe79041c04336f92a6cce2ba50e427","src/line.rs":"049e9b1526ae3433a6001e8377245131e9cbd056d17e67a9b34898598a4f1c28","src/loader.rs":"d5639a90b6e692e83d59ddbff592c5a40a0764929165345086961ee4c98a4597","src/lookup.rs":"0d28a2fd00f0696f8fb50cdc88cb7d55a910df8bf3052b7c74ae50a387346e67","src/unit.rs":"f4399c401759e14db5d596cfddfe2c8a0591a81c18d9adaedba7d243cc3bd192","tests/correctness.rs":"04692661bd02053789eff1af9faaff3c4ffe637801edc69f7e37eb993a95b2ad","tests/output_equivalence.rs":"54f4bd926ed46da96b0dab020c713df03e74f616f15ac8b70515d1cd9685f97a","tests/parse.rs":"2b56ab29fe20bfccb5694d3f79de6799d9a1726e655c75f6edada498eecb46c4"},"package":"f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375"}
{"files":{"CHANGELOG.md":"0d04c7dddcffba3d83d4a05466c9b79cf13360c33f081fc9800596716bf954ce","Cargo.lock":"783a3adbf5047e30e0aa52f28dc6a0134534de715e5a36fd402c17e2eba43b1a","Cargo.toml":"940373297f67456852d5236a1eb7a3856bc672c69529cbbe6052ce5f85221170","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"e99d88d232bf57d70f0fb87f6b496d44b6653f99f8a63d250a54c61ea4bcde40","README.md":"c635ed91d7b0c87ff2f0f311cd1a31336d2cbc4d011965d3b58afaca073538d9","src/bin/addr2line.rs":"3da8c7657604578961f2bf89052b94e6c59c55abe27a2707913f98875d666124","src/frame.rs":"de3b23388c36a0874db5569d1f49ce6cc52ef2006b9ae9b9a3eba7654b201e2b","src/function.rs":"7fc741622c44c24fdf54c8a44cbdee058d49da33974bc86cd45b70c143071e68","src/lazy.rs":"ec230b69a0d194fe253227a41903231ca70a88f896af7a6f8a5a7d9ac63bf618","src/lib.rs":"8bf9fe3f3ced8ff84d60fdd456a8ff6e73170825cd696b0291b4644c01e620d2","src/line.rs":"049e9b1526ae3433a6001e8377245131e9cbd056d17e67a9b34898598a4f1c28","src/loader.rs":"9ad08da02599b9742a9821742fd84dbe0294838b6faa5f5753eacddc6101ffc1","src/lookup.rs":"0d28a2fd00f0696f8fb50cdc88cb7d55a910df8bf3052b7c74ae50a387346e67","src/unit.rs":"f4399c401759e14db5d596cfddfe2c8a0591a81c18d9adaedba7d243cc3bd192"},"package":"dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"}

View File

@ -2,6 +2,37 @@
--------------------------------------------------------------------------------
## 0.24.2 (2024/10/04)
### Changed
* Enabled caching of DWARF abbreviations.
[#318](https://github.com/gimli-rs/addr2line/pull/318)
* Changed the `addr2line` binary to prefer symbol names over DWARF names.
[#332](https://github.com/gimli-rs/addr2line/pull/332)
* Updated `gimli` dependency.
### Added
* Added `Context::from_arc_dwarf`.
[#327](https://github.com/gimli-rs/addr2line/pull/327)
* Added benchmark comparison.
[#315](https://github.com/gimli-rs/addr2line/pull/315)
[#321](https://github.com/gimli-rs/addr2line/pull/321)
[#322](https://github.com/gimli-rs/addr2line/pull/322)
[#325](https://github.com/gimli-rs/addr2line/pull/325)
* Added more tests.
[#328](https://github.com/gimli-rs/addr2line/pull/328)
[#330](https://github.com/gimli-rs/addr2line/pull/330)
[#331](https://github.com/gimli-rs/addr2line/pull/331)
[#333](https://github.com/gimli-rs/addr2line/pull/333)
--------------------------------------------------------------------------------
## 0.24.1 (2024/07/26)
### Changed

209
pve-rs/vendor/addr2line/Cargo.lock generated vendored
View File

@ -4,16 +4,16 @@ version = 3
[[package]]
name = "addr2line"
version = "0.22.0"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375"
dependencies = [
"gimli 0.29.0",
"gimli",
]
[[package]]
name = "addr2line"
version = "0.24.1"
version = "0.24.2"
dependencies = [
"backtrace",
"clap",
@ -21,7 +21,7 @@ dependencies = [
"cpp_demangle",
"fallible-iterator",
"findshlibs",
"gimli 0.31.0",
"gimli",
"libtest-mimic",
"memmap2",
"object",
@ -33,10 +33,10 @@ dependencies = [
]
[[package]]
name = "adler"
version = "1.0.2"
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "anstream"
@ -89,17 +89,17 @@ dependencies = [
[[package]]
name = "backtrace"
version = "0.3.73"
version = "0.3.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a"
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
dependencies = [
"addr2line 0.22.0",
"cc",
"addr2line 0.24.1",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
"windows-targets",
]
[[package]]
@ -108,17 +108,14 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cc"
version = "1.1.6"
version = "1.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f"
checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
@ -128,9 +125,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.11"
version = "4.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3"
checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615"
dependencies = [
"clap_builder",
"clap_derive",
@ -138,9 +135,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.5.11"
version = "4.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa"
checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b"
dependencies = [
"anstream",
"anstyle",
@ -151,9 +148,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.5.11"
version = "4.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e"
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
dependencies = [
"heck",
"proc-macro2",
@ -175,15 +172,15 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]]
name = "compiler_builtins"
version = "0.1.113"
version = "0.1.131"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7a6025b8e1885a239509ec7a00859e721eecb5725a64206ab1a6a96f7b55660"
checksum = "d18d2ba094b78965890b2912f45dc8cb6bb3aff315ef54755ec33223b6454502"
[[package]]
name = "cpp_demangle"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119"
checksum = "96e58d342ad113c2b878f16d5d034c03be492ae460cdbc02b7f0f2284d310c7d"
dependencies = [
"cfg-if",
]
@ -233,9 +230,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.30"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae"
checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
dependencies = [
"crc32fast",
"miniz_oxide",
@ -243,15 +240,9 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.29.0"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
[[package]]
name = "gimli"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
dependencies = [
"compiler_builtins",
"fallible-iterator",
@ -286,9 +277,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.155"
version = "0.2.159"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
[[package]]
name = "libtest-mimic"
@ -316,20 +307,20 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memmap2"
version = "0.9.4"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322"
checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
dependencies = [
"libc",
]
[[package]]
name = "miniz_oxide"
version = "0.7.4"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler",
"adler2",
]
[[package]]
@ -344,9 +335,9 @@ dependencies = [
[[package]]
name = "object"
version = "0.36.2"
version = "0.36.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e"
checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
dependencies = [
"flate2",
"memchr",
@ -364,9 +355,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.36"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
@ -391,9 +382,9 @@ checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c"
[[package]]
name = "rustix"
version = "0.38.34"
version = "0.38.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
dependencies = [
"bitflags",
"errno",
@ -404,14 +395,19 @@ dependencies = [
[[package]]
name = "ruzstd"
version = "0.7.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5022b253619b1ba797f243056276bed8ed1a73b0f5a7ce7225d524067644bf8f"
checksum = "99c3938e133aac070997ddc684d4b393777d293ba170f2988c8fd5ea2ad4ce21"
dependencies = [
"byteorder",
"twox-hash",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "smallvec"
version = "1.13.2"
@ -438,9 +434,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.72"
version = "2.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
dependencies = [
"proc-macro2",
"quote",
@ -458,12 +454,12 @@ dependencies = [
[[package]]
name = "terminal_size"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7"
checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef"
dependencies = [
"rustix",
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]
@ -493,9 +489,9 @@ checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
[[package]]
name = "unicode-ident"
version = "1.0.12"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "utf8parse"
@ -521,11 +517,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@ -534,37 +530,22 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.6",
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
"windows-targets",
]
[[package]]
@ -573,46 +554,28 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc 0.52.6",
"windows_i686_gnu 0.52.6",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"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",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
@ -625,48 +588,24 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[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_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[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_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"

View File

@ -13,7 +13,8 @@
edition = "2018"
rust-version = "1.65"
name = "addr2line"
version = "0.24.1"
version = "0.24.2"
build = false
include = [
"/CHANGELOG.md",
"/Cargo.lock",
@ -22,8 +23,11 @@ include = [
"/LICENSE-MIT",
"/README.md",
"/src",
"/tests",
]
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "A cross-platform symbolication library written in Rust, using `gimli`"
documentation = "https://docs.rs/addr2line"
readme = "README.md"
@ -45,26 +49,15 @@ debug = 2
[profile.release]
debug = 2
[lib]
name = "addr2line"
path = "src/lib.rs"
[[bin]]
name = "addr2line"
path = "src/bin/addr2line.rs"
required-features = ["bin"]
[[test]]
name = "output_equivalence"
harness = false
required-features = ["bin"]
[[test]]
name = "correctness"
required-features = [
"loader",
"fallible-iterator",
]
[[test]]
name = "parse"
required-features = ["loader"]
[dependencies.alloc]
version = "1.0.0"
optional = true
@ -96,7 +89,7 @@ optional = true
default-features = false
[dependencies.gimli]
version = "0.31.0"
version = "0.31.1"
features = ["read"]
default-features = false
@ -141,6 +134,7 @@ bin = [
"loader",
"rustc-demangle",
"cpp_demangle",
"fallible-iterator",
"smallvec",
"dep:clap",
]

View File

@ -31,8 +31,10 @@ The DWARF information is parsed lazily where possible.
The library aims to perform similarly to equivalent existing tools such
as `addr2line` from binutils, `eu-addr2line` from elfutils, and
`llvm-symbolize` from the llvm project, and in the past some benchmarking
was done that indicates a comparable performance.
`llvm-addr2line` from the llvm project. Current benchmarks show a performance
improvement in all cases:
![addr2line runtime](benchmark-time.svg)
## License

View File

@ -1,3 +1,4 @@
use fallible_iterator::FallibleIterator;
use std::borrow::Cow;
use std::io::{BufRead, Lines, StdinLock, Write};
use std::path::{Path, PathBuf};
@ -210,7 +211,7 @@ fn main() {
if opts.do_functions || opts.do_inlines {
let mut printed_anything = false;
if let Some(probe) = probe {
let mut frames = ctx.find_frames(probe).unwrap();
let mut frames = ctx.find_frames(probe).unwrap().peekable();
let mut first = true;
while let Some(frame) = frames.next().unwrap() {
if opts.pretty && !first {
@ -219,15 +220,25 @@ fn main() {
first = false;
if opts.do_functions {
if let Some(func) = frame.function {
// Only use the symbol table if this isn't an inlined function.
let symbol = if matches!(frames.peek(), Ok(None)) {
ctx.find_symbol(probe)
} else {
None
};
if symbol.is_some() {
// Prefer the symbol table over the DWARF name because:
// - the symbol can include a clone suffix
// - llvm may omit the linkage name in the DWARF with -g1
print_function(symbol, None, opts.demangle);
} else if let Some(func) = frame.function {
print_function(
func.raw_name().ok().as_deref(),
func.language,
opts.demangle,
);
} else {
let name = ctx.find_symbol(probe);
print_function(name, None, opts.demangle);
print_function(None, None, opts.demangle);
}
if opts.pretty {

View File

@ -139,7 +139,12 @@ impl<R: gimli::Reader> Context<R> {
/// Construct a new `Context` from an existing [`gimli::Dwarf`] object.
#[inline]
pub fn from_dwarf(sections: gimli::Dwarf<R>) -> Result<Context<R>, Error> {
let sections = Arc::new(sections);
Self::from_arc_dwarf(Arc::new(sections))
}
/// Construct a new `Context` from an existing [`gimli::Dwarf`] object.
#[inline]
pub fn from_arc_dwarf(sections: Arc<gimli::Dwarf<R>>) -> Result<Context<R>, Error> {
let units = ResUnits::parse(&sections)?;
let sup_units = if let Some(sup) = sections.sup.as_ref() {
SupUnits::parse(sup)?
@ -390,10 +395,10 @@ impl<R: gimli::Reader> RangeAttributes<R> {
} else if let (Some(begin), Some(end)) = (self.low_pc, self.high_pc) {
add_range(gimli::Range { begin, end });
} else if let (Some(begin), Some(size)) = (self.low_pc, self.size) {
add_range(gimli::Range {
begin,
end: begin + size,
});
// If `begin` is a -1 tombstone, this will overflow and the check in
// `add_range` will ignore it.
let end = begin.wrapping_add(size);
add_range(gimli::Range { begin, end });
}
Ok(added_any)
}

View File

@ -209,6 +209,7 @@ impl<'a> LoaderInternal<'a> {
if let Some(sup_object) = &sup_object {
dwarf.load_sup(|id| load_section(Some(id.name()), sup_object, endian, arena_data))?;
}
dwarf.populate_abbreviations_cache(gimli::AbbreviationsCacheStrategy::Duplicates);
let ctx = Context::from_dwarf(dwarf)?;

View File

@ -1,57 +0,0 @@
use addr2line::Loader;
use fallible_iterator::FallibleIterator;
use findshlibs::{IterationControl, SharedLibrary, TargetSharedLibrary};
#[test]
#[allow(clippy::fn_to_numeric_cast)]
fn correctness() {
let path = std::env::current_exe().unwrap();
let ctx = Loader::new(&path).unwrap();
let module_base = ctx.relative_address_base();
let mut bias = None;
TargetSharedLibrary::each(|lib| {
bias = Some((lib.virtual_memory_bias().0 as u64).wrapping_sub(module_base));
IterationControl::Break
});
#[allow(unused_mut)]
let mut test = |sym: u64, expected_prefix: &str| {
let ip = sym.wrapping_sub(bias.unwrap());
let frames = ctx.find_frames(ip).unwrap();
let frame = frames.last().unwrap().unwrap();
let name = frame.function.as_ref().unwrap().demangle().unwrap();
// Old rust versions generate DWARF with wrong linkage name,
// so only check the start.
if !name.starts_with(expected_prefix) {
panic!("incorrect name '{}', expected {:?}", name, expected_prefix);
}
};
test(test_function as u64, "correctness::test_function");
test(
small::test_function as u64,
"correctness::small::test_function",
);
test(auxiliary::foo as u64, "auxiliary::foo");
}
mod small {
pub fn test_function() {
println!("y");
}
}
fn test_function() {
println!("x");
}
#[test]
fn zero_function() {
let path = std::env::current_exe().unwrap();
let ctx = Loader::new(&path).unwrap();
for probe in 0..10 {
assert!(ctx.find_frames(probe).unwrap().count().unwrap() < 10);
}
}

View File

@ -1,134 +0,0 @@
use std::env;
use std::ffi::OsStr;
use std::path::Path;
use std::process::Command;
use backtrace::Backtrace;
use findshlibs::{IterationControl, SharedLibrary, TargetSharedLibrary};
use libtest_mimic::{Arguments, Failed, Trial};
#[inline(never)]
fn make_trace() -> Vec<String> {
fn foo() -> Backtrace {
bar()
}
#[inline(never)]
fn bar() -> Backtrace {
baz()
}
#[inline(always)]
fn baz() -> Backtrace {
Backtrace::new_unresolved()
}
let mut base_addr = None;
TargetSharedLibrary::each(|lib| {
base_addr = Some(lib.virtual_memory_bias().0 as isize);
IterationControl::Break
});
let addrfix = -base_addr.unwrap();
let trace = foo();
trace
.frames()
.iter()
.take(5)
.map(|x| format!("{:p}", (x.ip() as *const u8).wrapping_offset(addrfix)))
.collect()
}
fn run_cmd<P: AsRef<OsStr>>(exe: P, me: &Path, flags: Option<&str>, trace: &str) -> String {
let mut cmd = Command::new(exe);
cmd.env("LC_ALL", "C"); // GNU addr2line is localized, we aren't
cmd.env("RUST_BACKTRACE", "1"); // if a child crashes, we want to know why
if let Some(flags) = flags {
cmd.arg(flags);
}
cmd.arg("--exe").arg(me).arg(trace);
let output = cmd.output().unwrap();
assert!(output.status.success());
String::from_utf8(output.stdout).unwrap()
}
fn run_test(flags: Option<&str>) -> Result<(), Failed> {
let me = env::current_exe().unwrap();
let mut exe = me.clone();
assert!(exe.pop());
if exe.file_name().unwrap().to_str().unwrap() == "deps" {
assert!(exe.pop());
}
exe.push("addr2line");
assert!(exe.is_file());
let trace = make_trace();
// HACK: GNU addr2line has a bug where looking up multiple addresses can cause the second
// lookup to fail. Workaround by doing one address at a time.
for addr in &trace {
let theirs = run_cmd("addr2line", &me, flags, addr);
let ours = run_cmd(&exe, &me, flags, addr);
// HACK: GNU addr2line does not tidy up paths properly, causing double slashes to be printed.
// We consider our behavior to be correct, so we fix their output to match ours.
let theirs = theirs.replace("//", "/");
assert!(
theirs == ours,
"Output not equivalent:
$ addr2line {0} --exe {1} {2}
{4}
$ {3} {0} --exe {1} {2}
{5}
",
flags.unwrap_or(""),
me.display(),
trace.join(" "),
exe.display(),
theirs,
ours
);
}
Ok(())
}
static FLAGS: &str = "aipsf";
fn make_tests() -> Vec<Trial> {
(0..(1 << FLAGS.len()))
.map(|bits| {
if bits == 0 {
None
} else {
let mut param = String::new();
param.push('-');
for (i, flag) in FLAGS.chars().enumerate() {
if (bits & (1 << i)) != 0 {
param.push(flag);
}
}
Some(param)
}
})
.map(|param| {
Trial::test(
format!("addr2line {}", param.as_deref().unwrap_or_default()),
move || run_test(param.as_deref()),
)
})
.collect()
}
fn main() {
if !cfg!(target_os = "linux") {
return;
}
let args = Arguments::from_args();
libtest_mimic::run(&args, make_tests()).exit();
}

View File

@ -1,85 +0,0 @@
use std::borrow::Cow;
use std::env;
use std::fs::File;
use std::path::{self, PathBuf};
use object::Object;
fn release_fixture_path() -> PathBuf {
if let Ok(p) = env::var("ADDR2LINE_FIXTURE_PATH") {
return p.into();
}
let mut path = PathBuf::new();
if let Ok(dir) = env::var("CARGO_MANIFEST_DIR") {
path.push(dir);
}
path.push("fixtures");
path.push("addr2line-release");
path
}
fn with_file<F: FnOnce(&object::File<'_>)>(target: &path::Path, f: F) {
let file = File::open(target).unwrap();
let map = unsafe { memmap2::Mmap::map(&file).unwrap() };
let file = object::File::parse(&*map).unwrap();
f(&file)
}
fn dwarf_load<'a>(object: &object::File<'a>) -> gimli::DwarfSections<Cow<'a, [u8]>> {
let load_section = |id: gimli::SectionId| -> Result<Cow<'a, [u8]>, gimli::Error> {
use object::ObjectSection;
let data = object
.section_by_name(id.name())
.and_then(|section| section.data().ok())
.unwrap_or(&[][..]);
Ok(Cow::Borrowed(data))
};
gimli::DwarfSections::load(&load_section).unwrap()
}
fn dwarf_borrow<'a>(
dwarf: &'a gimli::DwarfSections<Cow<'_, [u8]>>,
) -> gimli::Dwarf<gimli::EndianSlice<'a, gimli::LittleEndian>> {
let borrow_section: &dyn for<'b> Fn(
&'b Cow<'_, [u8]>,
) -> gimli::EndianSlice<'b, gimli::LittleEndian> =
&|section| gimli::EndianSlice::new(section, gimli::LittleEndian);
dwarf.borrow(&borrow_section)
}
#[test]
fn parse_base() {
let target = release_fixture_path();
with_file(&target, |file| {
let dwarf = dwarf_load(file);
let dwarf = dwarf_borrow(&dwarf);
addr2line::Context::from_dwarf(dwarf).unwrap();
});
}
#[test]
fn parse_lines() {
let target = release_fixture_path();
with_file(&target, |file| {
let dwarf = dwarf_load(file);
let dwarf = dwarf_borrow(&dwarf);
let context = addr2line::Context::from_dwarf(dwarf).unwrap();
context.parse_lines().unwrap();
});
}
#[test]
fn parse_functions() {
let target = release_fixture_path();
with_file(&target, |file| {
let dwarf = dwarf_load(file);
let dwarf = dwarf_borrow(&dwarf);
let context = addr2line::Context::from_dwarf(dwarf).unwrap();
context.parse_functions().unwrap();
});
}

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"50daeb84465695fb01975f29be1529b1c09010d9e6440d0f92034285f00e8203","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"6e608b9068b4ebab4b85944f047ea386f0288a99c615ac4a32ac45a7da4e5e33","build.rs":"914eb6158687216432aed82e357af5dff2d957d8c7746d075f7a778ba39df146","build/probe.rs":"ee0a4518493c0b3cca121ed2e937b1779eb7e8313a5c4d5fc5aea28ff015366b","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/backtrace.rs":"578b395a66b21d0e90c503546011138b057f6f27147c51667490da66d22edd54","src/chain.rs":"85af447405f075633fab186b7f1c94d7f33a36474f239c50a961b2d6197d5426","src/context.rs":"1be432c32752778041e8acf0e7d98d4f6291ce53fd7df5bbb0167824bbea57f7","src/ensure.rs":"9763f418b5397764549866c111ec6db3a7bdc4c30ad95c3bbfc56c5434ea8c09","src/error.rs":"cb47593520baa6dc9372bea3d0e8e318f7ec09734f88e7d9d6b9b0c1e17c1507","src/fmt.rs":"adf4be906b29900153bfb4b767a6049d58697dc3bcce7dfbb85ca773f5de5b33","src/kind.rs":"d8cc91e73653049ca0b5593f36aee8632fcc85847b36005b90ecd9a6f0de13cb","src/lib.rs":"8647691e7cf073cb8df0a5c69d55b6adfebf9f2ab93b7c0817621021c0762384","src/macros.rs":"17fb103e68a5befa768857314c3ca4d81d1dacfea0738bbb9c7597a485243499","src/ptr.rs":"4cb31d2f815b178daf951bfb94a1930383e056c0ca68d494603f45d8eea35d50","src/wrapper.rs":"d4e45caee3c2d861d4609a8141310d5c901af59a57d5f0a0de30251347dbd23c","tests/common/mod.rs":"f9088c2d7afafa64ff730b629272045b776bfafc2f5957508242da630635f2e1","tests/compiletest.rs":"4e381aa8ca3eabb7ac14d1e0c3700b3223e47640547a6988cfa13ad68255f60f","tests/drop/mod.rs":"08c3e553c1cc0d2dbd936fc45f4b5b1105057186affd6865e8d261e05f0f0646","tests/test_autotrait.rs":"ecccf9202a33611f64b76598806aa82abec2560ae058e32f63fb2fb3ef225be9","tests/test_backtrace.rs":"60afdd7ee5850dc22625ff486fe41c47fd322db874a93c4871ddfed2bf603930","tests/test_boxed.rs":"6b26db0e2eb72afe9af7352ea820837aab90f8d486294616dd5dc34c1b94038c","tests/test_chain.rs":"3a8a8d7569913bd98c0e27c69d0bda35101e7fde7c056ed57cdd8ed018e4cbcb","tests/test_context.rs":"8409c53b328562c11e822bd6c3cd17e0d4d50b9bbb8fc3617333fd77303a6a33","tests/test_convert.rs":"7e7a8b4772a427a911014ac4d1083f9519000e786177f898808980dd9bdfde61","tests/test_downcast.rs":"797e69a72d125758c4c4897e5dc776d549d52cc9a6a633e0a33193f588a62b88","tests/test_ensure.rs":"4014ead6596793f5eecd55cbaafa49286b75cee7b7092a8b9b8286fcd813a6da","tests/test_ffi.rs":"d0cb4c1d6d9154090982dee72ae3ebe05a5981f976058c3250f1c9da5a45edef","tests/test_fmt.rs":"0e49b48f08e4faaf03e2f202e1efc5250018876c4e1b01b8379d7a38ae8df870","tests/test_macros.rs":"68673942662a43bceee62aaed69c25d7ddbc55e25d62d528e13033c3e2e756cd","tests/test_repr.rs":"034dee888abd08741e11ac2e95ef4fcb2ab3943d0a76e8e976db404658e1a252","tests/test_source.rs":"b80723cf635a4f8c4df21891b34bfab9ed2b2aa407e7a2f826d24e334cd5f88e","tests/ui/chained-comparison.rs":"6504b03d95b5acc232a7f4defc9f343b2be6733bf475fa0992e8e6545b912bd4","tests/ui/chained-comparison.stderr":"7f1d0a8c251b0ede2d30b3087ec157fc660945c97a642c4a5acf5a14ec58de34","tests/ui/empty-ensure.rs":"ab5bf37c846a0d689f26ce9257a27228411ed64154f9c950f1602d88a355d94b","tests/ui/empty-ensure.stderr":"315782f5f4246290fe190e3767b22c3dcaffaabc19c5ace0373537d53e765278","tests/ui/ensure-nonbool.rs":"7e57cb93fbcd82959b36586ed6bd2ad978b051fe5facd5274651fde6b1600905","tests/ui/ensure-nonbool.stderr":"0b4d1611e3bb65081bf38c1e49b1f12e5096738f276608661016e68f1fe13f7c","tests/ui/must-use.rs":"fb59860b43f673bf4a430a6036ba463e95028844d8dd4243cfe5ebc7f2be582f","tests/ui/must-use.stderr":"c2848c5f254b4c061eea6714d9baf709924aba06619eaf2a8b3aee1266b75f9e","tests/ui/no-impl.rs":"fab6cbf2f6ea510b86f567dfb3b7c31250a9fd71ae5d110dbb9188be569ec593","tests/ui/no-impl.stderr":"0d8ed712d25de898eae18cfdffc575a47f4d5596346058cf6cd50d016c4f8ce8","tests/ui/temporary-value.rs":"4dcc96271b2403e6372cf4cfc813445e5ce4365fc6e156b6bc38274098499a70","tests/ui/temporary-value.stderr":"171f6c1c962503855480696e5d39e68946ec2a027b61a6f36ca1ad1b40265c5d","tests/ui/wrong-interpolation.rs":"9c44d4674c2dccd27b9dedd03341346ec02d993b41793ee89b5755202e7e367e","tests/ui/wrong-interpolation.stderr":"301e60e2eb9401782c7dc0b3580613a4cb2aafd4cc8065734a630a62e1161aa5"},"package":"10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8"}
{"files":{"Cargo.toml":"b9c67d404778b8bc5bbd695cd3afb809a9c7cc4655be31efa5d809c1b0e1a5a8","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"136d2b44cc4060192516f18e43ec3eafb65693c1819a80a867e7a00c60a45ee6","build.rs":"27bcb3380f8b9b52a12d1aedad324858a94de974f17efa86ff93aa7e556b3798","build/probe.rs":"ee0a4518493c0b3cca121ed2e937b1779eb7e8313a5c4d5fc5aea28ff015366b","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/backtrace.rs":"bbaa0e0e228475c9c9532786e305cf04f53729f386c48adb1d93bb8ce07f37ad","src/chain.rs":"85af447405f075633fab186b7f1c94d7f33a36474f239c50a961b2d6197d5426","src/context.rs":"1be432c32752778041e8acf0e7d98d4f6291ce53fd7df5bbb0167824bbea57f7","src/ensure.rs":"9763f418b5397764549866c111ec6db3a7bdc4c30ad95c3bbfc56c5434ea8c09","src/error.rs":"274c175ec92f4aa8bf479d39cf3023d1ead9865a242a0a63ad3998aea57219a6","src/fmt.rs":"adf4be906b29900153bfb4b767a6049d58697dc3bcce7dfbb85ca773f5de5b33","src/kind.rs":"d8cc91e73653049ca0b5593f36aee8632fcc85847b36005b90ecd9a6f0de13cb","src/lib.rs":"0534dd480fff1f6fa19e3e202dcd981047597eeb693406d0a7bc6f795cb4faf0","src/macros.rs":"875797636fde708dcb9c82e0cb3107cf38334086274aaada267fb5bfd60547a9","src/ptr.rs":"4cb31d2f815b178daf951bfb94a1930383e056c0ca68d494603f45d8eea35d50","src/wrapper.rs":"d4e45caee3c2d861d4609a8141310d5c901af59a57d5f0a0de30251347dbd23c","tests/common/mod.rs":"f9088c2d7afafa64ff730b629272045b776bfafc2f5957508242da630635f2e1","tests/compiletest.rs":"4e381aa8ca3eabb7ac14d1e0c3700b3223e47640547a6988cfa13ad68255f60f","tests/drop/mod.rs":"08c3e553c1cc0d2dbd936fc45f4b5b1105057186affd6865e8d261e05f0f0646","tests/test_autotrait.rs":"ba9bc18416115cb48fd08675a3e7fc89584de7926dad6b2be6645dc13d5931df","tests/test_backtrace.rs":"60afdd7ee5850dc22625ff486fe41c47fd322db874a93c4871ddfed2bf603930","tests/test_boxed.rs":"6b26db0e2eb72afe9af7352ea820837aab90f8d486294616dd5dc34c1b94038c","tests/test_chain.rs":"3a8a8d7569913bd98c0e27c69d0bda35101e7fde7c056ed57cdd8ed018e4cbcb","tests/test_context.rs":"8409c53b328562c11e822bd6c3cd17e0d4d50b9bbb8fc3617333fd77303a6a33","tests/test_convert.rs":"7e7a8b4772a427a911014ac4d1083f9519000e786177f898808980dd9bdfde61","tests/test_downcast.rs":"797e69a72d125758c4c4897e5dc776d549d52cc9a6a633e0a33193f588a62b88","tests/test_ensure.rs":"4014ead6596793f5eecd55cbaafa49286b75cee7b7092a8b9b8286fcd813a6da","tests/test_ffi.rs":"d0cb4c1d6d9154090982dee72ae3ebe05a5981f976058c3250f1c9da5a45edef","tests/test_fmt.rs":"0e49b48f08e4faaf03e2f202e1efc5250018876c4e1b01b8379d7a38ae8df870","tests/test_macros.rs":"68673942662a43bceee62aaed69c25d7ddbc55e25d62d528e13033c3e2e756cd","tests/test_repr.rs":"034dee888abd08741e11ac2e95ef4fcb2ab3943d0a76e8e976db404658e1a252","tests/test_source.rs":"b80723cf635a4f8c4df21891b34bfab9ed2b2aa407e7a2f826d24e334cd5f88e","tests/ui/chained-comparison.rs":"6504b03d95b5acc232a7f4defc9f343b2be6733bf475fa0992e8e6545b912bd4","tests/ui/chained-comparison.stderr":"7f1d0a8c251b0ede2d30b3087ec157fc660945c97a642c4a5acf5a14ec58de34","tests/ui/empty-ensure.rs":"ab5bf37c846a0d689f26ce9257a27228411ed64154f9c950f1602d88a355d94b","tests/ui/empty-ensure.stderr":"315782f5f4246290fe190e3767b22c3dcaffaabc19c5ace0373537d53e765278","tests/ui/ensure-nonbool.rs":"7e57cb93fbcd82959b36586ed6bd2ad978b051fe5facd5274651fde6b1600905","tests/ui/ensure-nonbool.stderr":"0b4d1611e3bb65081bf38c1e49b1f12e5096738f276608661016e68f1fe13f7c","tests/ui/must-use.rs":"fb59860b43f673bf4a430a6036ba463e95028844d8dd4243cfe5ebc7f2be582f","tests/ui/must-use.stderr":"c2848c5f254b4c061eea6714d9baf709924aba06619eaf2a8b3aee1266b75f9e","tests/ui/no-impl.rs":"fab6cbf2f6ea510b86f567dfb3b7c31250a9fd71ae5d110dbb9188be569ec593","tests/ui/no-impl.stderr":"0d8ed712d25de898eae18cfdffc575a47f4d5596346058cf6cd50d016c4f8ce8","tests/ui/temporary-value.rs":"4dcc96271b2403e6372cf4cfc813445e5ce4365fc6e156b6bc38274098499a70","tests/ui/temporary-value.stderr":"171f6c1c962503855480696e5d39e68946ec2a027b61a6f36ca1ad1b40265c5d","tests/ui/wrong-interpolation.rs":"9c44d4674c2dccd27b9dedd03341346ec02d993b41793ee89b5755202e7e367e","tests/ui/wrong-interpolation.stderr":"301e60e2eb9401782c7dc0b3580613a4cb2aafd4cc8065734a630a62e1161aa5"},"package":"c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"}

View File

@ -13,9 +13,10 @@
edition = "2018"
rust-version = "1.39"
name = "anyhow"
version = "1.0.87"
version = "1.0.91"
authors = ["David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
autolib = false
autobins = false
autoexamples = false
autotests = false

View File

@ -136,10 +136,10 @@ Cargo.toml. A global allocator is required.
anyhow = { version = "1.0", default-features = false }
```
Since the `?`-based error conversions would normally rely on the
`std::error::Error` trait which is only available through std, no_std mode will
require an explicit `.map_err(Error::msg)` when working with a non-Anyhow error
type inside a function that returns Anyhow's error type.
With versions of Rust older than 1.81, no_std mode may require an additional
`.map_err(Error::msg)` when working with a non-Anyhow error type inside a
function that returns Anyhow's error type, as the trait that `?`-based error
conversions are defined by is only available in std in those old versions.
<br>

View File

@ -1,5 +1,7 @@
use std::env;
use std::ffi::OsString;
use std::fs;
use std::io::ErrorKind;
use std::iter;
use std::path::Path;
use std::process::{self, Command, Stdio};
@ -68,6 +70,7 @@ fn main() {
if rustc >= 80 {
println!("cargo:rustc-check-cfg=cfg(anyhow_nightly_testing)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_error)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_unwind_safe)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_fmt_arguments_as_str)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_ptr_addr_of)");
println!("cargo:rustc-check-cfg=cfg(anyhow_no_unsafe_op_in_unsafe_fn_lint)");
@ -91,6 +94,12 @@ fn main() {
println!("cargo:rustc-cfg=anyhow_no_unsafe_op_in_unsafe_fn_lint");
}
if rustc < 56 {
// core::panic::{UnwindSafe, RefUnwindSafe}
// https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html#stabilized-apis
println!("cargo:rustc-cfg=anyhow_no_core_unwind_safe");
}
if !error_generic_member_access && cfg!(feature = "std") && rustc >= 65 {
// std::backtrace::Backtrace
// https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#stabilized-apis
@ -118,8 +127,16 @@ fn compile_probe(rustc_bootstrap: bool) -> bool {
let rustc = cargo_env_var("RUSTC");
let out_dir = cargo_env_var("OUT_DIR");
let out_subdir = Path::new(&out_dir).join("probe");
let probefile = Path::new("build").join("probe.rs");
if let Err(err) = fs::create_dir(&out_subdir) {
if err.kind() != ErrorKind::AlreadyExists {
eprintln!("Failed to create {}: {}", out_subdir.display(), err);
process::exit(1);
}
}
let rustc_wrapper = env::var_os("RUSTC_WRAPPER").filter(|wrapper| !wrapper.is_empty());
let rustc_workspace_wrapper =
env::var_os("RUSTC_WORKSPACE_WRAPPER").filter(|wrapper| !wrapper.is_empty());
@ -141,7 +158,7 @@ fn compile_probe(rustc_bootstrap: bool) -> bool {
.arg("--emit=dep-info,metadata")
.arg("--cap-lints=allow")
.arg("--out-dir")
.arg(out_dir)
.arg(&out_subdir)
.arg(probefile);
if let Some(target) = env::var_os("TARGET") {
@ -157,10 +174,22 @@ fn compile_probe(rustc_bootstrap: bool) -> bool {
}
}
match cmd.status() {
let success = match cmd.status() {
Ok(status) => status.success(),
Err(_) => false,
};
// Clean up to avoid leaving nondeterministic absolute paths in the dep-info
// file in OUT_DIR, which causes nonreproducible builds in build systems
// that treat the entire OUT_DIR as an artifact.
if let Err(err) = fs::remove_dir_all(&out_subdir) {
if err.kind() != ErrorKind::NotFound {
eprintln!("Failed to clean up {}: {}", out_subdir.display(), err);
process::exit(1);
}
}
success
}
fn rustc_minor_version() -> Option<u32> {

View File

@ -406,6 +406,6 @@ mod capture {
}
fn _assert_send_sync() {
fn _assert<T: Send + Sync>() {}
_assert::<Backtrace>();
fn assert<T: Send + Sync>() {}
assert::<Backtrace>();
}

View File

@ -12,9 +12,13 @@ use core::fmt::{self, Debug, Display};
use core::mem::ManuallyDrop;
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
use core::ops::{Deref, DerefMut};
#[cfg(not(anyhow_no_core_unwind_safe))]
use core::panic::{RefUnwindSafe, UnwindSafe};
#[cfg(not(anyhow_no_ptr_addr_of))]
use core::ptr;
use core::ptr::NonNull;
#[cfg(all(feature = "std", anyhow_no_core_unwind_safe))]
use std::panic::{RefUnwindSafe, UnwindSafe};
impl Error {
/// Create a new error object from any error type.
@ -1015,3 +1019,9 @@ impl AsRef<dyn StdError> for Error {
&**self
}
}
#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]
impl UnwindSafe for Error {}
#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]
impl RefUnwindSafe for Error {}

View File

@ -201,12 +201,12 @@
//! anyhow = { version = "1.0", default-features = false }
//! ```
//!
//! Since the `?`-based error conversions would normally rely on the
//! `std::error::Error` trait which is only available through std, no_std mode
//! will require an explicit `.map_err(Error::msg)` when working with a
//! non-Anyhow error type inside a function that returns Anyhow's error type.
//! With versions of Rust older than 1.81, no_std mode may require an additional
//! `.map_err(Error::msg)` when working with a non-Anyhow error type inside a
//! function that returns Anyhow's error type, as the trait that `?`-based error
//! conversions are defined by is only available in std in those old versions.
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.87")]
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.91")]
#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]
#![no_std]
#![deny(dead_code, unused_imports, unused_mut)]
@ -227,6 +227,7 @@
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::needless_doctest_main,
clippy::needless_lifetimes,
clippy::new_ret_no_self,
clippy::redundant_else,
clippy::return_self_not_must_use,

View File

@ -1,9 +1,10 @@
/// Return early with an error.
///
/// This macro is equivalent to `return Err(`[`anyhow!($args...)`][anyhow!]`)`.
/// This macro is equivalent to
/// <code>return Err([anyhow!($args\...)][anyhow!])</code>.
///
/// The surrounding function's or closure's return value is required to be
/// `Result<_,`[`anyhow::Error`][crate::Error]`>`.
/// <code>Result&lt;_, [anyhow::Error][crate::Error]&gt;</code>.
///
/// [anyhow!]: crate::anyhow
///
@ -69,11 +70,11 @@ macro_rules! __ensure {
($ensure:item) => {
/// Return early with an error if a condition is not satisfied.
///
/// This macro is equivalent to `if !$cond { return
/// Err(`[`anyhow!($args...)`][anyhow!]`); }`.
/// This macro is equivalent to
/// <code>if !$cond { return Err([anyhow!($args\...)][anyhow!]); }</code>.
///
/// The surrounding function's or closure's return value is required to be
/// `Result<_,`[`anyhow::Error`][crate::Error]`>`.
/// <code>Result&lt;_, [anyhow::Error][crate::Error]&gt;</code>.
///
/// Analogously to `assert!`, `ensure!` takes a condition and exits the function
/// if the condition fails. Unlike `assert!`, `ensure!` returns an `Error`

View File

@ -1,6 +1,7 @@
#![allow(clippy::extra_unused_type_parameters)]
use anyhow::Error;
use std::panic::{RefUnwindSafe, UnwindSafe};
#[test]
fn test_send() {
@ -13,3 +14,21 @@ fn test_sync() {
fn assert_sync<T: Sync>() {}
assert_sync::<Error>();
}
#[test]
fn test_unwind_safe() {
fn assert_unwind_safe<T: UnwindSafe>() {}
assert_unwind_safe::<Error>();
}
#[test]
fn test_ref_unwind_safe() {
fn assert_ref_unwind_safe<T: RefUnwindSafe>() {}
assert_ref_unwind_safe::<Error>();
}
#[test]
fn test_unpin() {
fn assert_unpin<T: Unpin>() {}
assert_unpin::<Error>();
}

View File

@ -0,0 +1 @@
{"files":{".cargo/config.toml":"77e9219c27274120197571fd165cbe4121963b5ad3bc0b20b383c86ef0ce6c2b",".gear/apt-pkg-native.spec":"f51204bd4903cc45b54c2066cc3b4775317460627182fd3180323f48ffe3aec4",".gear/rules":"25289e6d0b29990912683a33fa413644f829ff93fd77f8d982651c5cad1a7e3e",".gear/upstream/remotes":"be2df2cc7562819711aaac7d934e0c908096271d1c4175ecbc0a86eeabf5195b",".travis.yml":"c3fdf6173e81b6bf7e1b0399a1767ef55ea9867d0c86b12c3d91f6e717a8d1db","Cargo.lock":"f4c20f001b8884426eadb198b99556bbd62e3a0da8fb40d46444b5e988866113","Cargo.toml":"f25eb040338f607a7fee7b3eaedbea965491d17c50606bdcb3ceb6b684813dd0","LICENSE.MIT":"54e17baced243561c869877e68c2ac8736f17a2c1266062ad9fb1ebf3ed1967c","README.md":"d44dc795397fe707f6cc605d1f801c1cb8490e804861f1ac938945eb6f294cd3","apt-pkg-c/.gitignore":"659109c3f137e0b4f610d98f017adf80a01551689187a6778dc8fa0d54ea26a4","apt-pkg-c/Makefile":"a8472bde3198669e9af22dd1bfc187baa30a3b2b25490ef6ff3185ec3c0d1fc0","apt-pkg-c/lib.cpp":"baeae62600f975c1294c2d68f157e871c329f2c7d8534409f7f39e8100e71f21","build.rs":"e4cf0afcb5cf6887ea1d971eb3de9224d4186cb58ffff4f9592c4f4d73362946","examples/epochs.rs":"be32926cbad6eede80f7530178bb827eb02c958f6be82b30f5c6f5f21dc399d1","examples/list.rs":"0c20b92819ec94291a36a3805315ec52a2777147b211be0962c287127fbe515c","examples/on-sid/.dockerignore":"25ca4d0088686695559d7c5c7666166a6cb731b76fff8ebb1b90d598325c107c","examples/on-sid/Dockerfile":"dbc6cc6a7cb82854662308e27a7fced5256e4aac4b672bc5e307b55bf357e380","examples/on-sid/Makefile":"12353f6701bf4b685a60a9000021bbb41ff536843deb056810d52e33d00bfa12","examples/on-sid/sources.list":"050b38c58e546cd9c98ea4731cf58317b5611c734d372814f92b905a7c7767a0","examples/on-trusty/.dockerignore":"25ca4d0088686695559d7c5c7666166a6cb731b76fff8ebb1b90d598325c107c","examples/on-trusty/Dockerfile":"12f2231aa631687c868534ad8b0fb80b8ef1225791515ec44391e7e512f34d84","examples/on-trusty/Makefile":"5db72b4ffff06c351a81626d8b93e5d3cf222840b7a38cf927ccbecc57bd21aa","examples/on-trusty/uprust.sh":"22aa1f7f4c4b9be99a9d7e13ad45b2aec6714165a0578dd5ef81ca11f55ea24e","examples/policy.rs":"c7afd85c85e79acb2d5d10c362992a48a982f68222d724d11422ca90df2a09fe","examples/sources.rs":"9fb1f5bf21679a77b2c985945543da8ed748e786a9977a1d755be68b2f82b16f","src/citer.rs":"e03662241b7da607171a48870e97939d7c8309bc4a4d7c33697a851d8cc12178","src/lib.rs":"3fcd694e85be9d770baa2a92e02befc4f62a610044d55200fb441806286b9a68","src/raw.rs":"5c0060d052062885f9f7142e1b0274411199aa28696d5078a54ed23c23504606","src/sane.rs":"5e96611ee81f8cd02f20b8254a58f0dc4096f8e01c7b49b387e39b93ba15898f","src/simple.rs":"177994ecd9e106345c4efebe1ec38bb521a970332f12da9d9eda4b3563af5e2b"},"package":null}

View File

@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"

View File

@ -0,0 +1,41 @@
%define bin_name lib%name
Name: apt-pkg-native
Version: 0.3.2
Release: alt1
Summary: Rust bindings for libapt-pkg
License: MIT
Group: Development/Tools
Url: https://github.com/FauxFaux/apt-pkg-native-rs
Source: %name-%version.tar
BuildRequires(pre): rpm-build-rust
BuildRequires: /proc
BuildRequires: rust-cargo
BuildRequires: gcc-c++
BuildRequires: libapt-devel
%description
This crate provides bindings to libapt-pkg.
%prep
%setup
%build
%rust_build --features alt-linux
# --features ye-olde-apt
%install
%rust_install %bin_name
%check
%rust_test
%files
%_bindir/*
%doc LICENSE-MIT README.md
%changelog
* Mon Jun 19 2023 Alexander Burmatov <thatman@altlinux.org> 0.3.2-alt1
- Initial build for Sisyphus.

View File

@ -0,0 +1,2 @@
spec: .gear/apt-pkg-native.spec
tar: .

View File

@ -0,0 +1,3 @@
[remote "upstream"]
url = git@github.com:FauxFaux/apt-pkg-native-rs.git
fetch = +refs/heads/*:refs/remotes/upstream/*

View File

@ -0,0 +1,18 @@
language: rust
rust:
- nightly
- beta
- stable
matrix:
allow_failures:
- rust: nightly
addons:
apt:
packages:
- build-essential
- libapt-pkg-dev
dist: bionic
sudo: false

68
pve-rs/vendor/apt-pkg-native/Cargo.toml vendored Normal file
View File

@ -0,0 +1,68 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "apt-pkg-native"
version = "0.3.2"
authors = ["Chris West (Faux) <git@goeswhere.com>"]
build = "build.rs"
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Bindings for libapt-pkg"
readme = "README.md"
categories = [
"api-bindings",
"os",
]
license = "MIT"
repository = "https://github.com/FauxFaux/apt-pkg-native-rs"
[lib]
name = "apt_pkg_native"
path = "src/lib.rs"
[[example]]
name = "epochs"
path = "examples/epochs.rs"
[[example]]
name = "list"
path = "examples/list.rs"
[[example]]
name = "policy"
path = "examples/policy.rs"
[[example]]
name = "sources"
path = "examples/sources.rs"
[dependencies]
lazy_static = "1"
libc = "0.2"
[dev-dependencies]
boolinator = "2"
itertools = "0.9"
[build-dependencies]
cc = "1.0"
[features]
alt-linux = []
default = []
ye-olde-apt = []
[badges.travis-ci]
repository = "FauxFaux/apt-pkg-native-rs"

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Chris West
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

62
pve-rs/vendor/apt-pkg-native/README.md vendored Normal file
View File

@ -0,0 +1,62 @@
This crate provides bindings to `libapt-pkg`.
[![Build status](https://api.travis-ci.org/FauxFaux/apt-pkg-native-rs.png)](https://travis-ci.org/FauxFaux/apt-pkg-native-rs)
[![](http://meritbadge.herokuapp.com/apt-pkg-native)](https://crates.io/crates/apt-pkg-native)
### Documentation and Examples
See the `examples/` folder for some partial implementations of some commands.
https://docs.rs/apt-pkg-native
### License Note
While the code in this crate is available under a permissive MIT license,
it is useless without [`libapt-pkg`](https://tracker.debian.org/pkg/apt),
which is GPL2+.
### Building
`libapt-pkg-dev` must be installed. The [`cc`](https://crates.io/crates/cc)
crate is used to try and find a native compiler.
The `ye-olde-apt` feature provides support for `apt <1.2` (Ubuntu 14.04 (Trusty),
Debian 7 (Jessie) (2015)). This works by just deleting methods which are not
available in that version. See
[#2](https://github.com/FauxFaux/apt-pkg-native-rs/issues/2#issuecomment-351180818).
### Thread safety
It is intended that the crate should be usable from multiple threads.
However, this is generally implemented using singletons, which may be really
annoying for your use-case.
The current way the singleton is managed is awful, and it's not been fixed
while I've been learning about the problems. A major version bump, and a
proper singleton, may resolve some of the issues. This needs to be done eventually.
`apt` does not have a concurrency model: you may not use threads.
Since `apt` 1.4 or 1.5 (in Debian Stretch (2017), but not in Xenial 16.04),
some operations are thread safe: it should be possible to initialise the cache
twice in parallel. As these versions of `apt` are not widespread, the API of
this crate does not attempt to expose this.
### Alternatives
There is a similar project at [rust-apt](https://crates.io/crates/rust-apt).
### Switching distro with `docker`
`examples/on-sid` has a docker file which builds a minimum Debian image with
typical package lists downloaded. You can run a tool in it, from this directory,
by:
```
(cd examples/on-sid && make)
docker run -v $(pwd):/mnt sid-sources-list /mnt/target/release/examples/sources
```

View File

@ -0,0 +1 @@
lib.o

View File

@ -0,0 +1,10 @@
CXXFLAGS=-Wall -Wextra -g
all: clean check
check: lib.o
lib.o: lib.cpp
clean:
$(RM) lib.o

View File

@ -0,0 +1,671 @@
#include <sstream>
#include <cstdint>
#include <assert.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/pkgrecords.h>
#include <apt-pkg/version.h>
#include <apt-pkg/init.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/policy.h>
struct PCache {
// Owned by us.
#ifndef ALT_LINUX
pkgCacheFile *cache_file;
#else
CacheFile *cache_file;
#endif
// Borrowed from cache_file.
pkgCache *cache;
// Owned by us.
pkgRecords *records;
};
struct PPkgIterator {
// Owned by us.
pkgCache::PkgIterator iterator;
// Borrow of "static" PCache.
PCache *cache;
};
struct PVerIterator {
// Owned by us.
pkgCache::VerIterator iterator;
// Borrowed from PCache.
pkgCache::PkgIterator *pkg;
// Borrow of "static" PCache.
PCache *cache;
};
struct PDepIterator {
// Owned by us.
pkgCache::DepIterator iterator;
// Borrowed from PCache.
pkgCache::VerIterator *ver;
// Borrow of "static" PCache.
PCache *cache;
};
struct PVerFileIterator {
// Owned by us.
pkgCache::VerFileIterator iterator;
// Borrow of "static" PCache.
PCache *cache;
};
struct PPkgFileIterator {
// Owned by us.
pkgCache::PkgFileIterator iterator;
};
struct PVerFileParser {
pkgRecords::Parser *parser;
};
extern "C" {
void init_config_system();
PCache *pkg_cache_create();
void pkg_cache_release(PCache *cache);
int32_t pkg_cache_compare_versions(PCache *cache, const char *left, const char *right);
// pkg_iter creation and deletion
PPkgIterator *pkg_cache_pkg_iter(PCache *cache);
PPkgIterator *pkg_cache_find_name(PCache *cache, const char *name);
#ifndef ALT_LINUX
PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name, const char *arch);
#else
PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name);
#endif
void pkg_iter_release(PPkgIterator *iterator);
// pkg_iter mutation
void pkg_iter_next(PPkgIterator *iterator);
bool pkg_iter_end(PPkgIterator *iterator);
// pkg_iter access
const char *pkg_iter_name(PPkgIterator *iterator);
const char *pkg_iter_arch(PPkgIterator *iterator);
const char *pkg_iter_current_version(PPkgIterator *iterator);
const char *pkg_iter_candidate_version(PPkgIterator *iterator);
// ver_iter creation and deletion
PVerIterator *pkg_iter_ver_iter(PPkgIterator *iterator);
void ver_iter_release(PVerIterator *iterator);
// ver_iter mutation
void ver_iter_next(PVerIterator *iterator);
bool ver_iter_end(PVerIterator *iterator);
// ver_iter access
const char *ver_iter_version(PVerIterator *iterator);
const char *ver_iter_section(PVerIterator *iterator);
const char *ver_iter_arch(PVerIterator *iterator);
const char *ver_iter_priority_type(PVerIterator *wrapper);
#ifndef YE_OLDE_APT
const char *ver_iter_source_package(PVerIterator *iterator);
const char *ver_iter_source_version(PVerIterator *iterator);
int32_t ver_iter_priority(PVerIterator *iterator);
#endif
// dep_iter creation and deletion
PDepIterator *ver_iter_dep_iter(PVerIterator *iterator);
void dep_iter_release(PDepIterator *iterator);
// dep_iter mutation
void dep_iter_next(PDepIterator *iterator);
bool dep_iter_end(PDepIterator *iterator);
// dep_iter access
PPkgIterator *dep_iter_target_pkg(PDepIterator *iterator);
const char *dep_iter_target_ver(PDepIterator *iterator);
const char *dep_iter_comp_type(PDepIterator *iterator);
const char *dep_iter_dep_type(PDepIterator *iterator);
// ver_file_iter creation and deletion
PVerFileIterator *ver_iter_ver_file_iter(PVerIterator *iterator);
void ver_file_iter_release(PVerFileIterator *iterator);
// ver_file_iter mutation
void ver_file_iter_next(PVerFileIterator *iterator);
bool ver_file_iter_end(PVerFileIterator *iterator);
// ver_file_parser creation
PVerFileParser *ver_file_iter_get_parser(PVerFileIterator *iterator);
// ver_file_parser access
const char *ver_file_parser_short_desc(PVerFileParser *parser);
const char *ver_file_parser_long_desc(PVerFileParser *parser);
const char *ver_file_parser_maintainer(PVerFileParser *parser);
const char *ver_file_parser_homepage(PVerFileParser *parser);
// ver_file_iter has no accessors, only the creation of pkg_file_iter
// pkg_file_iter creation
PPkgFileIterator *ver_file_iter_pkg_file_iter(PVerFileIterator *iterator);
void pkg_file_iter_release(PPkgFileIterator *iterator);
// pkg_file_iter mutation
void pkg_file_iter_next(PPkgFileIterator *iterator);
bool pkg_file_iter_end(PPkgFileIterator *iterator);
// pkg_file_iter access
const char *pkg_file_iter_file_name(PPkgFileIterator *iterator);
const char *pkg_file_iter_archive(PPkgFileIterator *iterator);
const char *pkg_file_iter_version(PPkgFileIterator *iterator);
const char *pkg_file_iter_origin(PPkgFileIterator *iterator);
const char *pkg_file_iter_codename(PPkgFileIterator *iterator);
const char *pkg_file_iter_label(PPkgFileIterator *iterator);
const char *pkg_file_iter_site(PPkgFileIterator *iterator);
const char *pkg_file_iter_component(PPkgFileIterator *iterator);
const char *pkg_file_iter_architecture(PPkgFileIterator *iterator);
const char *pkg_file_iter_index_type(PPkgFileIterator *iterator);
}
void init_config_system() {
pkgInitConfig(*_config);
pkgInitSystem(*_config, _system);
}
#ifndef ALT_LINUX
PCache *pkg_cache_create() {
pkgCacheFile *cache_file = new pkgCacheFile();
pkgCache *cache = cache_file->GetPkgCache();
pkgRecords *records = new pkgRecords(*cache);
PCache *ret = new PCache();
ret->cache_file = cache_file;
ret->cache = cache;
ret->records = records;
return ret;
}
#else
const char *to_c_string(std::string s);
#include <unistd.h>
bool can_commit() {
// Allow user with effective SU to acquire lock
return geteuid() == 0;
}
// See ALT's apt/cmdline
// Used to print out the progress
// Set to stdout for now
ostream progress_stream(0);
PCache *pkg_cache_create() {
// Maybe should be set to false sometimes
// (Set to can_commit() for now)
// We should lock for installation, etc.
// For read-only access no locking needed
// In apt-shell, WithLock is always set according to (geteuid() == 0).
const bool WithLock = can_commit();
CacheFile *cache_file = new CacheFile(progress_stream, WithLock);
cache_file->Open();
if (cache_file->CheckDeps(true) == false) {
delete cache_file;
return nullptr;
}
// cast operator from CacheFile to pkgCache*
pkgCache *cache = *cache_file;
pkgRecords *records = new pkgRecords(*cache);
PCache *ret = new PCache();
ret->cache_file = cache_file;
ret->cache = cache;
ret->records = records;
return ret;
}
#endif
void pkg_cache_release(PCache *cache) {
// TODO: is cache->cache cleaned up with cache->cache_file?
delete cache->records;
delete cache->cache_file;
delete cache;
}
int32_t pkg_cache_compare_versions(PCache *cache, const char *left, const char *right) {
// an int is returned here; presumably it will always be -1, 0 or 1.
return cache->cache->VS->DoCmpVersion(left, left+strlen(left), right, right+strlen(right));
}
PPkgIterator *pkg_cache_pkg_iter(PCache *cache) {
PPkgIterator *wrapper = new PPkgIterator();
wrapper->iterator = cache->cache->PkgBegin();
wrapper->cache = cache;
return wrapper;
}
PPkgIterator *pkg_cache_find_name(PCache *cache, const char *name) {
PPkgIterator *wrapper = new PPkgIterator();
wrapper->iterator = cache->cache->FindPkg(name);
wrapper->cache = cache;
return wrapper;
}
#ifndef ALT_LINUX
PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name, const char *arch) {
PPkgIterator *wrapper = new PPkgIterator();
wrapper->iterator = cache->cache->FindPkg(name, arch);
wrapper->cache = cache;
return wrapper;
}
#else
PPkgIterator *pkg_cache_find_name_arch(PCache *cache, const char *name) {
PPkgIterator *wrapper = new PPkgIterator();
wrapper->iterator = cache->cache->FindPkg(name);
wrapper->cache = cache;
return wrapper;
}
#endif
void pkg_iter_release(PPkgIterator *wrapper) {
delete wrapper;
}
void pkg_iter_next(PPkgIterator *wrapper) {
++wrapper->iterator;
}
bool pkg_iter_end(PPkgIterator *wrapper) {
return wrapper->cache->cache->PkgEnd() == wrapper->iterator;
}
const char *pkg_iter_name(PPkgIterator *wrapper) {
return wrapper->iterator.Name();
}
#ifndef ALT_LINUX
const char *pkg_iter_arch(PPkgIterator *wrapper) {
return wrapper->iterator.Arch();
}
const char *pkg_iter_current_version(PPkgIterator *wrapper) {
return wrapper->iterator.CurVersion();
}
const char *pkg_iter_candidate_version(PPkgIterator *wrapper) {
pkgCache::VerIterator it = wrapper->cache->cache_file->GetPolicy()->GetCandidateVer(wrapper->iterator);
if (it.end()) {
return nullptr;
}
return it.VerStr();
}
#else
const char *pkg_iter_arch(PPkgIterator *wrapper) {
pkgCache::VerIterator it = wrapper->iterator.VersionList();
if (it.end()) {
// It's a virtual package
// Let's take some of providers and take it's arch
pkgCache::PrvIterator provide_list = wrapper->iterator.ProvidesList();
if (provide_list.end()) {
// Return 'something' in case of broken packages
// I would prefer returning nullptr,
// but Rust-side requires it to be non-null
return to_c_string("Undefined");
}
pkgCache::PkgIterator provide = provide_list.OwnerPkg();
if (provide.end()) {
return to_c_string("Undefined");
}
PPkgIterator new_wrapper;
new_wrapper.iterator = provide;
new_wrapper.cache = wrapper->cache;
return pkg_iter_arch(&new_wrapper);
} else {
return it.Arch();
}
}
const char *pkg_iter_current_version(PPkgIterator *wrapper) {
pkgCache::VerIterator it = wrapper->iterator.CurrentVer();
if (it.end()) {
return nullptr;
}
return it.VerStr();
}
const char *pkg_iter_candidate_version(PPkgIterator *wrapper) {
// pkgCache::VerIterator it = wrapper->cache->cache_file->GetPolicy(Progress)->GetCandidateVer(wrapper->iterator);
// Getting rid of GetPolicy call by creating PkgPolicy object via constructor (no need in OpProgress)
// (This is done this way in cmdline apt utility (see ALT's apt/cmdline sources))
pkgPolicy plcy(wrapper->cache->cache);
pkgCache::VerIterator it = plcy.GetCandidateVer(wrapper->iterator);
if (it.end()) {
return nullptr;
}
return it.VerStr();
}
#endif
PVerIterator *pkg_iter_ver_iter(PPkgIterator *wrapper) {
PVerIterator *new_wrapper = new PVerIterator();
new_wrapper->iterator = wrapper->iterator.VersionList();
new_wrapper->pkg = &wrapper->iterator;
new_wrapper->cache = wrapper->cache;
return new_wrapper;
}
void ver_iter_release(PVerIterator *wrapper) {
delete wrapper;
}
void ver_iter_next(PVerIterator *wrapper) {
++wrapper->iterator;
}
bool ver_iter_end(PVerIterator *wrapper) {
return wrapper->iterator.end();
}
const char *ver_iter_version(PVerIterator *wrapper) {
return wrapper->iterator.VerStr();
}
const char *ver_iter_section(PVerIterator *wrapper) {
return wrapper->iterator.Section();
}
const char *ver_iter_priority_type(PVerIterator *wrapper) {
return wrapper->iterator.PriorityType();
}
#ifndef YE_OLDE_APT
#ifndef ALT_LINUX
const char *ver_iter_source_package(PVerIterator *wrapper) {
return wrapper->iterator.SourcePkgName();
}
const char *ver_iter_source_version(PVerIterator *wrapper) {
return wrapper->iterator.SourceVerStr();
}
int32_t ver_iter_priority(PVerIterator *wrapper) {
// The priority is a "short", which is roughly a (signed) int16_t;
// going bigger just in case
return wrapper->cache->cache_file->GetPolicy()->GetPriority(wrapper->iterator);
}
#endif
#endif
#ifdef ALT_LINUX
const char *ver_iter_source_package(PVerIterator *wrapper) {
pkgRecords *recs = wrapper->cache->records;
pkgRecords::Parser &parse = recs->Lookup(wrapper->iterator.FileList());
// It's okay to return raw pointer to heap memory, due to convention in Rust-caller
// (it will be freed by an owning wrapper)
return to_c_string(parse.SourcePkg());
}
// SHOULD BE REMOVED FROM ALT'S VERSION! MEANINGLESS!
// Apt only works with rpms and not src.rpm
const char *ver_iter_source_version(PVerIterator *wrapper) {
return wrapper->iterator.VerStr();
}
int32_t ver_iter_priority(PVerIterator *wrapper) {
// return wrapper->cache->cache_file->GetPolicy(Progress)->GetPriority(*wrapper->pkg);
// Getting rid of GetPolicy call by creating PkgPolicy object with constructor (no need in OpProgress)
// (This is done this way in cmdline apt utility (see ALT's apt/cmdline sources))
pkgPolicy plcy(wrapper->cache->cache);
return plcy.GetPriority(*wrapper->pkg);
}
#endif
const char *ver_iter_arch(PVerIterator *wrapper) {
return wrapper->iterator.Arch();
}
PDepIterator *ver_iter_dep_iter(PVerIterator *wrapper) {
PDepIterator *new_wrapper = new PDepIterator();
new_wrapper->iterator = wrapper->iterator.DependsList();
new_wrapper->cache = wrapper->cache;
return new_wrapper;
}
void dep_iter_release(PDepIterator *wrapper) {
delete wrapper;
}
void dep_iter_next(PDepIterator *wrapper) {
++wrapper->iterator;
}
bool dep_iter_end(PDepIterator *wrapper) {
return wrapper->iterator.end();
}
PPkgIterator *dep_iter_target_pkg(PDepIterator *wrapper) {
PPkgIterator *new_wrapper = new PPkgIterator();
new_wrapper->iterator = wrapper->iterator.TargetPkg();
new_wrapper->cache = wrapper->cache;
return new_wrapper;
}
const char *dep_iter_target_ver(PDepIterator *wrapper) {
return wrapper->iterator.TargetVer();
}
const char *dep_iter_comp_type(PDepIterator *wrapper) {
return wrapper->iterator.CompType();
}
const char *dep_iter_dep_type(PDepIterator *wrapper) {
return wrapper->iterator.DepType();
}
PVerFileIterator *ver_iter_ver_file_iter(PVerIterator *wrapper) {
PVerFileIterator *new_wrapper = new PVerFileIterator();
new_wrapper->iterator = wrapper->iterator.FileList();
new_wrapper->cache = wrapper->cache;
return new_wrapper;
}
void ver_file_iter_release(PVerFileIterator *wrapper) {
delete wrapper;
}
void ver_file_iter_next(PVerFileIterator *wrapper) {
++wrapper->iterator;
}
PVerFileParser *ver_file_iter_get_parser(PVerFileIterator *wrapper) {
PVerFileParser *parser = new PVerFileParser();
parser->parser = &wrapper->cache->records->Lookup(wrapper->iterator);
return parser;
}
const char *to_c_string(std::string s) {
char *cstr = new char[s.length()+1];
std::strcpy(cstr, s.c_str());
return cstr;
}
const char *ver_file_parser_short_desc(PVerFileParser *parser) {
std::string desc = parser->parser->ShortDesc();
return to_c_string(desc);
}
const char *ver_file_parser_long_desc(PVerFileParser *parser) {
std::string desc = parser->parser->LongDesc();
return to_c_string(desc);
}
const char *ver_file_parser_maintainer(PVerFileParser *parser) {
std::string maint = parser->parser->Maintainer();
return to_c_string(maint);
}
#ifndef ALT_LINUX
const char *ver_file_parser_homepage(PVerFileParser *parser) {
std::string hp = parser->parser->Homepage();
return to_c_string(hp);
}
#else
// Should be erased from Alt's version or Alt's Apt should provide
// functionality for getting homepage address
const char *ver_file_parser_homepage(PVerFileParser *parser) {
// Unimplementable in ALT via PVerFileParser
// Maybe should remove it in ALT version of lib (or just return nullptr)
// Not sure in use of nullptr due to possible absense of checks from caller
// So return dummy string
return to_c_string("Not Specified");
}
#endif
bool ver_file_iter_end(PVerFileIterator *wrapper) {
return wrapper->iterator.end();
}
PPkgFileIterator *ver_file_iter_pkg_file_iter(PVerFileIterator *wrapper) {
PPkgFileIterator *new_wrapper = new PPkgFileIterator();
new_wrapper->iterator = wrapper->iterator.File();
return new_wrapper;
}
void pkg_file_iter_release(PPkgFileIterator *wrapper) {
delete wrapper;
}
void pkg_file_iter_next(PPkgFileIterator *wrapper) {
++wrapper->iterator;
}
bool pkg_file_iter_end(PPkgFileIterator *wrapper) {
return wrapper->iterator.end();
}
const char *pkg_file_iter_file_name(PPkgFileIterator *wrapper) {
return wrapper->iterator.FileName();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_archive(PPkgFileIterator *wrapper) {
return wrapper->iterator.Archive();
}
#else
const char *pkg_file_iter_archive(PPkgFileIterator *wrapper) {
const char *archive = wrapper->iterator.Archive();
if (archive == nullptr) {
// Should be non-null
return to_c_string("Not Specified");
}
return archive;
}
#endif
const char *pkg_file_iter_version(PPkgFileIterator *wrapper) {
return wrapper->iterator.Version();
}
const char *pkg_file_iter_origin(PPkgFileIterator *wrapper) {
return wrapper->iterator.Origin();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_codename(PPkgFileIterator *wrapper) {
return wrapper->iterator.Codename();
}
#else
const char *pkg_file_iter_codename(PPkgFileIterator *wrapper) {
// From Debian docs:
/* "The Codename field shall describe the codename of the release.*/
// Analogues in ALT is Branch name.
return wrapper->iterator.Label();
}
#endif
const char *pkg_file_iter_label(PPkgFileIterator *wrapper) {
return wrapper->iterator.Label();
}
const char *pkg_file_iter_site(PPkgFileIterator *wrapper) {
return wrapper->iterator.Site();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_component(PPkgFileIterator *wrapper) {
return wrapper->iterator.Component();
}
#else
const char *pkg_file_iter_component(PPkgFileIterator *wrapper) {
const char *component = wrapper->iterator.Component();
if (component == nullptr) {
// Should be non-null
return to_c_string("Not Specified");
}
return component;
}
#endif
const char *pkg_file_iter_architecture(PPkgFileIterator *wrapper) {
return wrapper->iterator.Architecture();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_index_type(PPkgFileIterator *wrapper) {
return wrapper->iterator.IndexType();
}
#else
const char *pkg_file_iter_index_type(PPkgFileIterator *wrapper) {
const char *index_type = wrapper->iterator.IndexType();
if (index_type == nullptr) {
// Should be non-null
return to_c_string("Not Specified");
}
return index_type;
}
#endif

33
pve-rs/vendor/apt-pkg-native/build.rs vendored Normal file
View File

@ -0,0 +1,33 @@
extern crate cc;
const SRC: &str = "apt-pkg-c/lib.cpp";
fn main() {
println!("cargo:rerun-if-changed={}", SRC);
let mut build = cc::Build::new();
build.file(SRC);
build.cpp(true);
#[cfg(feature = "alt-linux")]
{
build.flag("-std=gnu++17");
}
#[cfg(not(feature = "alt-linux"))]
{
build.flag("-std=gnu++11");
}
#[cfg(feature = "ye-olde-apt")]
{
build.define("YE_OLDE_APT", "1");
}
#[cfg(feature = "alt-linux")]
{
build.define("ALT_LINUX", "1");
}
build.compile("libapt-pkg-c.a");
println!("cargo:rustc-link-lib=apt-pkg");
}

View File

@ -0,0 +1,14 @@
use apt_pkg_native::Cache;
use boolinator::Boolinator;
fn main() {
let mut cache = Cache::get_singleton();
for item in cache.iter().filter_map(|f| {
f.versions()
.any(|version| version.version().contains(':'))
.as_some_from(|| f.name())
}) {
println!("{}", item);
}
}

View File

@ -0,0 +1,15 @@
use itertools::Itertools;
use apt_pkg_native::simple;
use apt_pkg_native::Cache;
fn main() {
let mut cache = Cache::get_singleton();
for item in cache.iter().map(simple::BinaryPackageVersions::new) {
println!(
"{} [{}]",
item.pkg,
item.versions.iter().map(|x| format!("{}", x)).join(", ")
);
}
}

View File

@ -0,0 +1 @@
Makefile

View File

@ -0,0 +1,9 @@
FROM debian:sid
COPY sources.list /etc/apt/sources.list
ARG http_proxy
RUN env http_proxy=${http_proxy} apt-get update
WORKDIR /mnt

View File

@ -0,0 +1,5 @@
build:
docker build --network=mope --build-arg http_proxy=http://urika:3142 --tag sid-sources-list .
clean:
docker rmi sid-sources-list

View File

@ -0,0 +1,2 @@
deb http://deb.debian.org/debian sid main contrib non-free
deb-src http://deb.debian.org/debian sid main contrib non-free

View File

@ -0,0 +1 @@
Makefile

View File

@ -0,0 +1,11 @@
FROM ubuntu:trusty
ARG http_proxy
RUN env http_proxy=${http_proxy} apt-get update \
&& apt-get install -y build-essential libapt-pkg-dev curl
COPY uprust.sh /root/uprust.sh
RUN bash /root/uprust.sh --default-toolchain nightly -y
WORKDIR /mnt

View File

@ -0,0 +1,10 @@
build:
docker build --network=mope --build-arg http_proxy=http://urika:3142 --tag trusty-dev-vm .
run: build
docker run --network=mope -v $(shell pwd)/../..:/mnt -it trusty-dev-vm
clean:
docker rmi trusty-dev-vm
.PHONY: build run

View File

@ -0,0 +1,362 @@
#!/bin/sh
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
# This is just a little script that can be curled from the internet to
# install rustup. It just does platform detection, curls the installer
# and runs it.
set -u
RUSTUP_UPDATE_ROOT="https://static.rust-lang.org/rustup/dist"
#XXX: If you change anything here, please make the same changes in setup_mode.rs
usage() {
cat 1>&2 <<EOF
rustup-init 1.0.0 (408ed84 2017-02-11)
The installer for rustup
USAGE:
rustup-init [FLAGS] [OPTIONS]
FLAGS:
-v, --verbose Enable verbose output
-y Disable confirmation prompt.
--no-modify-path Don't configure the PATH environment variable
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--default-host <default-host> Choose a default host triple
--default-toolchain <default-toolchain> Choose a default toolchain to install
--default-toolchain none Do not install any toolchains
EOF
}
main() {
need_cmd uname
need_cmd curl
need_cmd mktemp
need_cmd chmod
need_cmd mkdir
need_cmd rm
need_cmd rmdir
get_architecture || return 1
local _arch="$RETVAL"
assert_nz "$_arch" "arch"
local _ext=""
case "$_arch" in
*windows*)
_ext=".exe"
;;
esac
local _url="$RUSTUP_UPDATE_ROOT/$_arch/rustup-init$_ext"
local _dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t rustup)"
local _file="$_dir/rustup-init$_ext"
local _ansi_escapes_are_valid=false
if [ -t 2 ]; then
if [ "${TERM+set}" = 'set' ]; then
case "$TERM" in
xterm*|rxvt*|urxvt*|linux*|vt*)
_ansi_escapes_are_valid=true
;;
esac
fi
fi
# check if we have to use /dev/tty to prompt the user
local need_tty=yes
for arg in "$@"; do
case "$arg" in
-h|--help)
usage
exit 0
;;
-y)
# user wants to skip the prompt -- we don't need /dev/tty
need_tty=no
;;
*)
;;
esac
done
if $_ansi_escapes_are_valid; then
printf "\33[1minfo:\33[0m downloading installer\n" 1>&2
else
printf '%s\n' 'info: downloading installer' 1>&2
fi
ensure mkdir -p "$_dir"
ensure curl -sSfL "$_url" -o "$_file"
ensure chmod u+x "$_file"
if [ ! -x "$_file" ]; then
printf '%s\n' "Cannot execute $_file (likely because of mounting /tmp as noexec)." 1>&2
printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./rustup-init$_ext." 1>&2
exit 1
fi
if [ "$need_tty" = "yes" ]; then
# The installer is going to want to ask for confirmation by
# reading stdin. This script was piped into `sh` though and
# doesn't have stdin to pass to its children. Instead we're going
# to explicitly connect /dev/tty to the installer's stdin.
if [ ! -t 1 ]; then
err "Unable to run interactively. Run with -y to accept defaults, --help for additional options"
fi
ignore "$_file" "$@" < /dev/tty
else
ignore "$_file" "$@"
fi
local _retval=$?
ignore rm "$_file"
ignore rmdir "$_dir"
return "$_retval"
}
get_bitness() {
need_cmd head
# Architecture detection without dependencies beyond coreutils.
# ELF files start out "\x7fELF", and the following byte is
# 0x01 for 32-bit and
# 0x02 for 64-bit.
# The printf builtin on some shells like dash only supports octal
# escape sequences, so we use those.
local _current_exe_head=$(head -c 5 /proc/self/exe )
if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then
echo 32
elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then
echo 64
else
err "unknown platform bitness"
fi
}
get_endianness() {
local cputype=$1
local suffix_eb=$2
local suffix_el=$3
# detect endianness without od/hexdump, like get_bitness() does.
need_cmd head
need_cmd tail
local _current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)"
if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then
echo "${cputype}${suffix_el}"
elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then
echo "${cputype}${suffix_eb}"
else
err "unknown platform endianness"
fi
}
get_architecture() {
local _ostype="$(uname -s)"
local _cputype="$(uname -m)"
if [ "$_ostype" = Linux ]; then
if [ "$(uname -o)" = Android ]; then
local _ostype=Android
fi
fi
if [ "$_ostype" = Darwin -a "$_cputype" = i386 ]; then
# Darwin `uname -s` lies
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
local _cputype=x86_64
fi
fi
case "$_ostype" in
Android)
local _ostype=linux-android
;;
Linux)
local _ostype=unknown-linux-gnu
;;
FreeBSD)
local _ostype=unknown-freebsd
;;
NetBSD)
local _ostype=unknown-netbsd
;;
DragonFly)
local _ostype=unknown-dragonfly
;;
Darwin)
local _ostype=apple-darwin
;;
MINGW* | MSYS* | CYGWIN*)
local _ostype=pc-windows-gnu
;;
*)
err "unrecognized OS type: $_ostype"
;;
esac
case "$_cputype" in
i386 | i486 | i686 | i786 | x86)
local _cputype=i686
;;
xscale | arm)
local _cputype=arm
if [ "$_ostype" = "linux-android" ]; then
local _ostype=linux-androideabi
fi
;;
armv6l)
local _cputype=arm
if [ "$_ostype" = "linux-android" ]; then
local _ostype=linux-androideabi
else
local _ostype="${_ostype}eabihf"
fi
;;
armv7l | armv8l)
local _cputype=armv7
if [ "$_ostype" = "linux-android" ]; then
local _ostype=linux-androideabi
else
local _ostype="${_ostype}eabihf"
fi
;;
aarch64)
local _cputype=aarch64
;;
x86_64 | x86-64 | x64 | amd64)
local _cputype=x86_64
;;
mips)
local _cputype="$(get_endianness $_cputype "" 'el')"
;;
mips64)
local _bitness="$(get_bitness)"
if [ $_bitness = "32" ]; then
if [ $_ostype = "unknown-linux-gnu" ]; then
# 64-bit kernel with 32-bit userland
# endianness suffix is appended later
local _cputype=mips
fi
else
# only n64 ABI is supported for now
local _ostype="${_ostype}abi64"
fi
local _cputype="$(get_endianness $_cputype "" 'el')"
;;
ppc)
local _cputype=powerpc
;;
ppc64)
local _cputype=powerpc64
;;
ppc64le)
local _cputype=powerpc64le
;;
*)
err "unknown CPU type: $_cputype"
esac
# Detect 64-bit linux with 32-bit userland
if [ $_ostype = unknown-linux-gnu -a $_cputype = x86_64 ]; then
if [ "$(get_bitness)" = "32" ]; then
local _cputype=i686
fi
fi
# Detect armv7 but without the CPU features Rust needs in that build,
# and fall back to arm.
# See https://github.com/rust-lang-nursery/rustup.rs/issues/587.
if [ $_ostype = "unknown-linux-gnueabihf" -a $_cputype = armv7 ]; then
if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then
# At least one processor does not have NEON.
local _cputype=arm
fi
fi
local _arch="$_cputype-$_ostype"
RETVAL="$_arch"
}
say() {
echo "rustup: $1"
}
err() {
say "$1" >&2
exit 1
}
need_cmd() {
if ! command -v "$1" > /dev/null 2>&1
then err "need '$1' (command not found)"
fi
}
need_ok() {
if [ $? != 0 ]; then err "$1"; fi
}
assert_nz() {
if [ -z "$1" ]; then err "assert_nz $2"; fi
}
# Run a command that should never fail. If the command fails execution
# will immediately terminate with an error showing the failing
# command.
ensure() {
"$@"
need_ok "command failed: $*"
}
# This is just for indicating that commands' results are being
# intentionally ignored. Usually, because it's being executed
# as part of error handling.
ignore() {
"$@"
}
main "$@" || exit 1

View File

@ -0,0 +1,52 @@
use std::env;
use apt_pkg_native::simple;
use apt_pkg_native::Cache;
fn main() {
let pkg = env::args()
.nth(1)
.expect("usage: first argument: package name");
let arch = env::args().nth(2);
let mut cache = Cache::get_singleton();
let mut found = match arch {
Some(arch) => cache.find_by_name_arch(pkg.as_str(), arch.as_str()),
None => cache.find_by_name(pkg.as_str()),
};
if let Some(view) = found.next() {
println!("{}:{}:", view.name(), view.arch());
let installed_version = view
.current_version()
.unwrap_or_else(|| "(none)".to_string());
println!(" Installed: {}", installed_version);
println!(
" Candidate: {}",
view.candidate_version()
.unwrap_or_else(|| "(none)".to_string(),)
);
println!(" Version table:");
for simple::VersionOrigins { version, origins } in
view.versions().map(simple::VersionOrigins::new)
{
let marker = if version.version == installed_version {
"***"
} else {
" "
};
#[cfg(not(feature = "ye-olde-apt"))]
println!(" {} {} {}", marker, version.version, version.priority,);
#[cfg(feature = "ye-olde-apt")]
println!(" {} {}", marker, version.version,);
for origin in origins {
println!(" {:4} {}", "XXX", origin);
}
}
} else {
println!("unrecognised package: {}", pkg);
}
}

View File

@ -0,0 +1,84 @@
use std::collections::HashMap;
use std::collections::HashSet;
/// A port of a randomly selected Python program:
///
/// ```python
/// #!/usr/bin/python3
/// import collections
/// import apt
/// cache = apt.cache.Cache()
/// def versions_in(suite):
/// source_versions = collections.defaultdict(set)
///
/// for package in cache:
/// for version in package.versions:
/// if suite and suite not in (origin.archive for origin in version.origins):
/// continue
/// source_versions[version.source_name].add(version.source_version)
/// return source_versions
///
/// if '__main__' == __name__:
/// import sys
/// sources = versions_in(sys.argv[1] if len(sys.argv) > 1 else None)
/// for src in sorted(sources.keys()):
/// # sort lexographically for determinism, not for any other reason
/// for ver in sorted(sources[src]):
/// print('{}={}'.format(src, ver))
/// ```
use std::env;
use apt_pkg_native::Cache;
#[cfg(feature = "ye-olde-apt")]
fn main() {
eprintln!("ye-olde-apt pre-dates source versions")
}
#[cfg(not(feature = "ye-olde-apt"))]
fn main() {
let archive_filter = env::args().nth(1);
let mut cache = Cache::get_singleton();
let mut source_versions = HashMap::new();
{
let mut all_packages = cache.iter();
while let Some(binary) = all_packages.next() {
let mut binary_versions = binary.versions();
while let Some(version) = binary_versions.next() {
if let Some(ref target_archive) = archive_filter {
if version
.origin_iter()
.map(|origin| origin.file().next().unwrap().archive())
.any(|archive| archive == *target_archive)
{
continue;
}
}
source_versions
.entry(version.source_package())
.or_insert_with(HashSet::new)
.insert(version.source_version());
}
}
}
for src in lexicographic_sort(source_versions.keys()) {
let mut sorted_versions: Vec<&String> = source_versions[src].iter().collect();
sorted_versions.sort_by(|left, right| cache.compare_versions(left, right));
for ver in sorted_versions {
println!("{}={}", src, ver);
}
}
}
fn lexicographic_sort<I, T>(input: I) -> Vec<T>
where
T: Ord + Clone,
I: Iterator<Item = T>,
{
let mut val: Vec<T> = input.collect();
val.sort();
val
}

View File

@ -0,0 +1,183 @@
use std::marker::PhantomData;
use std::ops::Deref;
pub trait RawIterator {
type View;
fn is_end(&self) -> bool;
fn next(&mut self);
fn as_view(&self) -> Self::View;
fn release(&mut self);
}
pub struct CIterator<R>
where
R: RawIterator,
{
pub first: bool,
pub raw: R,
}
impl<R> Drop for CIterator<R>
where
R: RawIterator,
{
fn drop(&mut self) {
self.raw.release();
}
}
pub struct Borrowed<'i, R>
where
R: 'i + RawIterator,
{
it: PhantomData<&'i CIterator<R>>,
val: R::View,
}
impl<'i, R> Deref for Borrowed<'i, R>
where
R: RawIterator,
{
type Target = R::View;
fn deref(&self) -> &R::View {
&self.val
}
}
impl<R> CIterator<R>
where
R: RawIterator,
{
pub fn next(&mut self) -> Option<Borrowed<R>> {
if self.raw.is_end() {
return None;
}
if !self.first {
self.raw.next();
}
self.first = false;
// we don't want to observe the end marker
if self.raw.is_end() {
None
} else {
Some(Borrowed {
it: PhantomData,
val: self.raw.as_view(),
})
}
}
pub fn map<F, B>(self, f: F) -> CMap<R, F>
where
F: FnMut(&R::View) -> B,
{
CMap { it: self, f }
}
pub fn filter_map<F, B>(self, f: F) -> CFilterMap<R, F>
where
F: FnMut(&R::View) -> Option<B>,
{
CFilterMap { it: self, f }
}
pub fn any<F>(mut self, mut f: F) -> bool
where
F: FnMut(&R::View) -> bool,
{
while let Some(view) = self.next() {
if (f)(&view) {
return true;
}
}
false
}
pub fn all<F>(mut self, mut f: F) -> bool
where
F: FnMut(&R::View) -> bool,
{
while let Some(view) = self.next() {
if !(f)(&view) {
return false;
}
}
true
}
pub fn count(mut self) -> usize {
// Not sure this is actually better than self.map(|_| ()).count()
let mut count = 0;
while !self.raw.is_end() {
self.raw.next();
count += 1;
}
count
}
}
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct CMap<R, F>
where
R: RawIterator,
{
it: CIterator<R>,
f: F,
}
impl<B, R, F> Iterator for CMap<R, F>
where
R: RawIterator,
F: FnMut(&R::View) -> B,
{
type Item = B;
fn next(&mut self) -> Option<Self::Item> {
match self.it.next() {
Some(ref x) => Some((self.f)(x)),
None => None,
}
}
}
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct CFilterMap<R, F>
where
R: RawIterator,
{
it: CIterator<R>,
f: F,
}
impl<B, R, F> Iterator for CFilterMap<R, F>
where
R: RawIterator,
F: FnMut(&R::View) -> Option<B>,
{
type Item = B;
fn next(&mut self) -> Option<Self::Item> {
loop {
match self.it.next() {
Some(ref x) => {
if let Some(y) = (self.f)(x) {
return Some(y);
}
}
None => return None,
}
}
}
}

86
pve-rs/vendor/apt-pkg-native/src/lib.rs vendored Normal file
View File

@ -0,0 +1,86 @@
//! Here lies bindings to `libapt-pkg`, which is what the `apt`, `apt-get`, `apt-cache`, etc.
//! commands use to view and manipulate the state of packages on the system.
//!
//! Currently, not much is exposed. You can pretty much only view basic package
//! information, like with `apt-cache policy foo`.
//!
//! `libapt-pkg` has basically no documentation. `python-apt` is slightly better,
//! but is also pretty inconsistent on the documentation front. The design of this
//! crate is closer to `libapt-pkg`, despite it being pretty insane.
//!
//! The core concept here is an "iterator". Forget everything you know about iterators,
//! these iterators are pretty much pointers. The crate attempts to make them act
//! a bit more like Rust `Iterator`s, but is crippled by the insanity.
//!
//! Methods which "find" something will reposition one of these "iterators" at the right place
//! in an existing stream of items.
//!
//! I recommend using `.map()` to turn an "iterator" into a Rust type as soon as possible.
//! The returned map-like thing *is* a Rust `Iterator`, so you can do normal operations on it.
//!
//! Here's an example: normally you wouldn't need this ugly `.map(|_| ())` (read as "map anything
//! to the empty object"), but here, it is *also* converting a sh... apt "iterator" into a
//! real Iterator.
//!
//! ```rust,no_run
//! extern crate apt_pkg_native;
//! let mut cache = apt_pkg_native::Cache::get_singleton();
//! let total_packages = cache.iter().map(|_| ()).count();
//! ```
//!
//! `libapt-pkg` also just segfaults if you do anything wrong, or re-use anything at the wrong time,
//! or etc. I've tried to hide this, but I advise you not to push or outsmart the borrow checker.
mod citer;
mod raw;
pub mod sane;
pub mod simple;
pub use crate::sane::Cache;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn pretty_print_all() {
let mut cache = Cache::get_singleton();
let read_all_and_count = cache.iter().map(simple::BinaryPackageVersions::new).count();
assert!(read_all_and_count > 2);
assert_eq!(read_all_and_count, cache.iter().count());
}
#[test]
fn find_a_package() {
let mut cache = Cache::get_singleton();
if let Some(view) = cache.find_by_name("apt").next() {
assert_eq!("apt", view.name());
} else {
panic!("not found!");
}
assert!(cache
.find_by_name("this-package-doesnt-exist-and-if-someone-makes-it-ill-be-really-angry")
.next()
.is_none());
}
#[test]
fn compare_versions() {
use std::cmp::Ordering;
let cache = Cache::get_singleton();
assert_eq!(Ordering::Less, cache.compare_versions("3.0", "3.1"));
assert_eq!(Ordering::Greater, cache.compare_versions("3.1", "3.0"));
assert_eq!(Ordering::Equal, cache.compare_versions("3.0", "3.0"));
}
#[test]
fn reload() {
let mut cache = Cache::get_singleton();
cache.reload();
cache.reload();
cache.reload();
cache.reload();
}
}

167
pve-rs/vendor/apt-pkg-native/src/raw.rs vendored Normal file
View File

@ -0,0 +1,167 @@
/// In general:
/// * `*mut c_void` are to be released by the appropriate function
/// * `*const c_chars` are short-term borrows
/// * `*mut c_chars` are to be freed by `libc::free`.
use std::sync::Mutex;
use lazy_static::lazy_static;
use libc::c_char;
use libc::c_void;
pub type PCache = *mut c_void;
pub type PPkgIterator = *mut c_void;
pub type PVerIterator = *mut c_void;
pub type PDepIterator = *mut c_void;
pub type PVerFileIterator = *mut c_void;
pub type PPkgFileIterator = *mut c_void;
pub type PVerFileParser = *mut c_void;
#[link(name = "apt-pkg-c", kind = "static")]
#[link(name = "apt-pkg")]
extern "C" {
/// Must be called exactly once, before anything else?
fn init_config_system();
fn pkg_cache_create() -> PCache;
fn pkg_cache_release(cache: PCache);
pub fn pkg_cache_compare_versions(
cache: PCache,
left: *const c_char,
right: *const c_char,
) -> i32;
// Package iterators
// =================
pub fn pkg_cache_pkg_iter(cache: PCache) -> PPkgIterator;
pub fn pkg_cache_find_name(cache: PCache, name: *const c_char) -> PPkgIterator;
#[cfg(not(feature = "alt-linux"))]
pub fn pkg_cache_find_name_arch(
cache: PCache,
name: *const c_char,
arch: *const c_char,
) -> PPkgIterator;
#[cfg(feature = "alt-linux")]
pub fn pkg_cache_find_name_arch(
cache: PCache,
name: *const c_char,
) -> PPkgIterator;
pub fn pkg_iter_release(iterator: PPkgIterator);
pub fn pkg_iter_next(iterator: PPkgIterator);
pub fn pkg_iter_end(iterator: PPkgIterator) -> bool;
// Package iterator accessors
// ==========================
pub fn pkg_iter_name(iterator: PPkgIterator) -> *const c_char;
pub fn pkg_iter_arch(iterator: PPkgIterator) -> *const c_char;
pub fn pkg_iter_current_version(iterator: PPkgIterator) -> *const c_char;
pub fn pkg_iter_candidate_version(iterator: PPkgIterator) -> *const c_char;
// Version iterators
// =================
pub fn pkg_iter_ver_iter(pkg: PPkgIterator) -> PVerIterator;
pub fn ver_iter_release(iterator: PVerIterator);
pub fn ver_iter_next(iterator: PVerIterator);
pub fn ver_iter_end(iterator: PVerIterator) -> bool;
// Version accessors
// =================
pub fn ver_iter_version(iterator: PVerIterator) -> *mut c_char;
pub fn ver_iter_section(iterator: PVerIterator) -> *mut c_char;
#[cfg(not(feature = "ye-olde-apt"))]
pub fn ver_iter_source_package(iterator: PVerIterator) -> *mut c_char;
#[cfg(not(feature = "ye-olde-apt"))]
pub fn ver_iter_source_version(iterator: PVerIterator) -> *mut c_char;
pub fn ver_iter_arch(iterator: PVerIterator) -> *mut c_char;
pub fn ver_iter_priority_type(iterator: PVerIterator) -> *mut c_char;
#[cfg(not(feature = "ye-olde-apt"))]
pub fn ver_iter_priority(iterator: PVerIterator) -> i32;
// Dependency iterators
// ====================
pub fn ver_iter_dep_iter(iterator: PVerIterator) -> PDepIterator;
pub fn dep_iter_release(iterator: PDepIterator);
pub fn dep_iter_next(iterator: PDepIterator);
pub fn dep_iter_end(iterator: PDepIterator) -> bool;
// Dependency accessors
// ====================
pub fn dep_iter_target_pkg(iterator: PDepIterator) -> PPkgIterator;
pub fn dep_iter_target_ver(iterator: PDepIterator) -> *const c_char;
pub fn dep_iter_comp_type(iterator: PDepIterator) -> *const c_char;
pub fn dep_iter_dep_type(iterator: PDepIterator) -> *const c_char;
pub fn ver_iter_ver_file_iter(iterator: PVerIterator) -> PVerFileIterator;
pub fn ver_file_iter_release(iterator: PVerFileIterator);
pub fn ver_file_iter_next(iterator: PVerFileIterator);
pub fn ver_file_iter_end(iterator: PVerFileIterator) -> bool;
pub fn ver_file_iter_get_parser(iterator: PVerFileIterator) -> PVerFileParser;
pub fn ver_file_parser_short_desc(parser: PVerFileParser) -> *const c_char;
pub fn ver_file_parser_long_desc(parser: PVerFileParser) -> *const c_char;
pub fn ver_file_parser_maintainer(parser: PVerFileParser) -> *const c_char;
pub fn ver_file_parser_homepage(parser: PVerFileParser) -> *const c_char;
pub fn ver_file_iter_pkg_file_iter(iterator: PVerFileIterator) -> PPkgFileIterator;
pub fn pkg_file_iter_release(iterator: PPkgFileIterator);
pub fn pkg_file_iter_next(iterator: PPkgFileIterator);
pub fn pkg_file_iter_end(iterator: PPkgFileIterator) -> bool;
pub fn pkg_file_iter_file_name(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_archive(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_version(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_origin(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_codename(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_label(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_site(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_component(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_architecture(iterator: PPkgFileIterator) -> *const c_char;
pub fn pkg_file_iter_index_type(iterator: PPkgFileIterator) -> *const c_char;
}
pub fn pkg_cache_get_singleton() -> &'static CACHE_SINGLETON {
&CACHE_SINGLETON
}
#[derive(Debug)]
pub struct CacheHolder {
pub ptr: PCache,
}
unsafe impl Send for CacheHolder {}
impl CacheHolder {
pub fn re_up(&mut self) {
unsafe {
pkg_cache_release(self.ptr);
self.ptr = pkg_cache_create();
}
}
}
lazy_static! {
#[derive(Debug)]
pub static ref CACHE_SINGLETON: Mutex<CacheHolder> = {
unsafe {
init_config_system();
Mutex::new(CacheHolder {
ptr: pkg_cache_create()
})
}
};
}

546
pve-rs/vendor/apt-pkg-native/src/sane.rs vendored Normal file
View File

@ -0,0 +1,546 @@
use std::cmp;
use std::ffi;
use std::marker::PhantomData;
use std::sync::MutexGuard;
use crate::citer::CIterator;
use crate::citer::RawIterator;
use crate::raw;
/// A reference to the package cache singleton,
/// from which most functionality can be accessed.
#[derive(Debug)]
pub struct Cache {
ptr_mutex: &'static raw::CACHE_SINGLETON,
}
impl Cache {
/// Get a reference to the singleton.
pub fn get_singleton() -> Cache {
Cache {
ptr_mutex: raw::pkg_cache_get_singleton(),
}
}
/// Drop the cache, and re-create it from scratch.
///
/// It's super important that there are no other outstanding
/// references to the cache at this point. Again, I remind you
/// not to try and outsmart the borrow checker. It doesn't know
/// how much trouble there is in here.
pub fn reload(&mut self) {
self.ptr_mutex.lock().expect("poisoned mutex").re_up()
}
/// Walk through all of the packages, in a random order.
///
/// If there are multiple architectures, multiple architectures will be returned.
///
/// See the module documentation for apologies about how this isn't an iterator.
pub fn iter(&mut self) -> CIterator<PkgIterator> {
let lock = self.ptr_mutex.lock().expect("poisoned mutex");
unsafe {
let raw_iter = raw::pkg_cache_pkg_iter(lock.ptr);
PkgIterator::new(lock, raw_iter)
}
}
/// Find a package by name. It's not clear whether this picks a random arch,
/// or the primary one.
///
/// The returned iterator will either be at the end, or at a package with the name.
pub fn find_by_name(&mut self, name: &str) -> CIterator<PkgIterator> {
let lock = self.ptr_mutex.lock().expect("poisoned mutex");
unsafe {
let name = ffi::CString::new(name).unwrap();
let ptr = raw::pkg_cache_find_name(lock.ptr, name.as_ptr());
PkgIterator::new(lock, ptr)
}
}
/// Find a package by name and architecture.
///
/// The returned iterator will either be at the end, or at a matching package.
pub fn find_by_name_arch(&mut self, name: &str, arch: &str) -> CIterator<PkgIterator> {
let lock = self.ptr_mutex.lock().expect("poisoned mutex");
unsafe {
let name = ffi::CString::new(name).unwrap();
let arch = ffi::CString::new(arch).unwrap();
#[cfg(feature = "alt-linux")]
let ptr = raw::pkg_cache_find_name_arch(lock.ptr, name.as_ptr());
#[cfg(not(feature = "alt-linux"))]
let ptr = raw::pkg_cache_find_name_arch(lock.ptr, name.as_ptr(), arch.as_ptr());
PkgIterator::new(lock, ptr)
}
}
/// Compare two versions, returning an `Ordering`, as used by most Rusty `sort()` methods.
///
/// This uses the "versioning scheme" currently set, which, in theory, can change,
/// but in practice is always the "Standard .deb" scheme. As of 2017, there aren't even any
/// other implementations. As such, this may eventually become a static method somewhere.
///
/// # Examples
///
/// ```rust
/// # let mut cache = apt_pkg_native::Cache::get_singleton();
/// let mut packages = vec!["3.0", "3.1", "3.0~1"];
/// packages.sort_by(|left, right| cache.compare_versions(left, right));
/// assert_eq!(vec!["3.0~1", "3.0", "3.1"], packages);
/// ```
pub fn compare_versions(&self, left: &str, right: &str) -> cmp::Ordering {
unsafe {
let left = ffi::CString::new(left).unwrap();
let right = ffi::CString::new(right).unwrap();
let lock = self.ptr_mutex.lock().expect("poisoned mutex");
raw::pkg_cache_compare_versions(lock.ptr, left.as_ptr(), right.as_ptr()).cmp(&0)
}
}
}
/// An "iterator"/pointer to a point in a package list.
#[derive(Debug)]
pub struct PkgIterator<'c> {
cache: MutexGuard<'c, raw::CacheHolder>,
ptr: raw::PPkgIterator,
}
impl<'c> PkgIterator<'c> {
fn new(cache: MutexGuard<'c, raw::CacheHolder>, ptr: raw::PCache) -> CIterator<Self> {
CIterator {
first: true,
raw: PkgIterator { cache, ptr },
}
}
}
// TODO: could this be a ref to the iterator?
// TODO: Can't get the lifetimes to work.
pub struct PkgView<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PPkgIterator,
}
impl<'c> RawIterator for PkgIterator<'c> {
type View = PkgView<'c>;
fn is_end(&self) -> bool {
unsafe { raw::pkg_iter_end(self.ptr) }
}
fn next(&mut self) {
unsafe { raw::pkg_iter_next(self.ptr) }
}
fn as_view(&self) -> Self::View {
assert!(!self.is_end());
PkgView {
ptr: self.ptr,
cache: PhantomData,
}
}
fn release(&mut self) {
unsafe { raw::pkg_iter_release(self.ptr) }
}
}
/// Actual accessors
impl<'c> PkgView<'c> {
pub fn name(&self) -> String {
unsafe {
make_owned_ascii_string(raw::pkg_iter_name(self.ptr))
.expect("packages always have names")
}
}
pub fn arch(&self) -> String {
unsafe {
make_owned_ascii_string(raw::pkg_iter_arch(self.ptr))
.expect("packages always have architectures")
}
}
pub fn current_version(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_iter_current_version(self.ptr)) }
}
pub fn candidate_version(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_iter_candidate_version(self.ptr)) }
}
pub fn versions(&self) -> CIterator<VerIterator> {
CIterator {
first: true,
raw: VerIterator {
cache: PhantomData,
ptr: unsafe { raw::pkg_iter_ver_iter(self.ptr) },
},
}
}
}
/// Represents a single PkgView without associated PkgIterator. Derefs to
/// regular PkgView and releases the internal iterator on drop.
pub struct SinglePkgView<'c> {
view: PkgView<'c>,
}
impl<'c> std::ops::Deref for SinglePkgView<'c> {
type Target = PkgView<'c>;
fn deref(&self) -> &Self::Target {
&self.view
}
}
impl<'c> Drop for SinglePkgView<'c> {
fn drop(&mut self) {
unsafe {
raw::pkg_iter_release(self.view.ptr);
}
}
}
/// An "iterator"/pointer to a point in a version list.
pub struct VerIterator<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PVerIterator,
}
pub struct VerView<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PVerIterator,
}
impl<'c> RawIterator for VerIterator<'c> {
type View = VerView<'c>;
fn is_end(&self) -> bool {
unsafe { raw::ver_iter_end(self.ptr) }
}
fn next(&mut self) {
unsafe { raw::ver_iter_next(self.ptr) }
}
fn as_view(&self) -> Self::View {
assert!(!self.is_end());
VerView {
ptr: self.ptr,
cache: self.cache,
}
}
fn release(&mut self) {
unsafe { raw::ver_iter_release(self.ptr) }
}
}
/// Actual accessors
impl<'c> VerView<'c> {
pub fn version(&self) -> String {
unsafe {
make_owned_ascii_string(raw::ver_iter_version(self.ptr))
.expect("versions always have a version")
}
}
pub fn arch(&self) -> String {
unsafe {
make_owned_ascii_string(raw::ver_iter_arch(self.ptr))
.expect("versions always have an arch")
}
}
pub fn section(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::ver_iter_section(self.ptr)) }
}
pub fn priority_type(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::ver_iter_priority_type(self.ptr)) }
}
#[cfg(not(feature = "ye-olde-apt"))]
pub fn source_package(&self) -> String {
unsafe {
make_owned_ascii_string(raw::ver_iter_source_package(self.ptr))
.expect("versions always have a source package")
}
}
#[cfg(not(feature = "ye-olde-apt"))]
pub fn source_version(&self) -> String {
unsafe {
make_owned_ascii_string(raw::ver_iter_source_version(self.ptr))
.expect("versions always have a source_version")
}
}
#[cfg(not(feature = "ye-olde-apt"))]
pub fn priority(&self) -> i32 {
unsafe { raw::ver_iter_priority(self.ptr) }
}
pub fn origin_iter(&self) -> CIterator<VerFileIterator> {
CIterator {
first: true,
raw: VerFileIterator {
cache: PhantomData,
ptr: unsafe { raw::ver_iter_ver_file_iter(self.ptr) },
},
}
}
pub fn dep_iter(&self) -> CIterator<DepIterator> {
CIterator {
first: true,
raw: DepIterator {
cache: PhantomData,
ptr: unsafe { raw::ver_iter_dep_iter(self.ptr) },
},
}
}
}
/// An "iterator"/pointer to a point in a dependency list.
pub struct DepIterator<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PDepIterator,
}
pub struct DepView<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PDepIterator,
}
impl<'c> RawIterator for DepIterator<'c> {
type View = DepView<'c>;
fn is_end(&self) -> bool {
unsafe { raw::dep_iter_end(self.ptr) }
}
fn next(&mut self) {
unsafe { raw::dep_iter_next(self.ptr) }
}
fn as_view(&self) -> Self::View {
assert!(!self.is_end());
DepView {
ptr: self.ptr,
cache: self.cache,
}
}
fn release(&mut self) {
unsafe { raw::dep_iter_release(self.ptr) }
}
}
/// Actual accessors
impl<'c> DepView<'c> {
pub fn target_pkg(&self) -> SinglePkgView {
let ptr = unsafe { raw::dep_iter_target_pkg(self.ptr) };
SinglePkgView {
view: PkgView {
cache: self.cache,
ptr,
},
}
}
pub fn target_ver(&self) -> String {
unsafe {
make_owned_ascii_string(raw::dep_iter_target_ver(self.ptr))
.expect("dependency always has target version")
}
}
pub fn comp_type(&self) -> String {
unsafe {
make_owned_ascii_string(raw::dep_iter_comp_type(self.ptr))
.expect("dependency always has comp type")
}
}
pub fn dep_type(&self) -> String {
unsafe {
make_owned_ascii_string(raw::dep_iter_dep_type(self.ptr))
.expect("dependency always has dep type")
}
}
}
/// An "iterator"/pointer to a point in a version's file list(?).
pub struct VerFileIterator<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PVerFileIterator,
}
// TODO: could this be a ref to the iterator?
// TODO: Can't get the lifetimes to work.
pub struct VerFileView<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PVerFileIterator,
parser: raw::PVerFileParser,
}
impl<'c> RawIterator for VerFileIterator<'c> {
type View = VerFileView<'c>;
fn is_end(&self) -> bool {
unsafe { raw::ver_file_iter_end(self.ptr) }
}
fn next(&mut self) {
unsafe { raw::ver_file_iter_next(self.ptr) }
}
fn as_view(&self) -> Self::View {
assert!(!self.is_end());
let parser = unsafe { raw::ver_file_iter_get_parser(self.ptr) };
VerFileView {
ptr: self.ptr,
cache: self.cache,
parser,
}
}
fn release(&mut self) {
unsafe { raw::ver_file_iter_release(self.ptr) }
}
}
impl<'c> VerFileView<'c> {
pub fn file(&self) -> CIterator<PkgFileIterator> {
CIterator {
first: true,
raw: PkgFileIterator {
cache: PhantomData,
ptr: unsafe { raw::ver_file_iter_pkg_file_iter(self.ptr) },
},
}
}
pub fn short_desc(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::ver_file_parser_short_desc(self.parser)) }
}
pub fn long_desc(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::ver_file_parser_long_desc(self.parser)) }
}
pub fn maintainer(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::ver_file_parser_maintainer(self.parser)) }
}
pub fn homepage(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::ver_file_parser_homepage(self.parser)) }
}
}
/// An "iterator"/pointer to a point in a file list.
pub struct PkgFileIterator<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PPkgFileIterator,
}
// TODO: could this be a ref to the iterator?
// TODO: Can't get the lifetimes to work.
pub struct PkgFileView<'c> {
cache: PhantomData<&'c MutexGuard<'c, raw::CacheHolder>>,
ptr: raw::PPkgFileIterator,
}
impl<'c> RawIterator for PkgFileIterator<'c> {
type View = PkgFileView<'c>;
fn is_end(&self) -> bool {
unsafe { raw::pkg_file_iter_end(self.ptr) }
}
fn next(&mut self) {
unsafe { raw::pkg_file_iter_next(self.ptr) }
}
fn as_view(&self) -> Self::View {
assert!(!self.is_end());
PkgFileView {
ptr: self.ptr,
cache: self.cache,
}
}
fn release(&mut self) {
unsafe { raw::pkg_file_iter_release(self.ptr) }
}
}
impl<'c> PkgFileView<'c> {
pub fn file_name(&self) -> String {
unsafe {
make_owned_ascii_string(raw::pkg_file_iter_file_name(self.ptr))
.expect("package file always has a file name")
}
}
pub fn archive(&self) -> String {
unsafe {
make_owned_ascii_string(raw::pkg_file_iter_archive(self.ptr))
.expect("package file always has an archive")
}
}
pub fn version(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_file_iter_version(self.ptr)) }
}
pub fn origin(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_file_iter_origin(self.ptr)) }
}
pub fn codename(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_file_iter_codename(self.ptr)) }
}
pub fn label(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_file_iter_label(self.ptr)) }
}
pub fn site(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_file_iter_site(self.ptr)) }
}
pub fn component(&self) -> String {
unsafe {
make_owned_ascii_string(raw::pkg_file_iter_component(self.ptr))
.expect("package file always has a component")
}
}
pub fn architecture(&self) -> Option<String> {
unsafe { make_owned_ascii_string(raw::pkg_file_iter_architecture(self.ptr)) }
}
pub fn index_type(&self) -> String {
unsafe {
make_owned_ascii_string(raw::pkg_file_iter_index_type(self.ptr))
.expect("package file always has a index_type")
}
}
}
unsafe fn make_owned_ascii_string(ptr: *const libc::c_char) -> Option<String> {
if ptr.is_null() {
None
} else {
Some(
ffi::CStr::from_ptr(ptr)
.to_str()
.expect("value should always be low-ascii")
.to_string(),
)
}
}

View File

@ -0,0 +1,189 @@
//! Some structs representing basic concepts, and utilities to copy out of "iterators".
use std::fmt;
use crate::sane;
#[derive(Clone, Debug)]
pub struct BinaryPackage {
pub name: String,
pub arch: String,
pub current_version: Option<String>,
pub candidate_version: Option<String>,
}
impl BinaryPackage {
pub fn new(view: &sane::PkgView) -> Self {
BinaryPackage {
name: view.name(),
arch: view.arch(),
current_version: view.current_version(),
candidate_version: view.candidate_version(),
}
}
}
impl fmt::Display for BinaryPackage {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{}", self.name, self.arch)?;
if let Some(ref version) = self.current_version {
write!(f, " @ {}", version)?;
}
if let Some(ref version) = self.candidate_version {
write!(f, " -> {}", version)?;
}
Ok(())
}
}
#[derive(Clone, Debug)]
pub struct Version {
pub version: String,
pub arch: String,
pub section: Option<String>,
#[cfg(not(feature = "ye-olde-apt"))]
pub source_package: String,
#[cfg(not(feature = "ye-olde-apt"))]
pub source_version: String,
#[cfg(not(feature = "ye-olde-apt"))]
pub priority: i32,
}
impl Version {
pub fn new(view: &sane::VerView) -> Self {
Version {
version: view.version(),
arch: view.arch(),
section: view.section(),
#[cfg(not(feature = "ye-olde-apt"))]
source_package: view.source_package(),
#[cfg(not(feature = "ye-olde-apt"))]
source_version: view.source_version(),
#[cfg(not(feature = "ye-olde-apt"))]
priority: view.priority(),
}
}
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{}", self.version, self.arch)?;
if let Some(ref section) = self.section {
write!(f, " in {}", section)?;
}
#[cfg(not(feature = "ye-olde-apt"))]
write!(
f,
" from {}:{} at {}",
self.source_package, self.source_version, self.priority,
)?;
Ok(())
}
}
#[derive(Clone, Debug)]
pub struct Origin {
pub file_name: String,
pub archive: String,
pub version: Option<String>,
pub origin: Option<String>,
pub codename: Option<String>,
pub label: Option<String>,
pub site: Option<String>,
pub component: String,
pub architecture: Option<String>,
pub index_type: String,
}
impl Origin {
pub fn from_ver_file(view: &sane::VerFileView) -> Option<Self> {
// TODO: don't think this deref-ref should really be necessary?
view.file().next().map(|x| Self::new(&*x))
}
pub fn new(view: &sane::PkgFileView) -> Self {
Origin {
file_name: view.file_name(),
archive: view.archive(),
version: view.version(),
origin: view.origin(),
codename: view.codename(),
label: view.label(),
site: view.site(),
component: view.component(),
architecture: view.architecture(),
index_type: view.index_type(),
}
}
}
impl fmt::Display for Origin {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// trying to simulate apt-cache policy, but a lot of information is missing
if self.site.is_some()
&& self.origin.is_some()
&& self.label.is_some()
&& self.codename.is_some()
&& self.architecture.is_some()
{
write!(
f,
"TODO://{}/TODO(o:{}/l:{}/c:{}) {}/{} {} (f:{})",
self.site.as_ref().unwrap(),
self.origin.as_ref().unwrap(),
self.label.as_ref().unwrap(),
self.codename.as_ref().unwrap(),
self.archive,
self.component,
self.architecture.as_ref().unwrap(),
self.file_name
)
} else {
write!(f, "{}", self.file_name)
}
}
}
#[derive(Clone, Debug)]
pub struct VersionOrigins {
pub version: Version,
pub origins: Vec<Origin>,
}
impl VersionOrigins {
pub fn new(view: &sane::VerView) -> Self {
VersionOrigins {
version: Version::new(view),
origins: view
.origin_iter()
.map(|o| {
Origin::from_ver_file(o)
.expect("a version's origin should always have a backing file")
})
.collect(),
}
}
}
#[derive(Clone, Debug)]
pub struct BinaryPackageVersions {
pub pkg: BinaryPackage,
pub versions: Vec<Version>,
}
impl BinaryPackageVersions {
pub fn new(view: &sane::PkgView) -> Self {
BinaryPackageVersions {
pkg: BinaryPackage::new(view),
versions: view.versions().map(Version::new).collect(),
}
}
}
impl fmt::Display for BinaryPackageVersions {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} + {} versions", self.pkg, self.versions.len())
}
}

View File

@ -1 +1 @@
{"files":{"Cargo.lock":"8e60b691c883629c1e19c8dad7c4c18cded1a85c2e8f2e2a77e7a96957f865a7","Cargo.toml":"f8c2d5675773b7ddff8801c3c17ff9d26e9632fe2027a6b81ceb7bda67d71bfd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"51238410cbbb06b149a794d954ff4d5943da566a97e71dc3aa8b5fa5a9b538b6","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/nightly.rs":"ac8b5a9aa1e04465e44f5053b3c899b635e07af058c73aa8b45176bf4b5912f9","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"fd8ff67c64f7cd1b9f81325a81de4baa34c39d6ae298bdb33f9829cc91acac39","src/lib.rs":"7b00cd501b52bab797bf047ada2a446e16fc2b8b05567670d8b8b7ada3179f55","src/rustc.rs":"a8a213ddb64a05c1a1af933bcb331a98879e942b167c33d8f94f9f60ebb14e29","src/tests.rs":"594a1cff6fef4a0f8b5f962a668fda4030db5005f37f01eeb06d692fc48a60df","src/version.rs":"4f7d23b36f01c7be1871be86c038d6cb4689e145d67c82d3793690e9aa05b133","tests/no_std.rs":"cc5619466c6e955552f30ed2f80ba8ddf45c3d5d257f628f54dedc0da978f6aa","tests/rustflags.rs":"5c8169b88216055019db61b5d7baf4abdf675e3b14b54f5037bb1e3acd0a5d3f","tests/wrap_ignored":"a9e241edf584a0702066b25bc15c5bbfd8a1019e14fb655fc4f47a67360065ca","tests/wrappers.rs":"e8eb0eb5ac28ecd9e3473b5ddc321b1d4d523a6fb0c072255ac37d40674aa35c"},"package":"0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"}
{"files":{"Cargo.lock":"c53e68eabea3d0b6dbc762cdc0c0bd105a7ac97c76e0b8c5f492d0b94074469c","Cargo.toml":"624e428251fce7244aa71fe7764c1556bc8077ee4579ad7e5803cc8a74061673","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"21308cfaaea9e841e01a43b7ec77304c1daeea8d0e3ec8fe5022d8e56acc4eb2","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/nightly.rs":"ac8b5a9aa1e04465e44f5053b3c899b635e07af058c73aa8b45176bf4b5912f9","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"fd8ff67c64f7cd1b9f81325a81de4baa34c39d6ae298bdb33f9829cc91acac39","src/lib.rs":"b40828305eb18bcaad11608fbbf82d97fe381803fbf1b89a1511f0675ba49e6c","src/rustc.rs":"a8a213ddb64a05c1a1af933bcb331a98879e942b167c33d8f94f9f60ebb14e29","src/tests.rs":"b39f4d880ad343e65307a9e0c381954ea27adce4732f825516ce7952e2e5a91d","src/version.rs":"4f7d23b36f01c7be1871be86c038d6cb4689e145d67c82d3793690e9aa05b133","tests/no_std.rs":"18859dc4992fe1769887bde05f03d28f1ce524eafd17646d3fbcb4379422761a","tests/rustflags.rs":"e8ded4d57ba25379a38ab48456d67df14f82abbbb5f6bb66221c6decbcb517a3","tests/support/mod.rs":"32087d365b438ac3f62df9bb066d8d648b80cb130a5c777afcb2f21fbb68d88e","tests/tests.rs":"abd41a6a937ee58d7dcb541384705f87ec47294f6af6dab821441d50fd66ee7d","tests/wrap_ignored":"a9e241edf584a0702066b25bc15c5bbfd8a1019e14fb655fc4f47a67360065ca","tests/wrappers.rs":"b5137fe36768eaef277fb8650b0fe45b2c675d9e60b1b49d39f2ec95082c285b"},"package":"ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"}

5
pve-rs/vendor/autocfg/Cargo.lock generated vendored
View File

@ -1,7 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "autocfg"
version = "1.3.0"
version = "1.4.0"

View File

@ -12,9 +12,14 @@
[package]
rust-version = "1.0"
name = "autocfg"
version = "1.3.0"
version = "1.4.0"
authors = ["Josh Stone <cuviper@gmail.com>"]
build = false
exclude = ["/.github/**"]
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Automatic cfg for Rust compiler features"
documentation = "https://docs.rs/autocfg/"
readme = "README.md"
@ -27,4 +32,44 @@ categories = ["development-tools::build-utils"]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/cuviper/autocfg"
[lib]
name = "autocfg"
path = "src/lib.rs"
[[example]]
name = "integers"
path = "examples/integers.rs"
[[example]]
name = "nightly"
path = "examples/nightly.rs"
[[example]]
name = "paths"
path = "examples/paths.rs"
[[example]]
name = "traits"
path = "examples/traits.rs"
[[example]]
name = "versions"
path = "examples/versions.rs"
[[test]]
name = "no_std"
path = "tests/no_std.rs"
[[test]]
name = "rustflags"
path = "tests/rustflags.rs"
[[test]]
name = "tests"
path = "tests/tests.rs"
[[test]]
name = "wrappers"
path = "tests/wrappers.rs"
[dependencies]

View File

@ -43,6 +43,13 @@ should only be used when the compiler supports it.
## Release Notes
- 1.4.0 (2024-09-26)
- Add `emit_possibility` for Rust 1.80's [checked cfgs], and call that
automatically for methods that conditionally `emit`, by @Techcable.
[checked cfgs]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
- 1.3.0 (2024-05-03)
- Add `probe_raw` for direct control of the code that will be test-compiled.

View File

@ -20,7 +20,8 @@
//!
//! fn main() {
//! # // Normally, cargo will set `OUT_DIR` for build scripts.
//! # std::env::set_var("OUT_DIR", "target");
//! # let exe = std::env::current_exe().unwrap();
//! # std::env::set_var("OUT_DIR", exe.parent().unwrap());
//! let ac = autocfg::new();
//! ac.emit_has_type("i128");
//!
@ -91,6 +92,7 @@ pub struct AutoCfg {
target: Option<OsString>,
no_std: bool,
rustflags: Vec<String>,
uuid: u64,
}
/// Writes a config flag for rustc on standard out.
@ -98,6 +100,12 @@ pub struct AutoCfg {
/// This looks like: `cargo:rustc-cfg=CFG`
///
/// Cargo will use this in arguments to rustc, like `--cfg CFG`.
///
/// This does not automatically call [`emit_possibility`]
/// so the compiler my generate an [`unexpected_cfgs` warning][check-cfg-flags].
/// However, all the builtin emit methods on [`AutoCfg`] call [`emit_possibility`] automatically.
///
/// [check-cfg-flags]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
pub fn emit(cfg: &str) {
println!("cargo:rustc-cfg={}", cfg);
}
@ -123,6 +131,25 @@ pub fn rerun_env(var: &str) {
println!("cargo:rerun-if-env-changed={}", var);
}
/// Indicates to rustc that a config flag should not generate an [`unexpected_cfgs` warning][check-cfg-flags]
///
/// This looks like `cargo:rustc-check-cfg=cfg(VAR)`
///
/// As of rust 1.80, the compiler does [automatic checking of cfgs at compile time][check-cfg-flags].
/// All custom configuration flags must be known to rustc, or they will generate a warning.
/// This is done automatically when calling the builtin emit methods on [`AutoCfg`],
/// but not when calling [`autocfg::emit`](crate::emit) directly.
///
/// Versions before rust 1.80 will simply ignore this directive.
///
/// This function indicates to the compiler that the config flag never has a value.
/// If this is not desired, see [the blog post][check-cfg].
///
/// [check-cfg-flags]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
pub fn emit_possibility(cfg: &str) {
println!("cargo:rustc-check-cfg=cfg({})", cfg);
}
/// Creates a new `AutoCfg` instance.
///
/// # Panics
@ -176,6 +203,7 @@ impl AutoCfg {
rustc_version: rustc_version,
target: target,
no_std: false,
uuid: new_uuid(),
};
// Sanity check with and without `std`.
@ -227,21 +255,27 @@ impl AutoCfg {
/// Sets a `cfg` value of the form `rustc_major_minor`, like `rustc_1_29`,
/// if the current `rustc` is at least that version.
pub fn emit_rustc_version(&self, major: usize, minor: usize) {
let cfg_flag = format!("rustc_{}_{}", major, minor);
emit_possibility(&cfg_flag);
if self.probe_rustc_version(major, minor) {
emit(&format!("rustc_{}_{}", major, minor));
emit(&cfg_flag);
}
}
fn probe_fmt<'a>(&self, source: Arguments<'a>) -> Result<(), Error> {
/// Returns a new (hopefully unique) crate name for probes.
fn new_crate_name(&self) -> String {
#[allow(deprecated)]
static ID: AtomicUsize = ATOMIC_USIZE_INIT;
let id = ID.fetch_add(1, Ordering::Relaxed);
format!("autocfg_{:016x}_{}", self.uuid, id)
}
fn probe_fmt<'a>(&self, source: Arguments<'a>) -> Result<(), Error> {
let mut command = self.rustc.command();
command
.arg("--crate-name")
.arg(format!("probe{}", id))
.arg(self.new_crate_name())
.arg("--crate-type=lib")
.arg("--out-dir")
.arg(&self.out_dir)
@ -291,7 +325,8 @@ impl AutoCfg {
/// ```
/// # extern crate autocfg;
/// # // Normally, cargo will set `OUT_DIR` for build scripts.
/// # std::env::set_var("OUT_DIR", "target");
/// # let exe = std::env::current_exe().unwrap();
/// # std::env::set_var("OUT_DIR", exe.parent().unwrap());
/// let ac = autocfg::new();
/// assert!(ac.probe_raw("#![no_builtins]").is_ok());
/// ```
@ -306,7 +341,8 @@ impl AutoCfg {
/// ```
/// # extern crate autocfg;
/// # // Normally, cargo will set `OUT_DIR` for build scripts.
/// # std::env::set_var("OUT_DIR", "target");
/// # let exe = std::env::current_exe().unwrap();
/// # std::env::set_var("OUT_DIR", exe.parent().unwrap());
/// let ac = autocfg::new();
/// let code = r#"
/// #![feature(slice_group_by)]
@ -336,8 +372,10 @@ impl AutoCfg {
/// Emits a config value `has_CRATE` if `probe_sysroot_crate` returns true.
pub fn emit_sysroot_crate(&self, name: &str) {
let cfg_flag = format!("has_{}", mangle(name));
emit_possibility(&cfg_flag);
if self.probe_sysroot_crate(name) {
emit(&format!("has_{}", mangle(name)));
emit(&cfg_flag);
}
}
@ -357,13 +395,12 @@ impl AutoCfg {
/// Any non-identifier characters in the `path` will be replaced with
/// `_` in the generated config value.
pub fn emit_has_path(&self, path: &str) {
if self.probe_path(path) {
emit(&format!("has_{}", mangle(path)));
}
self.emit_path_cfg(path, &format!("has_{}", mangle(path)));
}
/// Emits the given `cfg` value if `probe_path` returns true.
pub fn emit_path_cfg(&self, path: &str, cfg: &str) {
emit_possibility(cfg);
if self.probe_path(path) {
emit(cfg);
}
@ -385,13 +422,12 @@ impl AutoCfg {
/// Any non-identifier characters in the trait `name` will be replaced with
/// `_` in the generated config value.
pub fn emit_has_trait(&self, name: &str) {
if self.probe_trait(name) {
emit(&format!("has_{}", mangle(name)));
}
self.emit_trait_cfg(name, &format!("has_{}", mangle(name)));
}
/// Emits the given `cfg` value if `probe_trait` returns true.
pub fn emit_trait_cfg(&self, name: &str, cfg: &str) {
emit_possibility(cfg);
if self.probe_trait(name) {
emit(cfg);
}
@ -413,13 +449,12 @@ impl AutoCfg {
/// Any non-identifier characters in the type `name` will be replaced with
/// `_` in the generated config value.
pub fn emit_has_type(&self, name: &str) {
if self.probe_type(name) {
emit(&format!("has_{}", mangle(name)));
}
self.emit_type_cfg(name, &format!("has_{}", mangle(name)));
}
/// Emits the given `cfg` value if `probe_type` returns true.
pub fn emit_type_cfg(&self, name: &str, cfg: &str) {
emit_possibility(cfg);
if self.probe_type(name) {
emit(cfg);
}
@ -438,6 +473,7 @@ impl AutoCfg {
/// Emits the given `cfg` value if `probe_expression` returns true.
pub fn emit_expression_cfg(&self, expr: &str, cfg: &str) {
emit_possibility(cfg);
if self.probe_expression(expr) {
emit(cfg);
}
@ -456,6 +492,7 @@ impl AutoCfg {
/// Emits the given `cfg` value if `probe_constant` returns true.
pub fn emit_constant_cfg(&self, expr: &str, cfg: &str) {
emit_possibility(cfg);
if self.probe_constant(expr) {
emit(cfg);
}
@ -533,3 +570,21 @@ fn rustflags(target: &Option<OsString>, dir: &Path) -> Vec<String> {
Vec::new()
}
/// Generates a numeric ID to use in probe crate names.
///
/// This attempts to be random, within the constraints of Rust 1.0 and no dependencies.
fn new_uuid() -> u64 {
const FNV_OFFSET_BASIS: u64 = 0xcbf2_9ce4_8422_2325;
const FNV_PRIME: u64 = 0x100_0000_01b3;
// This set should have an actual random hasher.
let set: std::collections::HashSet<u64> = (0..256).collect();
// Feed the `HashSet`-shuffled order into FNV-1a.
let mut hash: u64 = FNV_OFFSET_BASIS;
for x in set {
hash = (hash ^ x).wrapping_mul(FNV_PRIME);
}
hash
}

View File

@ -1,36 +1,5 @@
use super::AutoCfg;
use std::env;
use std::path::Path;
impl AutoCfg {
fn core_std(&self, path: &str) -> String {
let krate = if self.no_std { "core" } else { "std" };
format!("{}::{}", krate, path)
}
fn assert_std(&self, probe_result: bool) {
assert_eq!(!self.no_std, probe_result);
}
fn assert_min(&self, major: usize, minor: usize, probe_result: bool) {
assert_eq!(self.probe_rustc_version(major, minor), probe_result);
}
fn for_test() -> Result<Self, super::error::Error> {
match env::var_os("TESTS_TARGET_DIR") {
Some(d) => Self::with_dir(d),
None => Self::with_dir("target"),
}
}
}
#[test]
fn autocfg_version() {
let ac = AutoCfg::for_test().unwrap();
println!("version: {:?}", ac.rustc_version);
assert!(ac.probe_rustc_version(1, 0));
}
#[test]
fn version_cmp() {
use super::version::Version;
@ -44,111 +13,6 @@ fn version_cmp() {
assert!(Version::new(2, 0, 0) > v123);
}
#[test]
fn probe_add() {
let ac = AutoCfg::for_test().unwrap();
let add = ac.core_std("ops::Add");
let add_rhs = add.clone() + "<i32>";
let add_rhs_output = add.clone() + "<i32, Output = i32>";
let dyn_add_rhs_output = "dyn ".to_string() + &*add_rhs_output;
assert!(ac.probe_path(&add));
assert!(ac.probe_trait(&add));
assert!(ac.probe_trait(&add_rhs));
assert!(ac.probe_trait(&add_rhs_output));
ac.assert_min(1, 27, ac.probe_type(&dyn_add_rhs_output));
}
#[test]
fn probe_as_ref() {
let ac = AutoCfg::for_test().unwrap();
let as_ref = ac.core_std("convert::AsRef");
let as_ref_str = as_ref.clone() + "<str>";
let dyn_as_ref_str = "dyn ".to_string() + &*as_ref_str;
assert!(ac.probe_path(&as_ref));
assert!(ac.probe_trait(&as_ref_str));
assert!(ac.probe_type(&as_ref_str));
ac.assert_min(1, 27, ac.probe_type(&dyn_as_ref_str));
}
#[test]
fn probe_i128() {
let ac = AutoCfg::for_test().unwrap();
let i128_path = ac.core_std("i128");
ac.assert_min(1, 26, ac.probe_path(&i128_path));
ac.assert_min(1, 26, ac.probe_type("i128"));
}
#[test]
fn probe_sum() {
let ac = AutoCfg::for_test().unwrap();
let sum = ac.core_std("iter::Sum");
let sum_i32 = sum.clone() + "<i32>";
let dyn_sum_i32 = "dyn ".to_string() + &*sum_i32;
ac.assert_min(1, 12, ac.probe_path(&sum));
ac.assert_min(1, 12, ac.probe_trait(&sum));
ac.assert_min(1, 12, ac.probe_trait(&sum_i32));
ac.assert_min(1, 12, ac.probe_type(&sum_i32));
ac.assert_min(1, 27, ac.probe_type(&dyn_sum_i32));
}
#[test]
fn probe_std() {
let ac = AutoCfg::for_test().unwrap();
ac.assert_std(ac.probe_sysroot_crate("std"));
}
#[test]
fn probe_alloc() {
let ac = AutoCfg::for_test().unwrap();
ac.assert_min(1, 36, ac.probe_sysroot_crate("alloc"));
}
#[test]
fn probe_bad_sysroot_crate() {
let ac = AutoCfg::for_test().unwrap();
assert!(!ac.probe_sysroot_crate("doesnt_exist"));
}
#[test]
fn probe_no_std() {
let ac = AutoCfg::for_test().unwrap();
assert!(ac.probe_type("i32"));
assert!(ac.probe_type("[i32]"));
ac.assert_std(ac.probe_type("Vec<i32>"));
}
#[test]
fn probe_expression() {
let ac = AutoCfg::for_test().unwrap();
assert!(ac.probe_expression(r#""test".trim_left()"#));
ac.assert_min(1, 30, ac.probe_expression(r#""test".trim_start()"#));
ac.assert_std(ac.probe_expression("[1, 2, 3].to_vec()"));
}
#[test]
fn probe_constant() {
let ac = AutoCfg::for_test().unwrap();
assert!(ac.probe_constant("1 + 2 + 3"));
ac.assert_min(1, 33, ac.probe_constant("{ let x = 1 + 2 + 3; x * x }"));
ac.assert_min(1, 39, ac.probe_constant(r#""test".len()"#));
}
#[test]
fn probe_raw() {
let ac = AutoCfg::for_test().unwrap();
let prefix = if ac.no_std { "#![no_std]\n" } else { "" };
let f = |s| format!("{}{}", prefix, s);
// This attribute **must** be used at the crate level.
assert!(ac.probe_raw(&f("#![no_builtins]")).is_ok());
assert!(ac.probe_raw(&f("#![deny(dead_code)] fn x() {}")).is_err());
assert!(ac.probe_raw(&f("#![allow(dead_code)] fn x() {}")).is_ok());
assert!(ac
.probe_raw(&f("#![deny(dead_code)] pub fn x() {}"))
.is_ok());
}
#[test]
fn dir_does_not_contain_target() {
assert!(!super::dir_contains_target(

View File

@ -2,6 +2,8 @@ extern crate autocfg;
use std::env;
mod support;
/// Tests that we can control the use of `#![no_std]`.
#[test]
fn no_std() {
@ -10,10 +12,9 @@ fn no_std() {
env::remove_var("TARGET");
// Use the same path as this test binary.
let dir = env::current_exe().unwrap().parent().unwrap().to_path_buf();
env::set_var("OUT_DIR", &format!("{}", dir.display()));
let out = support::out_dir();
let mut ac = autocfg::AutoCfg::new().unwrap();
let mut ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
assert!(!ac.no_std());
assert!(ac.probe_path("std::mem"));

View File

@ -2,18 +2,19 @@ extern crate autocfg;
use std::env;
mod support;
/// Tests that autocfg uses the RUSTFLAGS or CARGO_ENCODED_RUSTFLAGS
/// environment variables when running rustc.
#[test]
fn test_with_sysroot() {
// Use the same path as this test binary.
let dir = env::current_exe().unwrap().parent().unwrap().to_path_buf();
env::set_var("OUT_DIR", &format!("{}", dir.display()));
let dir = support::exe_dir();
let out = support::out_dir();
// If we have encoded rustflags, they take precedence, even if empty.
env::set_var("CARGO_ENCODED_RUSTFLAGS", "");
env::set_var("RUSTFLAGS", &format!("-L {}", dir.display()));
let ac = autocfg::AutoCfg::new().unwrap();
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
assert!(ac.probe_sysroot_crate("std"));
assert!(!ac.probe_sysroot_crate("autocfg"));
@ -22,12 +23,12 @@ fn test_with_sysroot() {
"CARGO_ENCODED_RUSTFLAGS",
&format!("-L\x1f{}", dir.display()),
);
let ac = autocfg::AutoCfg::new().unwrap();
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
assert!(ac.probe_sysroot_crate("autocfg"));
// Try the old-style RUSTFLAGS, ensuring HOST != TARGET.
env::remove_var("CARGO_ENCODED_RUSTFLAGS");
env::set_var("HOST", "lol");
let ac = autocfg::AutoCfg::new().unwrap();
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
assert!(ac.probe_sysroot_crate("autocfg"));
}

View File

@ -0,0 +1,21 @@
use std::borrow::Cow;
use std::env;
use std::path::{Path, PathBuf};
/// The directory containing this test binary.
pub fn exe_dir() -> PathBuf {
let exe = env::current_exe().unwrap();
exe.parent().unwrap().to_path_buf()
}
/// The directory to use for test probes.
pub fn out_dir() -> Cow<'static, Path> {
if let Some(tmpdir) = option_env!("CARGO_TARGET_TMPDIR") {
Cow::Borrowed(tmpdir.as_ref())
} else if let Some(tmpdir) = env::var_os("TESTS_TARGET_DIR") {
Cow::Owned(tmpdir.into())
} else {
// Use the same path as this test binary.
Cow::Owned(exe_dir())
}
}

138
pve-rs/vendor/autocfg/tests/tests.rs vendored Normal file
View File

@ -0,0 +1,138 @@
extern crate autocfg;
use autocfg::AutoCfg;
mod support;
fn core_std(ac: &AutoCfg, path: &str) -> String {
let krate = if ac.no_std() { "core" } else { "std" };
format!("{}::{}", krate, path)
}
fn assert_std(ac: &AutoCfg, probe_result: bool) {
assert_eq!(!ac.no_std(), probe_result);
}
fn assert_min(ac: &AutoCfg, major: usize, minor: usize, probe_result: bool) {
assert_eq!(ac.probe_rustc_version(major, minor), probe_result);
}
fn autocfg_for_test() -> AutoCfg {
AutoCfg::with_dir(support::out_dir().as_ref()).unwrap()
}
#[test]
fn autocfg_version() {
let ac = autocfg_for_test();
assert!(ac.probe_rustc_version(1, 0));
}
#[test]
fn probe_add() {
let ac = autocfg_for_test();
let add = core_std(&ac, "ops::Add");
let add_rhs = add.clone() + "<i32>";
let add_rhs_output = add.clone() + "<i32, Output = i32>";
let dyn_add_rhs_output = "dyn ".to_string() + &*add_rhs_output;
assert!(ac.probe_path(&add));
assert!(ac.probe_trait(&add));
assert!(ac.probe_trait(&add_rhs));
assert!(ac.probe_trait(&add_rhs_output));
assert_min(&ac, 1, 27, ac.probe_type(&dyn_add_rhs_output));
}
#[test]
fn probe_as_ref() {
let ac = autocfg_for_test();
let as_ref = core_std(&ac, "convert::AsRef");
let as_ref_str = as_ref.clone() + "<str>";
let dyn_as_ref_str = "dyn ".to_string() + &*as_ref_str;
assert!(ac.probe_path(&as_ref));
assert!(ac.probe_trait(&as_ref_str));
assert!(ac.probe_type(&as_ref_str));
assert_min(&ac, 1, 27, ac.probe_type(&dyn_as_ref_str));
}
#[test]
fn probe_i128() {
let ac = autocfg_for_test();
let i128_path = core_std(&ac, "i128");
assert_min(&ac, 1, 26, ac.probe_path(&i128_path));
assert_min(&ac, 1, 26, ac.probe_type("i128"));
}
#[test]
fn probe_sum() {
let ac = autocfg_for_test();
let sum = core_std(&ac, "iter::Sum");
let sum_i32 = sum.clone() + "<i32>";
let dyn_sum_i32 = "dyn ".to_string() + &*sum_i32;
assert_min(&ac, 1, 12, ac.probe_path(&sum));
assert_min(&ac, 1, 12, ac.probe_trait(&sum));
assert_min(&ac, 1, 12, ac.probe_trait(&sum_i32));
assert_min(&ac, 1, 12, ac.probe_type(&sum_i32));
assert_min(&ac, 1, 27, ac.probe_type(&dyn_sum_i32));
}
#[test]
fn probe_std() {
let ac = autocfg_for_test();
assert_std(&ac, ac.probe_sysroot_crate("std"));
}
#[test]
fn probe_alloc() {
let ac = autocfg_for_test();
assert_min(&ac, 1, 36, ac.probe_sysroot_crate("alloc"));
}
#[test]
fn probe_bad_sysroot_crate() {
let ac = autocfg_for_test();
assert!(!ac.probe_sysroot_crate("doesnt_exist"));
}
#[test]
fn probe_no_std() {
let ac = autocfg_for_test();
assert!(ac.probe_type("i32"));
assert!(ac.probe_type("[i32]"));
assert_std(&ac, ac.probe_type("Vec<i32>"));
}
#[test]
fn probe_expression() {
let ac = autocfg_for_test();
assert!(ac.probe_expression(r#""test".trim_left()"#));
assert_min(&ac, 1, 30, ac.probe_expression(r#""test".trim_start()"#));
assert_std(&ac, ac.probe_expression("[1, 2, 3].to_vec()"));
}
#[test]
fn probe_constant() {
let ac = autocfg_for_test();
assert!(ac.probe_constant("1 + 2 + 3"));
assert_min(
&ac,
1,
33,
ac.probe_constant("{ let x = 1 + 2 + 3; x * x }"),
);
assert_min(&ac, 1, 39, ac.probe_constant(r#""test".len()"#));
}
#[test]
fn probe_raw() {
let ac = autocfg_for_test();
let prefix = if ac.no_std() { "#![no_std]\n" } else { "" };
let f = |s| format!("{}{}", prefix, s);
// This attribute **must** be used at the crate level.
assert!(ac.probe_raw(&f("#![no_builtins]")).is_ok());
assert!(ac.probe_raw(&f("#![deny(dead_code)] fn x() {}")).is_err());
assert!(ac.probe_raw(&f("#![allow(dead_code)] fn x() {}")).is_ok());
assert!(ac
.probe_raw(&f("#![deny(dead_code)] pub fn x() {}"))
.is_ok());
}

View File

@ -2,6 +2,8 @@ extern crate autocfg;
use std::env;
mod support;
/// Tests that autocfg uses the RUSTC_WRAPPER and/or RUSTC_WORKSPACE_WRAPPER
/// environment variables when running rustc.
#[test]
@ -15,9 +17,7 @@ fn test_wrappers() {
}
}
// Use the same path as this test binary.
let dir = env::current_exe().unwrap().parent().unwrap().to_path_buf();
env::set_var("OUT_DIR", &format!("{}", dir.display()));
let out = support::out_dir();
// This is used as a heuristic to detect rust-lang/cargo#9601.
env::set_var("CARGO_ENCODED_RUSTFLAGS", "");
@ -30,7 +30,7 @@ fn test_wrappers() {
set("RUSTC_WRAPPER", rustc);
set("RUSTC_WORKSPACE_WRAPPER", workspace);
let ac = autocfg::AutoCfg::new().unwrap();
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
if rustc == Some(false) || workspace == Some(false) {
// Everything should fail with bad wrappers.
assert!(!ac.probe_type("usize"));
@ -48,7 +48,7 @@ fn test_wrappers() {
// by using something that doesn't pass through at all.
env::set_var("RUSTC_WRAPPER", "./tests/wrap_ignored");
env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false");
let ac = autocfg::AutoCfg::new().unwrap();
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
assert!(ac.probe_type("mesize")); // anything goes!
// Make sure we also got the version from that wrapper.

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"dab5bedf72d2caebd61a9feef156f98eb31677e14f95bc99888e21b20ce579bc","Cargo.toml":"5d32feb935f873448d6d999c8463b3a6263284cf198986f107a0adef72bfca0a","LICENSE":"45f522cacecb1023856e46df79ca625dfc550c94910078bd8aec6e02880b3d42","README.md":"c1b2b54999d4829f9f64fb41cbdf05a72d565be0dd078a8633d34631147498a1","SECURITY.md":"a3335079977c2f13bad59e323fdc1056bdae5adfe55f18d15ac2c930d741828c","benches/buf.rs":"72e6b6120b52d568da068f17c66a793d65602e400c595778581b63092e41d8dc","benches/bytes.rs":"7084e564f8568f52c9fdb76a06e58701aa7f0c776209d29a0f60c38a19748203","benches/bytes_mut.rs":"1326fe6224b26826228e02b4133151e756f38152c2d9cfe66adf83af76c3ec98","ci/miri.sh":"1ee54575b55a0e495e52ca1a934beed674bc8f375f03c4cfc3e81d221ec4fe98","ci/test-stable.sh":"b21b9265d8d65c1f3d50c64e40d41c66a870d897325119d1f78d601727bbb562","ci/tsan.sh":"466b86b19225dd26c756cf2252cb1973f87a145642c99364b462ed7ceb55c7dd","clippy.toml":"8522f448dfa3b33ac334ce47d233ebb6b58e8ae115e45107a64fc1b4510fe560","src/buf/buf_impl.rs":"8616fdf6f6e0f3d9b3870fbf85a78f7907006656d05032bbd2966c73f0a13b1c","src/buf/buf_mut.rs":"133a0a898df73a0e545b28e8875d3ae457df0d164c1345b5aceb4ecb67aee371","src/buf/chain.rs":"c933958f04c4ecd39a18db34c04ea51cc601180d43ee6924fed2fb44b96fe8c7","src/buf/iter.rs":"d4dca5b7f9b1cb441f22ac1862e28b10086721879163a810955aefb5cd7f3e58","src/buf/limit.rs":"e005ba140b70f68654877c96b981a220477e415ff5c92438c1b0cb9bc866d872","src/buf/mod.rs":"3f60295316d44b510b942abb31a0d975ae488bd4b52c87f5252d73f88f82715a","src/buf/reader.rs":"cda8bc221a1de06c7395d5c6e80f8a5924198eafbc2decc0909082ce8781d789","src/buf/take.rs":"ce7f4644986797dae3e6bdaa8f65c8ff0a9b0d4b80f749c735ed4777b96dcb2c","src/buf/uninit_slice.rs":"ce0029ebe6fd76617a457676e581c756d6026bb02b9c24718286668b962c23a1","src/buf/vec_deque.rs":"8d552c26ac6ce28a471f74c388e4749432e86b1d8f5a9759b9fc32a2549d395f","src/buf/writer.rs":"7589e9ea054d01d133b230130113a2de20b4f221a5e5c754809b583052601ea2","src/bytes.rs":"b1367f27701a5b8d75a5c0ece1d91f08d284abc62f7b80572d3b3b70c0df2ee2","src/bytes_mut.rs":"378194077a8dc2d7ad4b97c73fd4494ba99ec893921987d93eaf0f2bc0df5330","src/fmt/debug.rs":"97b23cfa1d2701fa187005421302eeb260e635cd4f9a9e02b044ff89fcc8b8ad","src/fmt/hex.rs":"13755ec6f1b79923e1f1a05c51b179a38c03c40bb8ed2db0210e8901812e61e7","src/fmt/mod.rs":"176da4e359da99b8e5cf16e480cb7b978f574876827f1b9bb9c08da4d74ac0f5","src/lib.rs":"226bb979808d8dcc8ff1643029b74a672b1779d6b7153a9e180777b77906191f","src/loom.rs":"eb3f577d8cce39a84155c241c4dc308f024631f02085833f7fe9f0ea817bcea9","src/serde.rs":"3ecd7e828cd4c2b7db93c807cb1548fad209e674df493edf7cda69a7b04d405d","tests/test_buf.rs":"a7be350258f0433cfb9ba9e4583d6bb356c964ac34a781f586fd78fbd2c4bb02","tests/test_buf_mut.rs":"3e6a12a4f546dbf1a0e1346ab2b7ff707fdaf01a06b21714ca64b141484a76c3","tests/test_bytes.rs":"eb3b0cf10a6ada6e2ec71c3546a5477c1b1c1e22044a182391df0f57cda6fad4","tests/test_bytes_odd_alloc.rs":"ad5df84a35038359413199762c65017989d905e6e965a7b863beaa9962a7e1e8","tests/test_bytes_vec_alloc.rs":"dd7e3c3a71abcfdcad7e3b2f52a6bd106ad6ea0d4bc634372e81dae097233cf0","tests/test_chain.rs":"e9f094539bb42b3135f50033c44122a6b44cf0f953e51e8b488f43243f1e7f10","tests/test_debug.rs":"13299107172809e8cbbd823964ac9450cd0d6b6de79f2e6a2e0f44b9225a0593","tests/test_iter.rs":"665e1837c1294d7695ffa352a666ce8673fb46fa603164556524e87d5517a6cb","tests/test_reader.rs":"bf83669d4e0960dad6aa47b46a9a454814fab626eb83572aba914c3d71618f43","tests/test_serde.rs":"2691f891796ba259de0ecf926de05c514f4912cc5fcd3e6a1591efbcd23ed4d0","tests/test_take.rs":"db01bf6855097f318336e90d12c0725a92cee426d330e477a6bd1d32dac34a27"},"package":"8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"}
{"files":{"CHANGELOG.md":"c5fce829116f7930c93ac10392eb1f58ab9b84322b33318b6ec864d0eeb880f6","Cargo.toml":"af0137d8b9f6720d284b383ef252a5d9d48b644939990310324a69ccadf797d8","LICENSE":"45f522cacecb1023856e46df79ca625dfc550c94910078bd8aec6e02880b3d42","README.md":"c1b2b54999d4829f9f64fb41cbdf05a72d565be0dd078a8633d34631147498a1","SECURITY.md":"a3335079977c2f13bad59e323fdc1056bdae5adfe55f18d15ac2c930d741828c","benches/buf.rs":"72e6b6120b52d568da068f17c66a793d65602e400c595778581b63092e41d8dc","benches/bytes.rs":"7084e564f8568f52c9fdb76a06e58701aa7f0c776209d29a0f60c38a19748203","benches/bytes_mut.rs":"1326fe6224b26826228e02b4133151e756f38152c2d9cfe66adf83af76c3ec98","ci/miri.sh":"13b2db3432fcdf9e2db6ef9e6ec20d063c0ce63542981a6f77e09306e1e2198e","ci/test-stable.sh":"b21b9265d8d65c1f3d50c64e40d41c66a870d897325119d1f78d601727bbb562","ci/tsan.sh":"466b86b19225dd26c756cf2252cb1973f87a145642c99364b462ed7ceb55c7dd","clippy.toml":"8522f448dfa3b33ac334ce47d233ebb6b58e8ae115e45107a64fc1b4510fe560","src/buf/buf_impl.rs":"73092a4cea9d0657e7e54875ee8018e31ad9306524984a67529f9a6d5e790f4a","src/buf/buf_mut.rs":"20bfb57681d1f0cb7c7610e12b9a06233235ba6f20100f7eb2f23a5f4cf0de90","src/buf/chain.rs":"c933958f04c4ecd39a18db34c04ea51cc601180d43ee6924fed2fb44b96fe8c7","src/buf/iter.rs":"d4dca5b7f9b1cb441f22ac1862e28b10086721879163a810955aefb5cd7f3e58","src/buf/limit.rs":"e005ba140b70f68654877c96b981a220477e415ff5c92438c1b0cb9bc866d872","src/buf/mod.rs":"3f60295316d44b510b942abb31a0d975ae488bd4b52c87f5252d73f88f82715a","src/buf/reader.rs":"cda8bc221a1de06c7395d5c6e80f8a5924198eafbc2decc0909082ce8781d789","src/buf/take.rs":"ce7f4644986797dae3e6bdaa8f65c8ff0a9b0d4b80f749c735ed4777b96dcb2c","src/buf/uninit_slice.rs":"52629b93ff7a08db45fc69395580b34fa3609fd9309ea01f86e58488b02b08a3","src/buf/vec_deque.rs":"8d552c26ac6ce28a471f74c388e4749432e86b1d8f5a9759b9fc32a2549d395f","src/buf/writer.rs":"7589e9ea054d01d133b230130113a2de20b4f221a5e5c754809b583052601ea2","src/bytes.rs":"c4cf6e8f6770c4bfe62181460aaab5f36b9392a92cfbb7fd4a5a5e42ac6dc3db","src/bytes_mut.rs":"76e6a2e68ffa433b694671f673aa16dc2d4a414e73d1037fd8f3d801251901ce","src/fmt/debug.rs":"97b23cfa1d2701fa187005421302eeb260e635cd4f9a9e02b044ff89fcc8b8ad","src/fmt/hex.rs":"13755ec6f1b79923e1f1a05c51b179a38c03c40bb8ed2db0210e8901812e61e7","src/fmt/mod.rs":"176da4e359da99b8e5cf16e480cb7b978f574876827f1b9bb9c08da4d74ac0f5","src/lib.rs":"226bb979808d8dcc8ff1643029b74a672b1779d6b7153a9e180777b77906191f","src/loom.rs":"eb3f577d8cce39a84155c241c4dc308f024631f02085833f7fe9f0ea817bcea9","src/serde.rs":"3ecd7e828cd4c2b7db93c807cb1548fad209e674df493edf7cda69a7b04d405d","tests/test_buf.rs":"827a965d3635eed132317248172add380679a3aaa0a26752bb77ea6ff8a458d5","tests/test_buf_mut.rs":"3e6a12a4f546dbf1a0e1346ab2b7ff707fdaf01a06b21714ca64b141484a76c3","tests/test_bytes.rs":"38885e993df0f22586d38e43a24bcb90799e7b4f03aefc2330fd06a54ab6fb9a","tests/test_bytes_odd_alloc.rs":"ad5df84a35038359413199762c65017989d905e6e965a7b863beaa9962a7e1e8","tests/test_bytes_vec_alloc.rs":"dd7e3c3a71abcfdcad7e3b2f52a6bd106ad6ea0d4bc634372e81dae097233cf0","tests/test_chain.rs":"e9f094539bb42b3135f50033c44122a6b44cf0f953e51e8b488f43243f1e7f10","tests/test_debug.rs":"13299107172809e8cbbd823964ac9450cd0d6b6de79f2e6a2e0f44b9225a0593","tests/test_iter.rs":"665e1837c1294d7695ffa352a666ce8673fb46fa603164556524e87d5517a6cb","tests/test_reader.rs":"bf83669d4e0960dad6aa47b46a9a454814fab626eb83572aba914c3d71618f43","tests/test_serde.rs":"2691f891796ba259de0ecf926de05c514f4912cc5fcd3e6a1591efbcd23ed4d0","tests/test_take.rs":"db01bf6855097f318336e90d12c0725a92cee426d330e477a6bd1d32dac34a27"},"package":"9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"}

View File

@ -1,3 +1,21 @@
# 1.8.0 (October 21, 2024)
- Guarantee address in `split_off`/`split_to` for empty slices (#740)
# 1.7.2 (September 17, 2024)
### Fixed
- Fix default impl of `Buf::{get_int, get_int_le}` (#732)
### Documented
- Fix double spaces in comments and doc comments (#731)
### Internal changes
- Ensure BytesMut::advance reduces capacity (#728)
# 1.7.1 (August 1, 2024)
This release reverts the following change due to a regression:

View File

@ -13,11 +13,16 @@
edition = "2018"
rust-version = "1.39"
name = "bytes"
version = "1.7.1"
version = "1.8.0"
authors = [
"Carl Lerche <me@carllerche.com>",
"Sean McArthur <sean@seanmonstar.com>",
]
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Types and traits for working with bytes"
readme = "README.md"
keywords = [
@ -38,6 +43,66 @@ rustdoc-args = [
"docsrs",
]
[lib]
name = "bytes"
path = "src/lib.rs"
[[test]]
name = "test_buf"
path = "tests/test_buf.rs"
[[test]]
name = "test_buf_mut"
path = "tests/test_buf_mut.rs"
[[test]]
name = "test_bytes"
path = "tests/test_bytes.rs"
[[test]]
name = "test_bytes_odd_alloc"
path = "tests/test_bytes_odd_alloc.rs"
[[test]]
name = "test_bytes_vec_alloc"
path = "tests/test_bytes_vec_alloc.rs"
[[test]]
name = "test_chain"
path = "tests/test_chain.rs"
[[test]]
name = "test_debug"
path = "tests/test_debug.rs"
[[test]]
name = "test_iter"
path = "tests/test_iter.rs"
[[test]]
name = "test_reader"
path = "tests/test_reader.rs"
[[test]]
name = "test_serde"
path = "tests/test_serde.rs"
[[test]]
name = "test_take"
path = "tests/test_take.rs"
[[bench]]
name = "buf"
path = "benches/buf.rs"
[[bench]]
name = "bytes"
path = "benches/bytes.rs"
[[bench]]
name = "bytes_mut"
path = "benches/bytes_mut.rs"
[dependencies.serde]
version = "1.0.60"
features = ["alloc"]

View File

@ -1,8 +1,7 @@
#!/bin/bash
set -e
rustup toolchain install nightly --component miri
rustup override set nightly
rustup component add miri
cargo miri setup
export MIRIFLAGS="-Zmiri-strict-provenance"

View File

@ -66,6 +66,12 @@ macro_rules! buf_get_impl {
}};
}
// https://en.wikipedia.org/wiki/Sign_extension
fn sign_extend(val: u64, nbytes: usize) -> i64 {
let shift = (8 - nbytes) * 8;
(val << shift) as i64 >> shift
}
/// Read bytes from a buffer.
///
/// A buffer stores bytes in memory such that read operations are infallible.
@ -923,7 +929,7 @@ pub trait Buf {
/// This function panics if there is not enough remaining data in `self`, or
/// if `nbytes` is greater than 8.
fn get_int(&mut self, nbytes: usize) -> i64 {
buf_get_impl!(be => self, i64, nbytes);
sign_extend(self.get_uint(nbytes), nbytes)
}
/// Gets a signed n-byte integer from `self` in little-endian byte order.
@ -944,7 +950,7 @@ pub trait Buf {
/// This function panics if there is not enough remaining data in `self`, or
/// if `nbytes` is greater than 8.
fn get_int_le(&mut self, nbytes: usize) -> i64 {
buf_get_impl!(le => self, i64, nbytes);
sign_extend(self.get_uint_le(nbytes), nbytes)
}
/// Gets a signed n-byte integer from `self` in native-endian byte order.

View File

@ -1107,7 +1107,7 @@ pub unsafe trait BufMut {
}
}
/// Writes an IEEE754 single-precision (4 bytes) floating point number to
/// Writes an IEEE754 single-precision (4 bytes) floating point number to
/// `self` in big-endian byte order.
///
/// The current position is advanced by 4.
@ -1131,7 +1131,7 @@ pub unsafe trait BufMut {
self.put_u32(n.to_bits());
}
/// Writes an IEEE754 single-precision (4 bytes) floating point number to
/// Writes an IEEE754 single-precision (4 bytes) floating point number to
/// `self` in little-endian byte order.
///
/// The current position is advanced by 4.
@ -1183,7 +1183,7 @@ pub unsafe trait BufMut {
self.put_u32_ne(n.to_bits());
}
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// `self` in big-endian byte order.
///
/// The current position is advanced by 8.
@ -1207,7 +1207,7 @@ pub unsafe trait BufMut {
self.put_u64(n.to_bits());
}
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// `self` in little-endian byte order.
///
/// The current position is advanced by 8.
@ -1231,7 +1231,7 @@ pub unsafe trait BufMut {
self.put_u64_le(n.to_bits());
}
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// Writes an IEEE754 double-precision (8 bytes) floating point number to
/// `self` in native-endian byte order.
///
/// The current position is advanced by 8.

View File

@ -110,7 +110,7 @@ impl UninitSlice {
unsafe { self[index..].as_mut_ptr().write(byte) }
}
/// Copies bytes from `src` into `self`.
/// Copies bytes from `src` into `self`.
///
/// The length of `src` must be the same as `self`.
///

View File

@ -142,6 +142,7 @@ impl Bytes {
Bytes::from_static(EMPTY)
}
/// Creates a new empty `Bytes`.
#[cfg(all(loom, test))]
pub fn new() -> Self {
const EMPTY: &[u8] = &[];
@ -172,6 +173,7 @@ impl Bytes {
}
}
/// Creates a new `Bytes` from a static slice.
#[cfg(all(loom, test))]
pub fn from_static(bytes: &'static [u8]) -> Self {
Bytes {
@ -182,6 +184,22 @@ impl Bytes {
}
}
/// Creates a new `Bytes` with length zero and the given pointer as the address.
fn new_empty_with_ptr(ptr: *const u8) -> Self {
debug_assert!(!ptr.is_null());
// Detach this pointer's provenance from whichever allocation it came from, and reattach it
// to the provenance of the fake ZST [u8;0] at the same address.
let ptr = without_provenance(ptr as usize);
Bytes {
ptr,
len: 0,
data: AtomicPtr::new(ptr::null_mut()),
vtable: &STATIC_VTABLE,
}
}
/// Returns the number of bytes contained in this `Bytes`.
///
/// # Examples
@ -364,7 +382,9 @@ impl Bytes {
/// Splits the bytes into two at the given index.
///
/// Afterwards `self` contains elements `[0, at)`, and the returned `Bytes`
/// contains elements `[at, len)`.
/// contains elements `[at, len)`. It's guaranteed that the memory does not
/// move, that is, the address of `self` does not change, and the address of
/// the returned slice is `at` bytes after that.
///
/// This is an `O(1)` operation that just increases the reference count and
/// sets a few indices.
@ -387,11 +407,11 @@ impl Bytes {
#[must_use = "consider Bytes::truncate if you don't need the other half"]
pub fn split_off(&mut self, at: usize) -> Self {
if at == self.len() {
return Bytes::new();
return Bytes::new_empty_with_ptr(self.ptr.wrapping_add(at));
}
if at == 0 {
return mem::replace(self, Bytes::new());
return mem::replace(self, Bytes::new_empty_with_ptr(self.ptr));
}
assert!(
@ -436,11 +456,12 @@ impl Bytes {
#[must_use = "consider Bytes::advance if you don't need the other half"]
pub fn split_to(&mut self, at: usize) -> Self {
if at == self.len() {
return mem::replace(self, Bytes::new());
let end_ptr = self.ptr.wrapping_add(at);
return mem::replace(self, Bytes::new_empty_with_ptr(end_ptr));
}
if at == 0 {
return Bytes::new();
return Bytes::new_empty_with_ptr(self.ptr);
}
assert!(
@ -1301,7 +1322,7 @@ unsafe fn shallow_clone_vec(
offset: *const u8,
len: usize,
) -> Bytes {
// If the buffer is still tracked in a `Vec<u8>`. It is time to
// If the buffer is still tracked in a `Vec<u8>`. It is time to
// promote the vec to an `Arc`. This could potentially be called
// concurrently, so some care must be taken.
@ -1424,6 +1445,10 @@ where
new_addr as *mut u8
}
fn without_provenance(ptr: usize) -> *const u8 {
core::ptr::null::<u8>().wrapping_add(ptr)
}
// compile-fails
/// ```compile_fail

View File

@ -291,7 +291,9 @@ impl BytesMut {
/// Splits the bytes into two at the given index.
///
/// Afterwards `self` contains elements `[0, at)`, and the returned
/// `BytesMut` contains elements `[at, capacity)`.
/// `BytesMut` contains elements `[at, capacity)`. It's guaranteed that the
/// memory does not move, that is, the address of `self` does not change,
/// and the address of the returned slice is `at` bytes after that.
///
/// This is an `O(1)` operation that just increases the reference count
/// and sets a few indices.

View File

@ -36,6 +36,19 @@ fn test_get_u16() {
assert_eq!(0x5421, buf.get_u16_le());
}
#[test]
fn test_get_int() {
let mut buf = &b"\xd6zomg"[..];
assert_eq!(-42, buf.get_int(1));
let mut buf = &b"\xd6zomg"[..];
assert_eq!(-42, buf.get_int_le(1));
let mut buf = &b"\xfe\x1d\xc0zomg"[..];
assert_eq!(0xffffffffffc01dfeu64 as i64, buf.get_int_le(3));
let mut buf = &b"\xfe\x1d\xc0zomg"[..];
assert_eq!(0xfffffffffffe1dc0u64 as i64, buf.get_int(3));
}
#[test]
#[should_panic]
fn test_get_u16_buffer_underflow() {

View File

@ -676,6 +676,43 @@ fn advance_bytes_mut() {
assert_eq!(a, b"d zomg wat wat"[..]);
}
// Ensures BytesMut::advance reduces always capacity
//
// See https://github.com/tokio-rs/bytes/issues/725
#[test]
fn advance_bytes_mut_remaining_capacity() {
// reduce the search space under miri
let max_capacity = if cfg!(miri) { 16 } else { 256 };
for capacity in 0..=max_capacity {
for len in 0..=capacity {
for advance in 0..=len {
eprintln!("testing capacity={capacity}, len={len}, advance={advance}");
let mut buf = BytesMut::with_capacity(capacity);
buf.resize(len, 42);
assert_eq!(buf.len(), len, "resize should write `len` bytes");
assert_eq!(
buf.remaining(),
len,
"Buf::remaining() should equal BytesMut::len"
);
buf.advance(advance);
assert_eq!(
buf.remaining(),
len - advance,
"Buf::advance should reduce the remaining len"
);
assert_eq!(
buf.capacity(),
capacity - advance,
"Buf::advance should reduce the remaining capacity"
);
}
}
}
}
#[test]
#[should_panic]
fn advance_past_len() {
@ -1362,3 +1399,83 @@ fn try_reclaim_arc() {
buf.advance(2);
assert_eq!(true, buf.try_reclaim(6));
}
#[test]
fn split_off_empty_addr() {
let mut buf = Bytes::from(vec![0; 1024]);
let ptr_start = buf.as_ptr();
let ptr_end = ptr_start.wrapping_add(1024);
let empty_end = buf.split_off(1024);
assert_eq!(empty_end.len(), 0);
assert_eq!(empty_end.as_ptr(), ptr_end);
let _ = buf.split_off(0);
assert_eq!(buf.len(), 0);
assert_eq!(buf.as_ptr(), ptr_start);
// Is miri happy about the provenance?
let _ = &empty_end[..];
let _ = &buf[..];
}
#[test]
fn split_to_empty_addr() {
let mut buf = Bytes::from(vec![0; 1024]);
let ptr_start = buf.as_ptr();
let ptr_end = ptr_start.wrapping_add(1024);
let empty_start = buf.split_to(0);
assert_eq!(empty_start.len(), 0);
assert_eq!(empty_start.as_ptr(), ptr_start);
let _ = buf.split_to(1024);
assert_eq!(buf.len(), 0);
assert_eq!(buf.as_ptr(), ptr_end);
// Is miri happy about the provenance?
let _ = &empty_start[..];
let _ = &buf[..];
}
#[test]
fn split_off_empty_addr_mut() {
let mut buf = BytesMut::from([0; 1024].as_slice());
let ptr_start = buf.as_ptr();
let ptr_end = ptr_start.wrapping_add(1024);
let empty_end = buf.split_off(1024);
assert_eq!(empty_end.len(), 0);
assert_eq!(empty_end.as_ptr(), ptr_end);
let _ = buf.split_off(0);
assert_eq!(buf.len(), 0);
assert_eq!(buf.as_ptr(), ptr_start);
// Is miri happy about the provenance?
let _ = &empty_end[..];
let _ = &buf[..];
}
#[test]
fn split_to_empty_addr_mut() {
let mut buf = BytesMut::from([0; 1024].as_slice());
let ptr_start = buf.as_ptr();
let ptr_end = ptr_start.wrapping_add(1024);
let empty_start = buf.split_to(0);
assert_eq!(empty_start.len(), 0);
assert_eq!(empty_start.as_ptr(), ptr_start);
let _ = buf.split_to(1024);
assert_eq!(buf.len(), 0);
assert_eq!(buf.as_ptr(), ptr_end);
// Is miri happy about the provenance?
let _ = &empty_start[..];
let _ = &buf[..];
}

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"8fbb094907ab39e364881b157a48c28035db3aeb5a12703bd2b66db3d477d06f","Cargo.toml":"ebd3771889005853b63973024cf9c220d37c74218ff3bbfab1591ce3393e0e2d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"f1ddbede208a5b78333a25dac0a7598e678e9b601a7d99a791069bddaf180dfe","clippy.toml":"aa7850db4350883c8f373bd0d6b4d19bf3b75f13c1c238e24368c109cb52fb1d","src/command_helpers.rs":"0b54800fe5c89cd102a5f872fe1a843c1a58e026bc4bbc611e207914b8c84dda","src/detect_compiler_family.c":"97ca4b021495611e828becea6187add37414186a16dfedd26c2947cbce6e8b2f","src/lib.rs":"a0e3ce90d8d8655b56f14aa185381992cb504912991b8ca8c44f1cd4d059b23b","src/parallel/async_executor.rs":"4ce24435fff6b6555b43fee042c16bd65d4150d0346567f246b9190d85b45983","src/parallel/job_token.rs":"f4ed0a03d89a42bfd5527133d12b267af519b745f3f2b997ed293df15a2641b8","src/parallel/mod.rs":"55fb4c2d15e66677b2ed5ffa6d65ea161bcf1a1e1dc7910ee3bde06f2f67ab14","src/parallel/once_lock.rs":"d13e4cb82d6bca3297ca8671d83a40dd5affd7ac89191d733dd451867181bb02","src/parallel/stderr.rs":"74384d41198740a6fce0877f144262db09fb091225fa8fbfa771314bb11487c6","src/target_info.rs":"f939a570c99d897fdd37cd491a4ee0657e2c7480ec71acbd9cbee48732d4bfbc","src/tempfile.rs":"ebafb5b0e5d08b0706916ed911d4245240e60c3e2d0c9a1630c520842988a2b3","src/tool.rs":"2e6550062e021f2b394388172bbb01e86fe6a94d2395bcb3c85a9e86690da1a9","src/utilities.rs":"a13bb0a351fcef72823485b1b5dc4f514c533fa4feac95deb66ed9e5fbfe7b53","src/windows/com.rs":"a2800ddb81215fff2bf618336f5c4ff8e8bdb746dd18b795873c7304b3f2a5e3","src/windows/find_tools.rs":"dd6b2450909cd8334a2aa2ce856bcc72a9654d92422267d6345d5fabfcbf57c5","src/windows/mod.rs":"34cfa201cfbcac7ccaa3ea5295d3e4200439af3cc5c6433baf81502596040a89","src/windows/registry.rs":"c521b72c825e8095843e73482ffa810ed066ad8bb9f86e6db0c5c143c171aba1","src/windows/setup_config.rs":"754439cbab492afd44c9755abcbec1a41c9b2c358131cee2df13c0e996dbbec8","src/windows/vs_instances.rs":"946527cf8fd32c3472f6a2884dcdec290763101097334c7478f9c24c3950db6b","src/windows/winapi.rs":"250d51c1826d1a2329e9889dd9f058cfce253dbf2a678b076147c6cdb5db046c","src/windows/windows_sys.rs":"e2714c8307bfa083b9745eb0e46cadd7f98d7b88abf45a7637172019324e34b8","src/windows/windows_targets.rs":"5b4648ebc22b028caca9f4b4bf8881fe2d094b7bec217264ba2e6e2c49d1ccee"},"package":"b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476"}
{"files":{"CHANGELOG.md":"4c2d7e4367b23e9232a1a08f93c6cd739d9c54394d8f6a58b1674101e7fd70ed","Cargo.toml":"8531bf0801327dae7536893352efc21e1864af5cbb854547c3850a4905a88f36","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"f1ddbede208a5b78333a25dac0a7598e678e9b601a7d99a791069bddaf180dfe","clippy.toml":"aa7850db4350883c8f373bd0d6b4d19bf3b75f13c1c238e24368c109cb52fb1d","src/command_helpers.rs":"63742844930bd693e029fa93b734d21c64453c1d9c58f792b3363b28a4c0e86d","src/detect_compiler_family.c":"97ca4b021495611e828becea6187add37414186a16dfedd26c2947cbce6e8b2f","src/lib.rs":"68e35fadafc880de1f59c327f5bc1681837c1009089dcdf6815798e76bbcc39f","src/parallel/async_executor.rs":"4ce24435fff6b6555b43fee042c16bd65d4150d0346567f246b9190d85b45983","src/parallel/job_token.rs":"f4ed0a03d89a42bfd5527133d12b267af519b745f3f2b997ed293df15a2641b8","src/parallel/mod.rs":"55fb4c2d15e66677b2ed5ffa6d65ea161bcf1a1e1dc7910ee3bde06f2f67ab14","src/parallel/once_lock.rs":"d13e4cb82d6bca3297ca8671d83a40dd5affd7ac89191d733dd451867181bb02","src/parallel/stderr.rs":"74384d41198740a6fce0877f144262db09fb091225fa8fbfa771314bb11487c6","src/target_info.rs":"447d3083f24e10fe4c449925b349b3d14ab2ff103c0d9f942ea9b581873442e1","src/tempfile.rs":"ebafb5b0e5d08b0706916ed911d4245240e60c3e2d0c9a1630c520842988a2b3","src/tool.rs":"2e6550062e021f2b394388172bbb01e86fe6a94d2395bcb3c85a9e86690da1a9","src/utilities.rs":"a13bb0a351fcef72823485b1b5dc4f514c533fa4feac95deb66ed9e5fbfe7b53","src/windows/com.rs":"a2800ddb81215fff2bf618336f5c4ff8e8bdb746dd18b795873c7304b3f2a5e3","src/windows/find_tools.rs":"dd6b2450909cd8334a2aa2ce856bcc72a9654d92422267d6345d5fabfcbf57c5","src/windows/mod.rs":"34cfa201cfbcac7ccaa3ea5295d3e4200439af3cc5c6433baf81502596040a89","src/windows/registry.rs":"c521b72c825e8095843e73482ffa810ed066ad8bb9f86e6db0c5c143c171aba1","src/windows/setup_config.rs":"754439cbab492afd44c9755abcbec1a41c9b2c358131cee2df13c0e996dbbec8","src/windows/vs_instances.rs":"946527cf8fd32c3472f6a2884dcdec290763101097334c7478f9c24c3950db6b","src/windows/winapi.rs":"250d51c1826d1a2329e9889dd9f058cfce253dbf2a678b076147c6cdb5db046c","src/windows/windows_sys.rs":"e2714c8307bfa083b9745eb0e46cadd7f98d7b88abf45a7637172019324e34b8","src/windows/windows_targets.rs":"5b4648ebc22b028caca9f4b4bf8881fe2d094b7bec217264ba2e6e2c49d1ccee"},"package":"c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f"}

View File

@ -6,6 +6,87 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.1.31](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.30...cc-v1.1.31) - 2024-10-19
### Other
- Add comment explaining why cc does not rebuild on env PATH change ([#1247](https://github.com/rust-lang/cc-rs/pull/1247))
## [1.1.30](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.29...cc-v1.1.30) - 2024-10-11
### Other
- Don't pass -fPIC by default on wasm ([#1245](https://github.com/rust-lang/cc-rs/pull/1245))
## [1.1.29](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.28...cc-v1.1.29) - 2024-10-11
### Other
- Regenerate target info ([#1243](https://github.com/rust-lang/cc-rs/pull/1243))
## [1.1.28](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.27...cc-v1.1.28) - 2024-10-06
### Other
- Environment variables: For one accepting boolean, treat "0", "false" and empty env as false ([#1238](https://github.com/rust-lang/cc-rs/pull/1238))
## [1.1.27](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.26...cc-v1.1.27) - 2024-10-06
### Other
- Revert "Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))" ([#1237](https://github.com/rust-lang/cc-rs/pull/1237))
- Disable `CC_ENABLE_DEBUG_OUTPUT` if it is set to "0" ([#1234](https://github.com/rust-lang/cc-rs/pull/1234))
## [1.1.26](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.25...cc-v1.1.26) - 2024-10-06
### Other
- Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))
## [1.1.25](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.24...cc-v1.1.25) - 2024-10-05
### Other
- Remove incorrect "lib" prefixes in CXXSTDLIB doc comments ([#1228](https://github.com/rust-lang/cc-rs/pull/1228))
## [1.1.24](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.23...cc-v1.1.24) - 2024-10-01
### Other
- Fix wasm32-wasip1-threads: shared-memory disallowed due to not compiled with 'atomics' or 'bulk-memory' features ([#1221](https://github.com/rust-lang/cc-rs/pull/1221))
- Reduce the need for the host target triple ([#1224](https://github.com/rust-lang/cc-rs/pull/1224))
- Add auto cancellation for CI jobs ([#1222](https://github.com/rust-lang/cc-rs/pull/1222))
## [1.1.23](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.22...cc-v1.1.23) - 2024-09-30
### Other
- Update doc for detecting changes/upgrades of compilers ([#1218](https://github.com/rust-lang/cc-rs/pull/1218))
## [1.1.22](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.21...cc-v1.1.22) - 2024-09-27
### Other
- Don't rerun if PATH changes ([#1215](https://github.com/rust-lang/cc-rs/pull/1215))
## [1.1.21](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.20...cc-v1.1.21) - 2024-09-18
### Other
- disable pic for targets that end in `-none` ([#1212](https://github.com/rust-lang/cc-rs/pull/1212))
## [1.1.20](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.19...cc-v1.1.20) - 2024-09-17
### Other
- Add buildcache as known Rust and C/C++ compiler wrapper ([#1209](https://github.com/rust-lang/cc-rs/pull/1209))
## [1.1.19](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.18...cc-v1.1.19) - 2024-09-15
### Other
- Add support arm64e-apple-darwin ([#1207](https://github.com/rust-lang/cc-rs/pull/1207))
## [1.1.18](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.17...cc-v1.1.18) - 2024-09-07
### Other

View File

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.63"
name = "cc"
version = "1.1.18"
version = "1.1.31"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
build = false
exclude = [

View File

@ -44,7 +44,10 @@ impl CargoOutput {
metadata: true,
warnings: true,
output: OutputKind::Forward,
debug: std::env::var_os("CC_ENABLE_DEBUG_OUTPUT").is_some(),
debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") {
Some(v) => v != "0" && v != "false" && v != "",
None => false,
},
checked_dbg_var: Arc::new(AtomicBool::new(false)),
}
}

View File

@ -283,6 +283,9 @@ pub struct Build {
ccbin: bool,
std: Option<Arc<str>>,
target: Option<Arc<str>>,
/// The host compiler.
///
/// Try to not access this directly, and instead prefer `cfg!(...)`.
host: Option<Arc<str>>,
out_dir: Option<Arc<Path>>,
opt_level: Option<Arc<str>>,
@ -658,11 +661,13 @@ impl Build {
.cargo_metadata(self.cargo_output.metadata)
.target(target)
.opt_level(0)
.host(&self.get_host()?)
.debug(false)
.cpp(self.cpp)
.cuda(self.cuda)
.emit_rerun_if_env_changed(self.emit_rerun_if_env_changed);
if let Some(host) = &self.host {
cfg.host(host);
}
cfg.try_get_compiler()?
};
@ -839,8 +844,8 @@ impl Build {
/// The name of the C++ standard library to link is decided by:
/// 1. If [`cpp_link_stdlib`](Build::cpp_link_stdlib) is set, use its value.
/// 2. Else if the `CXXSTDLIB` environment variable is set, use its value.
/// 3. Else the default is `libc++` for OS X and BSDs, `libc++_shared` for Android,
/// `None` for MSVC and `libstdc++` for anything else.
/// 3. Else the default is `c++` for OS X and BSDs, `c++_shared` for Android,
/// `None` for MSVC and `stdc++` for anything else.
pub fn cpp(&mut self, cpp: bool) -> &mut Build {
self.cpp = cpp;
self
@ -1269,6 +1274,17 @@ impl Build {
/// Define whether metadata should be emitted for cargo to detect environment
/// changes that should trigger a rebuild.
///
/// NOTE that cc does not emit metadata to detect changes for `PATH`, since it could
/// be changed every comilation yet does not affect the result of compilation
/// (i.e. rust-analyzer adds temporary directory to `PATH`).
///
/// cc in general, has no way detecting changes to compiler, as there are so many ways to
/// change it and sidestep the detection, for example the compiler might be wrapped in a script
/// so detecting change of the file, or using checksum won't work.
///
/// We recommend users to decide for themselves, if they want rebuild if the compiler has been upgraded
/// or changed, and how to detect that.
///
/// This has no effect if the `cargo_metadata` option is `false`.
///
/// This option defaults to `true`.
@ -1841,7 +1857,7 @@ impl Build {
let mut cmd = self.get_base_compiler()?;
// Disable default flag generation via `no_default_flags` or environment variable
let no_defaults = self.no_default_flags || self.getenv("CRATE_CC_NO_DEFAULTS").is_some();
let no_defaults = self.no_default_flags || self.getenv_boolean("CRATE_CC_NO_DEFAULTS");
if !no_defaults {
self.add_default_flags(&mut cmd, &target, &opt_level)?;
@ -1980,11 +1996,13 @@ impl Build {
cmd.push_cc_arg("-fdata-sections".into());
}
// Disable generation of PIC on bare-metal for now: rust-lld doesn't support this yet
if self.pic.unwrap_or(
if self.pic.unwrap_or_else(|| {
!target.contains("windows")
&& !target.contains("-none-")
&& !target.contains("uefi"),
) {
&& !target.ends_with("-none")
&& !target.contains("uefi")
&& !Build::is_wasi_target(target)
}) {
cmd.push_cc_arg("-fPIC".into());
// PLT only applies if code is compiled with PIC support,
// and only for ELF targets.
@ -2002,6 +2020,10 @@ impl Build {
format!("--sysroot={}", Path::new(&wasi_sysroot).display()).into(),
);
}
if target.contains("threads") {
cmd.push_cc_arg("-pthread".into());
}
}
}
}
@ -2697,7 +2719,7 @@ impl Build {
let arch = if is_mac {
match arch_str {
"i686" => AppleArchSpec::Device("-m32"),
"x86_64" | "x86_64h" | "aarch64" => AppleArchSpec::Device("-m64"),
"x86_64" | "x86_64h" | "aarch64" | "arm64e" => AppleArchSpec::Device("-m64"),
_ => {
return Err(Error::new(
ErrorKind::ArchitectureInvalid,
@ -2854,7 +2876,6 @@ impl Build {
out_dir,
));
}
let host = self.get_host()?;
let target = self.get_target()?;
let target = &*target;
let (env, msvc, gnu, traditional, clang) = if self.cpp {
@ -2867,7 +2888,7 @@ impl Build {
// is not flag-compatible with "gcc". This history casts a long shadow,
// and many modern illumos distributions today ship GCC as "gcc" without
// also making it available as "cc".
let default = if host.contains("solaris") || host.contains("illumos") {
let default = if cfg!(target_os = "solaris") || cfg!(target_os = "illumos") {
gnu
} else {
traditional
@ -2932,7 +2953,7 @@ impl Build {
let tool = match tool_opt {
Some(t) => t,
None => {
let compiler = if host.contains("windows") && target.contains("windows") {
let compiler = if cfg!(windows) && target.contains("windows") {
if target.contains("msvc") {
msvc.to_string()
} else {
@ -2946,7 +2967,7 @@ impl Build {
{
clang.to_string()
} else if target.contains("android") {
autodetect_android_compiler(target, &host, gnu, clang)
autodetect_android_compiler(target, gnu, clang)
} else if target.contains("cloudabi") {
format!("{}-{}", target, traditional)
} else if Build::is_wasi_target(target) {
@ -2965,7 +2986,7 @@ impl Build {
format!("arm-kmc-eabi-{}", gnu)
} else if target.starts_with("aarch64-kmc-solid_") {
format!("aarch64-kmc-elf-{}", gnu)
} else if &*self.get_host()? != target {
} else if self.get_is_cross_compile()? {
let prefix = self.prefix_for_target(target);
match prefix {
Some(prefix) => {
@ -3030,8 +3051,7 @@ impl Build {
// on Windows is restricted to around 8k characters instead of around 32k characters.
// To remove this limit, we call the main clang binary directly and construct the
// `--target=` ourselves.
if host.contains("windows") && android_clang_compiler_uses_target_arg_internally(&tool.path)
{
if cfg!(windows) && android_clang_compiler_uses_target_arg_internally(&tool.path) {
if let Some(path) = tool.path.file_name() {
let file_name = path.to_str().unwrap().to_owned();
let (target, clang) = file_name.split_at(file_name.rfind('-').unwrap());
@ -3088,7 +3108,7 @@ impl Build {
// No explicit CC wrapper was detected, but check if RUSTC_WRAPPER
// is defined and is a build accelerator that is compatible with
// C/C++ compilers (e.g. sccache)
const VALID_WRAPPERS: &[&str] = &["sccache", "cachepot"];
const VALID_WRAPPERS: &[&str] = &["sccache", "cachepot", "buildcache"];
let rustc_wrapper = self.getenv("RUSTC_WRAPPER")?;
let wrapper_path = Path::new(&rustc_wrapper);
@ -3142,7 +3162,14 @@ impl Build {
//
// It's true that everything here is a bit of a pain, but apparently if
// you're not literally make or bash then you get a lot of bug reports.
let mut known_wrappers = vec!["ccache", "distcc", "sccache", "icecc", "cachepot"];
let mut known_wrappers = vec![
"ccache",
"distcc",
"sccache",
"icecc",
"cachepot",
"buildcache",
];
let custom_wrapper = self.getenv("CC_KNOWN_WRAPPER_CUSTOM");
if custom_wrapper.is_some() {
known_wrappers.push(custom_wrapper.as_deref().unwrap().to_str().unwrap());
@ -3175,8 +3202,8 @@ impl Build {
/// Returns the C++ standard library:
/// 1. If [`cpp_link_stdlib`](cc::Build::cpp_link_stdlib) is set, uses its value.
/// 2. Else if the `CXXSTDLIB` environment variable is set, uses its value.
/// 3. Else the default is `libc++` for OS X and BSDs, `libc++_shared` for Android,
/// `None` for MSVC and `libstdc++` for anything else.
/// 3. Else the default is `c++` for OS X and BSDs, `c++_shared` for Android,
/// `None` for MSVC and `stdc++` for anything else.
fn get_cpp_link_stdlib(&self) -> Result<Option<Cow<'_, Path>>, Error> {
match &self.cpp_link_stdlib {
Some(s) => Ok(s.as_deref().map(Path::new).map(Cow::Borrowed)),
@ -3411,7 +3438,7 @@ impl Build {
// Use the GNU-variant to match other Unix systems.
name = format!("g{}", tool).into();
self.cmd(&name)
} else if self.get_host()? != target {
} else if self.get_is_cross_compile()? {
match self.prefix_for_target(&target) {
Some(p) => {
// GCC uses $target-gcc-ar, whereas binutils uses $target-ar -- try both.
@ -3625,11 +3652,13 @@ impl Build {
}
}
fn get_host(&self) -> Result<Cow<'_, str>, Error> {
match &self.host {
Some(h) => Ok(Cow::Borrowed(h)),
None => self.getenv_unwrap_str("HOST").map(Cow::Owned),
}
fn get_is_cross_compile(&self) -> Result<bool, Error> {
let target = self.get_target()?;
let host: Cow<'_, str> = match &self.host {
Some(h) => Cow::Borrowed(h),
None => Cow::Owned(self.getenv_unwrap_str("HOST")?),
};
Ok(host != target)
}
fn get_opt_level(&self) -> Result<Cow<'_, str>, Error> {
@ -3640,15 +3669,12 @@ impl Build {
}
fn get_debug(&self) -> bool {
self.debug.unwrap_or_else(|| match self.getenv("DEBUG") {
Some(s) => &*s != "false",
None => false,
})
self.debug.unwrap_or_else(|| self.getenv_boolean("DEBUG"))
}
fn get_shell_escaped_flags(&self) -> bool {
self.shell_escaped_flags
.unwrap_or_else(|| self.getenv("CC_SHELL_ESCAPED_FLAGS").is_some())
.unwrap_or_else(|| self.getenv_boolean("CC_SHELL_ESCAPED_FLAGS"))
}
fn get_dwarf_version(&self) -> Option<u32> {
@ -3710,7 +3736,9 @@ impl Build {
if let Some(val) = self.env_cache.read().unwrap().get(v).cloned() {
return val;
}
if self.emit_rerun_if_env_changed && !provided_by_cargo(v) {
// Excluding `PATH` prevents spurious rebuilds on Windows, see
// <https://github.com/rust-lang/cc-rs/pull/1215> for details.
if self.emit_rerun_if_env_changed && !provided_by_cargo(v) && v != "PATH" {
self.cargo_output
.print_metadata(&format_args!("cargo:rerun-if-env-changed={}", v));
}
@ -3724,6 +3752,14 @@ impl Build {
r
}
/// get boolean flag that is either true or false
fn getenv_boolean(&self, v: &str) -> bool {
match self.getenv(v) {
Some(s) => &*s != "0" && &*s != "false" && !s.is_empty(),
None => false,
}
}
fn getenv_unwrap(&self, v: &str) -> Result<Arc<OsStr>, Error> {
match self.getenv(v) {
Some(s) => Ok(s),
@ -3746,8 +3782,11 @@ impl Build {
fn getenv_with_target_prefixes(&self, var_base: &str) -> Result<Arc<OsStr>, Error> {
let target = self.get_target()?;
let host = self.get_host()?;
let kind = if host == target { "HOST" } else { "TARGET" };
let kind = if self.get_is_cross_compile()? {
"TARGET"
} else {
"HOST"
};
let target_u = target.replace('-', "_");
let res = self
.getenv(&format!("{}_{}", var_base, target))
@ -3780,8 +3819,7 @@ impl Build {
fn fix_env_for_apple_os(&self, cmd: &mut Command) -> Result<(), Error> {
let target = self.get_target()?;
let host = self.get_host()?;
if host.contains("apple-darwin") && target.contains("apple-darwin") {
if cfg!(target_os = "macos") && target.contains("apple-darwin") {
// Additionally, `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at
// "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld",
// although this is apparently ignored when using the linker at "/usr/bin/ld".
@ -4190,7 +4228,7 @@ fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool
false
}
fn autodetect_android_compiler(target: &str, host: &str, gnu: &str, clang: &str) -> String {
fn autodetect_android_compiler(target: &str, gnu: &str, clang: &str) -> String {
let new_clang_key = match target {
"aarch64-linux-android" => Some("aarch64"),
"armv7-linux-androideabi" => Some("armv7a"),
@ -4230,7 +4268,7 @@ fn autodetect_android_compiler(target: &str, host: &str, gnu: &str, clang: &str)
// if not, use clang
if Command::new(&gnu_compiler).output().is_ok() {
gnu_compiler
} else if host.contains("windows") && Command::new(&clang_compiler_cmd).output().is_ok() {
} else if cfg!(windows) && Command::new(&clang_compiler_cmd).output().is_ok() {
clang_compiler_cmd
} else {
clang_compiler

View File

@ -2,6 +2,9 @@
//! in dev-tools/gen-target-info if you need to make changes.
pub const RISCV_ARCH_MAPPING: &[(&str, &str)] = &[
("riscv32e", "riscv32"),
("riscv32em", "riscv32"),
("riscv32emc", "riscv32"),
("riscv32gc", "riscv32"),
("riscv32i", "riscv32"),
("riscv32im", "riscv32"),

File diff suppressed because one or more lines are too long

10
pve-rs/vendor/flate2/Cargo.lock generated vendored
View File

@ -52,7 +52,7 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.33"
version = "1.0.34"
dependencies = [
"cloudflare-zlib-sys",
"crc32fast",
@ -93,9 +93,9 @@ dependencies = [
[[package]]
name = "libz-rs-sys"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ec231cd2039ed0e15e72467a2eabcdf6ff103e8a95e01eb8e2fb6f4c0661be7"
checksum = "b6fe3b2b1132d0a04912e2ea4f1196212562ba7775abe9f3b32d49489b17b75d"
dependencies = [
"zlib-rs",
]
@ -193,6 +193,6 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "zlib-rs"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e942bb8453553ee59b701f977d5331a512f8dd07906153bbe050cb9bb58a4811"
checksum = "4bf919c619da9eaede02291295e9c5ae230fc7b5f2a5f4257ff859b075111faf"

View File

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.56.1"
name = "flate2"
version = "1.0.33"
version = "1.0.34"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Josh Triplett <josh@joshtriplett.org>",
@ -177,7 +177,7 @@ version = "1.1.16"
optional = true
[dependencies.libz-rs-sys]
version = "0.2.1"
version = "0.3.0"
features = [
"std",
"rust-allocator",

View File

@ -447,7 +447,7 @@ mod c_backend {
#[cfg(feature = "zlib-ng")]
const ZLIB_VERSION: &'static str = "2.1.0.devel\0";
#[cfg(all(not(feature = "zlib-ng"), feature = "zlib-rs"))]
const ZLIB_VERSION: &'static str = "0.1.0\0";
const ZLIB_VERSION: &'static str = "1.3.0-zlib-rs-0.3.0\0";
#[cfg(not(any(feature = "zlib-ng", feature = "zlib-rs")))]
const ZLIB_VERSION: &'static str = "1.2.8\0";

View File

@ -192,6 +192,18 @@ impl Compression {
///
/// The integer here is typically on a scale of 0-9 where 0 means "no
/// compression" and 9 means "take as long as you'd like".
///
/// ### Backend differences
///
/// The [`miniz_oxide`](https://crates.io/crates/miniz_oxide) backend for flate2
/// does not support level 0 or `Compression::none()`. Instead it interprets them
/// as the default compression level, which is quite slow.
/// `Compression::fast()` should be used instead.
///
/// `miniz_oxide` also supports a non-compliant compression level 10.
/// It is even slower and may result in higher compression, but
/// **only miniz_oxide will be able to read the data** compressed with level 10.
/// Do **not** use level 10 if you need other software to be able to read it!
pub const fn new(level: u32) -> Compression {
Compression(level)
}
@ -213,7 +225,7 @@ impl Compression {
}
/// Returns an integer representing the compression level, typically on a
/// scale of 0-9
/// scale of 0-9. See [`new`](Self::new) for details about compression levels.
pub fn level(&self) -> u32 {
self.0
}

View File

@ -0,0 +1 @@
{"files":{"CHANGELOG.md":"04652d7c24426c471cae8b682ca4a1698de375a090a6b70ece2b41951ba33640","Cargo.toml":"a51fa0ef99f3ad34aef64907151d80c723a6143cba3aaa38b4f2e35cc82f1537","LICENSE":"7399628e08f01b7d94d42395ac7f50b95aad25faffa670d39c8b2d0281adf551","README.md":"a66c6718d61c2cabe11e2f41cbfc5dca5293b77b5927b9466fa09a3ead6b8d56","clippy.toml":"e0f282c75faa7e46c2630843826bb78f39dd2a6dea78dab7f960d34f730fb396","src/lib.rs":"eba884c4ffb319eecf896fe67351ace042660d36af9d32e955ab137c16b74493"},"package":"6b6129284da9f7e5296cc22183a63f24300e945e297705dcc0672f7df01d62c8"}

18
pve-rs/vendor/fmt2io/CHANGELOG.md vendored Normal file
View File

@ -0,0 +1,18 @@
# Changes
## 1.0.0 - Fri Sep 6 2024
* The crate is now considered stable
* Support Rust 1.0.0
* Various documentation improvements
* Fixed the `maintenance` badge
## 0.2.0 - Tue Jun 22 2021
Breaking change: the `write` function can now return any value in the `Ok` variant.
This is breaking because the number of generic arguments changed,
however if you didn't use turbofish to specify them there's no real break for you.
## 0.1.0 - Tue Nov 6 2018
Initial version capable of bridging `fmt` to `io` writes that didn't produce any value.

39
pve-rs/vendor/fmt2io/Cargo.toml vendored Normal file
View File

@ -0,0 +1,39 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
name = "fmt2io"
version = "1.0.0"
authors = ["Martin Habovstiak <martin.habovstiak@gmail.com>"]
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "A bridge between std::io::Write and std::fmt::Write."
readme = "README.md"
keywords = [
"fmt",
"io",
"Write",
"wrapper",
"bridge",
]
categories = ["rust-patterns"]
license = "MITNFA"
repository = "https://github.com/Kixunil/fmt2io"
[lib]
name = "fmt2io"
path = "src/lib.rs"
[badges.maintenance]
status = "as-is"

9
pve-rs/vendor/fmt2io/LICENSE vendored Normal file
View File

@ -0,0 +1,9 @@
Copyright (c) 2024 Martin Habovštiak
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Distributions of all or part of the Software intended to be used by the recipients as they would use the unmodified Software, containing modifications that substantially alter, remove, or disable functionality of the Software, outside of the documented configuration mechanisms provided by the Software, shall be modified such that the Original Author's bug reporting email addresses and urls are either replaced with the contact information of the parties responsible for the changes, or removed entirely.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

42
pve-rs/vendor/fmt2io/README.md vendored Normal file
View File

@ -0,0 +1,42 @@
Fmt to IO
=========
A bridge between `std::io::Write` and `std::fmt::Write`.
About
-----
Have you ever implemented a nice algorithm that generically uses `fmt::Write`
only to find out it doesn't work with `io::Write`? Worry no more - this is the
solution!
This crate provides a simple `write` function which takes your `io::Write`r,
converts it to `fmt::Write`r and provides it to your closure. This way, you
can easily bridge the two traits and have truly generic code.
Maintenance status
------------------
Passively maintained/done.
The crate does one thing and one thing only.
It works as expected and has sensible API.
It didn't need to be changed for a very long time and only had one significant code change since
its creation.
The other changes were purely for cleanup before 1.0 release.
It's also very small so there's pretty much zero chance of bugs.
Therefore I consider it done.
It's not dead, there just doesn't seem to be anything that needs changing.
MSRV
----
The minimal supported version of Rust is **1.0.0**.
This is not a joke, the crate really doesn't require any fancy compiler features.
However I don't object to raising the MSRV up to what's in Debian stable if some really good
reason arises. This is highly unlikely to happen.
License
-------
MITNFA

1
pve-rs/vendor/fmt2io/clippy.toml vendored Normal file
View File

@ -0,0 +1 @@
msrv = "1.0.0"

105
pve-rs/vendor/fmt2io/src/lib.rs vendored Normal file
View File

@ -0,0 +1,105 @@
//! Have you ever implemented a nice algorithm that generically uses `fmt::Write`
//! only to find out it doesn't work with `io::Write`? Worry no more - this is the
//! solution!
//!
//! This crate provides a simple `write` function which takes your `io::Write`r,
//! converts it to `fmt::Write`r and provides it to your closure. This way, you
//! can easily bridge the two traits and have truly generic code.
//!
//! Example
//! -------
//!
//! ```rust
//! use std::fmt::Write;
//!
//! let mut out = Vec::new();
//!
//! fmt2io::write(&mut out, |writer| write!(writer, "Hello world!"))?;
//! assert_eq!(out, "Hello world!".as_bytes());
//!
//! # Ok::<(), std::io::Error>(())
//! ```
//!
//! Maintenance status
//! ------------------
//!
//! Passively maintained/done.
//!
//! The crate does one thing and one thing only.
//! It works as expected and has sensible API.
//! It didn't need to be changed for a very long time and only had one significant code change since
//! its creation.
//! The other changes were purely for cleanup before 1.0 release.
//! It's also very small so there's pretty much zero chance of bugs.
//! Therefore I consider it done.
//! It's not dead, there just doesn't seem to be anything that needs changing.
//!
//! MSRV
//! ----
//!
//! The minimal supported version of Rust is **1.0.0**.
//! This is not a joke, the crate really doesn't require any fancy compiler features.
//! However I don't object to raising the MSRV up to what's in Debian stable if some really good
//! reason arises. This is highly unlikely to happen.
use std::{fmt, io};
/// Converts given [`io::Write`]r to [`fmt::Write`]r.
///
/// The [`Writer`] is constructed from your `writer` which you
/// can use to write UTF-8 data to. The function returns underlying io
/// Error, if there has been one.
///
/// This function uses closure instead of directly exposing [`Writer`]
/// in order to make error handling ergonomic/idiomatic.
///
/// See the [crate-level documentation](crate) for an example.
///
/// ## Panics
///
/// This function panics if `writer` didn't return an error but you
/// return `Err` from the closure. Return `Ok(Err(YourError))` to handle
/// your own error cases.
pub fn write<R, W, F>(writer: W, f: F) -> io::Result<R> where W: io::Write, F: FnOnce(&mut Writer<W>) -> Result<R, fmt::Error> {
let mut writer = Writer {
writer: writer,
result: Ok(()),
};
let result = f(&mut writer);
writer.result.map(move |_| result.unwrap())
}
/// A bridge between [`std::io::Write`] and [`std::fmt::Write`].
///
/// This struct provides [`fmt::Write`] implementation for inner
/// writers implementing [`io::Write`]. It must be used within the
/// [`write()`] function.
///
/// See the documentation of [`write()`] for more information.
#[derive(Debug)]
pub struct Writer<W: io::Write> {
writer: W,
result: Result<(), io::Error>,
}
impl<W: io::Write> fmt::Write for Writer<W> {
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
self.writer.write_all(s.as_bytes()).map_err(|err| { self.result = Err(err); fmt::Error })
}
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
use std::fmt::Write;
let mut out = Vec::new();
::write(&mut out, |writer| write!(writer, "Hello world!")).unwrap();
assert_eq!(out, "Hello world!".as_bytes());
}
}

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"21a7215adbf49919270abecb9deb8d81a32383f4d2163d82869139cbffe6648e","LICENSE-APACHE":"275c491d6d1160553c32fd6127061d7f9606c3ea25abfad6ca3f6ed088785427","LICENSE-MIT":"6652c868f35dfe5e8ef636810a4e576b9d663f3a17fb0f5613ad73583e1b88fd","README.md":"e8258273fed6f1796485777655118f2369fd3f000191e9d8cdbd10bf052946a9","src/future.rs":"0cb559fad0d43566dab959e929c4631c25cf749e2e29a5444fbcad464c9262ae","src/lib.rs":"eacd5816fbb914ca061d49ff6203723ebbe639eb7c45ebfa8a0613069d174111","src/stream.rs":"f1c7ab84161c5d5b424655b257fc3183eb6f2ed5324ba4006a70f9a4b0dc8872","src/task/__internal/atomic_waker.rs":"e5184bcc772c1472a2f0f9899bd3e388b74b771d327d801a5ea7e4aca6e57715","src/task/__internal/mod.rs":"1cc15fd61942a29ea558c5f4d5782e46adcfd914cab82be084a6882fa9afc122","src/task/mod.rs":"e213602a2fe5ae78ad5f1ca20e6d32dcbab17aba5b6b072fb927a72da99b4a11","src/task/poll.rs":"74c2717c1f9a37587a367da1b690d1cd2312e95dbaffca42be4755f1cd164bb8"},"package":"dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"}
{"files":{"Cargo.toml":"c0ee4bd5904127f284fff848d01d9e6539e1762e6c1291f55025a9bf0b754827","LICENSE-APACHE":"275c491d6d1160553c32fd6127061d7f9606c3ea25abfad6ca3f6ed088785427","LICENSE-MIT":"6652c868f35dfe5e8ef636810a4e576b9d663f3a17fb0f5613ad73583e1b88fd","README.md":"e8258273fed6f1796485777655118f2369fd3f000191e9d8cdbd10bf052946a9","src/future.rs":"bdbe034548271aef0c3dd8a6d087a5861e5920848c9e33a8949dbc40407c0ca7","src/lib.rs":"e545004177a7cd13257a3a562d2d44a5e0cff45687fc912b69e3d510fa397396","src/stream.rs":"11f0b4360287dd870c1b674db84f2452ddc38fbaf475cca27d374b65211af72d","src/task/__internal/atomic_waker.rs":"0418206de25768f691944c81f61ccec2c362751e56757bf812385c8ef01081fe","src/task/__internal/mod.rs":"1cc15fd61942a29ea558c5f4d5782e46adcfd914cab82be084a6882fa9afc122","src/task/mod.rs":"e213602a2fe5ae78ad5f1ca20e6d32dcbab17aba5b6b072fb927a72da99b4a11","src/task/poll.rs":"74c2717c1f9a37587a367da1b690d1cd2312e95dbaffca42be4755f1cd164bb8"},"package":"05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"}

View File

@ -13,7 +13,12 @@
edition = "2018"
rust-version = "1.36"
name = "futures-core"
version = "0.3.30"
version = "0.3.31"
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = """
The core traits and types in for the `futures` library.
"""
@ -29,6 +34,10 @@ rustdoc-args = [
"docsrs",
]
[lib]
name = "futures_core"
path = "src/lib.rs"
[dependencies.portable-atomic]
version = "1.3"
features = ["require-cas"]
@ -43,3 +52,14 @@ cfg-target-has-atomic = []
default = ["std"]
std = ["alloc"]
unstable = []
[lints.rust]
missing_debug_implementations = "warn"
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
unreachable_pub = "warn"
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0
check-cfg = ["cfg(futures_sanitizer)"]

View File

@ -9,10 +9,20 @@ pub use core::future::Future;
/// An owned dynamically typed [`Future`] for use in cases where you can't
/// statically type your result or need to add some indirection.
///
/// This type is often created by the [`boxed`] method on [`FutureExt`]. See its documentation for more.
///
/// [`boxed`]: https://docs.rs/futures/latest/futures/future/trait.FutureExt.html#method.boxed
/// [`FutureExt`]: https://docs.rs/futures/latest/futures/future/trait.FutureExt.html
#[cfg(feature = "alloc")]
pub type BoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + Send + 'a>>;
/// `BoxFuture`, but without the `Send` requirement.
///
/// This type is often created by the [`boxed_local`] method on [`FutureExt`]. See its documentation for more.
///
/// [`boxed_local`]: https://docs.rs/futures/latest/futures/future/trait.FutureExt.html#method.boxed_local
/// [`FutureExt`]: https://docs.rs/futures/latest/futures/future/trait.FutureExt.html
#[cfg(feature = "alloc")]
pub type LocalBoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + 'a>>;

View File

@ -1,9 +1,6 @@
//! Core traits and types for asynchronous operations in Rust.
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)]
// It cannot be included in the published code because this lints have false positives in the minimum required version.
#![cfg_attr(test, warn(single_use_lifetimes))]
#![no_std]
#![doc(test(
no_crate_inject,
attr(
@ -11,9 +8,12 @@
allow(dead_code, unused_assignments, unused_variables)
)
))]
#![warn(missing_docs, /* unsafe_op_in_unsafe_fn */)] // unsafe_op_in_unsafe_fn requires Rust 1.52
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
pub mod future;
#[doc(no_inline)]

View File

@ -6,10 +6,20 @@ use core::task::{Context, Poll};
/// An owned dynamically typed [`Stream`] for use in cases where you can't
/// statically type your result or need to add some indirection.
///
/// This type is often created by the [`boxed`] method on [`StreamExt`]. See its documentation for more.
///
/// [`boxed`]: https://docs.rs/futures/latest/futures/stream/trait.StreamExt.html#method.boxed
/// [`StreamExt`]: https://docs.rs/futures/latest/futures/stream/trait.StreamExt.html
#[cfg(feature = "alloc")]
pub type BoxStream<'a, T> = Pin<alloc::boxed::Box<dyn Stream<Item = T> + Send + 'a>>;
/// `BoxStream`, but without the `Send` requirement.
///
/// This type is often created by the [`boxed_local`] method on [`StreamExt`]. See its documentation for more.
///
/// [`boxed_local`]: https://docs.rs/futures/latest/futures/stream/trait.StreamExt.html#method.boxed_local
/// [`StreamExt`]: https://docs.rs/futures/latest/futures/stream/trait.StreamExt.html
#[cfg(feature = "alloc")]
pub type LocalBoxStream<'a, T> = Pin<alloc::boxed::Box<dyn Stream<Item = T> + 'a>>;
@ -38,15 +48,15 @@ pub trait Stream {
/// stream state:
///
/// - `Poll::Pending` means that this stream's next value is not ready
/// yet. Implementations will ensure that the current task will be notified
/// when the next value may be ready.
/// yet. Implementations will ensure that the current task will be notified
/// when the next value may be ready.
///
/// - `Poll::Ready(Some(val))` means that the stream has successfully
/// produced a value, `val`, and may produce further values on subsequent
/// `poll_next` calls.
/// produced a value, `val`, and may produce further values on subsequent
/// `poll_next` calls.
///
/// - `Poll::Ready(None)` means that the stream has terminated, and
/// `poll_next` should not be invoked again.
/// `poll_next` should not be invoked again.
///
/// # Panics
///

View File

@ -206,6 +206,7 @@ impl AtomicWaker {
/// Create an `AtomicWaker`.
pub const fn new() -> Self {
// Make sure that task is Sync
#[allow(dead_code)]
trait AssertSync: Sync {}
impl AssertSync for Waker {}

View File

@ -1 +1 @@
{"files":{"Cargo.toml":"a2f46c222bebd5fae127414ffb34535af67be92b58bafcc39a16523ffc33ee83","LICENSE-APACHE":"275c491d6d1160553c32fd6127061d7f9606c3ea25abfad6ca3f6ed088785427","LICENSE-MIT":"6652c868f35dfe5e8ef636810a4e576b9d663f3a17fb0f5613ad73583e1b88fd","README.md":"575430be5c47352d85f36b44dcc2c2851a6a19e2384593415c4af22c6654cee7","src/lib.rs":"526e9700c28250b7512f122952257d57adc38eb001af92ef25bdb48a8c453175"},"package":"a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"}
{"files":{"Cargo.toml":"1b91c3dcf4888590e4e0499bbc7f261d97278782875032bef60952b4f47c5872","LICENSE-APACHE":"275c491d6d1160553c32fd6127061d7f9606c3ea25abfad6ca3f6ed088785427","LICENSE-MIT":"6652c868f35dfe5e8ef636810a4e576b9d663f3a17fb0f5613ad73583e1b88fd","README.md":"575430be5c47352d85f36b44dcc2c2851a6a19e2384593415c4af22c6654cee7","src/lib.rs":"ff0a57a4c0eea4b7677404cdca237729f0af9c5dfc9539d23583a71ac7e9cc42"},"package":"9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"}

View File

@ -13,7 +13,12 @@
edition = "2018"
rust-version = "1.36"
name = "futures-io"
version = "0.3.30"
version = "0.3.31"
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = """
The `AsyncRead`, `AsyncWrite`, `AsyncSeek`, and `AsyncBufRead` traits for the futures-rs library.
"""
@ -29,9 +34,24 @@ rustdoc-args = [
"docsrs",
]
[lib]
name = "futures_io"
path = "src/lib.rs"
[dependencies]
[features]
default = ["std"]
std = []
unstable = []
[lints.rust]
missing_debug_implementations = "warn"
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
unreachable_pub = "warn"
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0
check-cfg = ["cfg(futures_sanitizer)"]

Some files were not shown because too many files have changed in this diff Show More