├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md └── src ├── build.rs ├── files.rs ├── installed.rs ├── list.rs ├── main.rs └── query_files.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "android-tzdata" 16 | version = "0.1.1" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" 19 | 20 | [[package]] 21 | name = "android_system_properties" 22 | version = "0.1.5" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 25 | dependencies = [ 26 | "libc", 27 | ] 28 | 29 | [[package]] 30 | name = "anstream" 31 | version = "0.6.18" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" 34 | dependencies = [ 35 | "anstyle", 36 | "anstyle-parse", 37 | "anstyle-query", 38 | "anstyle-wincon", 39 | "colorchoice", 40 | "is_terminal_polyfill", 41 | "utf8parse", 42 | ] 43 | 44 | [[package]] 45 | name = "anstyle" 46 | version = "1.0.10" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" 49 | 50 | [[package]] 51 | name = "anstyle-parse" 52 | version = "0.2.6" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" 55 | dependencies = [ 56 | "utf8parse", 57 | ] 58 | 59 | [[package]] 60 | name = "anstyle-query" 61 | version = "1.1.2" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" 64 | dependencies = [ 65 | "windows-sys 0.59.0", 66 | ] 67 | 68 | [[package]] 69 | name = "anstyle-wincon" 70 | version = "3.0.7" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" 73 | dependencies = [ 74 | "anstyle", 75 | "once_cell", 76 | "windows-sys 0.59.0", 77 | ] 78 | 79 | [[package]] 80 | name = "autocfg" 81 | version = "1.4.0" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 84 | 85 | [[package]] 86 | name = "bitflags" 87 | version = "2.9.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" 90 | 91 | [[package]] 92 | name = "bumpalo" 93 | version = "3.17.0" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" 96 | 97 | [[package]] 98 | name = "cc" 99 | version = "1.2.17" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" 102 | dependencies = [ 103 | "shlex", 104 | ] 105 | 106 | [[package]] 107 | name = "cfg-if" 108 | version = "1.0.0" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 111 | 112 | [[package]] 113 | name = "chrono" 114 | version = "0.4.40" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" 117 | dependencies = [ 118 | "android-tzdata", 119 | "iana-time-zone", 120 | "num-traits", 121 | "windows-link", 122 | ] 123 | 124 | [[package]] 125 | name = "clap" 126 | version = "4.5.34" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" 129 | dependencies = [ 130 | "clap_builder", 131 | "clap_derive", 132 | ] 133 | 134 | [[package]] 135 | name = "clap_builder" 136 | version = "4.5.34" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" 139 | dependencies = [ 140 | "anstream", 141 | "anstyle", 142 | "clap_lex", 143 | "strsim", 144 | ] 145 | 146 | [[package]] 147 | name = "clap_derive" 148 | version = "4.5.32" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" 151 | dependencies = [ 152 | "heck", 153 | "proc-macro2", 154 | "quote", 155 | "syn", 156 | ] 157 | 158 | [[package]] 159 | name = "clap_lex" 160 | version = "0.7.4" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" 163 | 164 | [[package]] 165 | name = "colorchoice" 166 | version = "1.0.3" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" 169 | 170 | [[package]] 171 | name = "compress-tools" 172 | version = "0.15.1" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "ecbcea9a172acabd98f272919faf0b1830a2ccec90d518d67c5eb13742e769a7" 175 | dependencies = [ 176 | "derive_more", 177 | "libc", 178 | "pkg-config", 179 | "vcpkg", 180 | ] 181 | 182 | [[package]] 183 | name = "core-foundation-sys" 184 | version = "0.8.7" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" 187 | 188 | [[package]] 189 | name = "derive_more" 190 | version = "0.99.19" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" 193 | dependencies = [ 194 | "proc-macro2", 195 | "quote", 196 | "syn", 197 | ] 198 | 199 | [[package]] 200 | name = "errno" 201 | version = "0.3.10" 202 | source = "registry+https://github.com/rust-lang/crates.io-index" 203 | checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" 204 | dependencies = [ 205 | "libc", 206 | "windows-sys 0.59.0", 207 | ] 208 | 209 | [[package]] 210 | name = "eyre" 211 | version = "0.6.12" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" 214 | dependencies = [ 215 | "indenter", 216 | "once_cell", 217 | ] 218 | 219 | [[package]] 220 | name = "fastrand" 221 | version = "2.3.0" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" 224 | 225 | [[package]] 226 | name = "getrandom" 227 | version = "0.3.2" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" 230 | dependencies = [ 231 | "cfg-if", 232 | "libc", 233 | "r-efi", 234 | "wasi", 235 | ] 236 | 237 | [[package]] 238 | name = "heck" 239 | version = "0.5.0" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 242 | 243 | [[package]] 244 | name = "iana-time-zone" 245 | version = "0.1.62" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "b2fd658b06e56721792c5df4475705b6cda790e9298d19d2f8af083457bcd127" 248 | dependencies = [ 249 | "android_system_properties", 250 | "core-foundation-sys", 251 | "iana-time-zone-haiku", 252 | "js-sys", 253 | "log", 254 | "wasm-bindgen", 255 | "windows-core", 256 | ] 257 | 258 | [[package]] 259 | name = "iana-time-zone-haiku" 260 | version = "0.1.2" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" 263 | dependencies = [ 264 | "cc", 265 | ] 266 | 267 | [[package]] 268 | name = "indenter" 269 | version = "0.3.3" 270 | source = "registry+https://github.com/rust-lang/crates.io-index" 271 | checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" 272 | 273 | [[package]] 274 | name = "is_terminal_polyfill" 275 | version = "1.70.1" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" 278 | 279 | [[package]] 280 | name = "js-sys" 281 | version = "0.3.77" 282 | source = "registry+https://github.com/rust-lang/crates.io-index" 283 | checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" 284 | dependencies = [ 285 | "once_cell", 286 | "wasm-bindgen", 287 | ] 288 | 289 | [[package]] 290 | name = "lazy_static" 291 | version = "1.5.0" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 294 | 295 | [[package]] 296 | name = "libc" 297 | version = "0.2.171" 298 | source = "registry+https://github.com/rust-lang/crates.io-index" 299 | checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" 300 | 301 | [[package]] 302 | name = "linux-raw-sys" 303 | version = "0.9.3" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" 306 | 307 | [[package]] 308 | name = "log" 309 | version = "0.4.27" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" 312 | 313 | [[package]] 314 | name = "matchers" 315 | version = "0.1.0" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" 318 | dependencies = [ 319 | "regex-automata 0.1.10", 320 | ] 321 | 322 | [[package]] 323 | name = "memchr" 324 | version = "2.7.4" 325 | source = "registry+https://github.com/rust-lang/crates.io-index" 326 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 327 | 328 | [[package]] 329 | name = "nu-ansi-term" 330 | version = "0.46.0" 331 | source = "registry+https://github.com/rust-lang/crates.io-index" 332 | checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" 333 | dependencies = [ 334 | "overload", 335 | "winapi", 336 | ] 337 | 338 | [[package]] 339 | name = "nu-ansi-term" 340 | version = "0.50.1" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" 343 | dependencies = [ 344 | "windows-sys 0.52.0", 345 | ] 346 | 347 | [[package]] 348 | name = "num-traits" 349 | version = "0.2.19" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 352 | dependencies = [ 353 | "autocfg", 354 | ] 355 | 356 | [[package]] 357 | name = "once_cell" 358 | version = "1.21.1" 359 | source = "registry+https://github.com/rust-lang/crates.io-index" 360 | checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" 361 | 362 | [[package]] 363 | name = "overload" 364 | version = "0.1.1" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" 367 | 368 | [[package]] 369 | name = "pacfiles" 370 | version = "0.2.7" 371 | dependencies = [ 372 | "clap", 373 | "compress-tools", 374 | "eyre", 375 | "nu-ansi-term 0.50.1", 376 | "tempfile", 377 | "tracing", 378 | "tracing-subscriber", 379 | ] 380 | 381 | [[package]] 382 | name = "pin-project-lite" 383 | version = "0.2.16" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" 386 | 387 | [[package]] 388 | name = "pkg-config" 389 | version = "0.3.32" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" 392 | 393 | [[package]] 394 | name = "proc-macro2" 395 | version = "1.0.94" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" 398 | dependencies = [ 399 | "unicode-ident", 400 | ] 401 | 402 | [[package]] 403 | name = "quote" 404 | version = "1.0.40" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 407 | dependencies = [ 408 | "proc-macro2", 409 | ] 410 | 411 | [[package]] 412 | name = "r-efi" 413 | version = "5.2.0" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" 416 | 417 | [[package]] 418 | name = "regex" 419 | version = "1.11.1" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" 422 | dependencies = [ 423 | "aho-corasick", 424 | "memchr", 425 | "regex-automata 0.4.9", 426 | "regex-syntax 0.8.5", 427 | ] 428 | 429 | [[package]] 430 | name = "regex-automata" 431 | version = "0.1.10" 432 | source = "registry+https://github.com/rust-lang/crates.io-index" 433 | checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" 434 | dependencies = [ 435 | "regex-syntax 0.6.29", 436 | ] 437 | 438 | [[package]] 439 | name = "regex-automata" 440 | version = "0.4.9" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" 443 | dependencies = [ 444 | "aho-corasick", 445 | "memchr", 446 | "regex-syntax 0.8.5", 447 | ] 448 | 449 | [[package]] 450 | name = "regex-syntax" 451 | version = "0.6.29" 452 | source = "registry+https://github.com/rust-lang/crates.io-index" 453 | checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" 454 | 455 | [[package]] 456 | name = "regex-syntax" 457 | version = "0.8.5" 458 | source = "registry+https://github.com/rust-lang/crates.io-index" 459 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 460 | 461 | [[package]] 462 | name = "rustix" 463 | version = "1.0.3" 464 | source = "registry+https://github.com/rust-lang/crates.io-index" 465 | checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" 466 | dependencies = [ 467 | "bitflags", 468 | "errno", 469 | "libc", 470 | "linux-raw-sys", 471 | "windows-sys 0.59.0", 472 | ] 473 | 474 | [[package]] 475 | name = "rustversion" 476 | version = "1.0.20" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" 479 | 480 | [[package]] 481 | name = "sharded-slab" 482 | version = "0.1.7" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" 485 | dependencies = [ 486 | "lazy_static", 487 | ] 488 | 489 | [[package]] 490 | name = "shlex" 491 | version = "1.3.0" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 494 | 495 | [[package]] 496 | name = "strsim" 497 | version = "0.11.1" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 500 | 501 | [[package]] 502 | name = "syn" 503 | version = "2.0.100" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 506 | dependencies = [ 507 | "proc-macro2", 508 | "quote", 509 | "unicode-ident", 510 | ] 511 | 512 | [[package]] 513 | name = "tempfile" 514 | version = "3.19.1" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" 517 | dependencies = [ 518 | "fastrand", 519 | "getrandom", 520 | "once_cell", 521 | "rustix", 522 | "windows-sys 0.59.0", 523 | ] 524 | 525 | [[package]] 526 | name = "thread_local" 527 | version = "1.1.8" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" 530 | dependencies = [ 531 | "cfg-if", 532 | "once_cell", 533 | ] 534 | 535 | [[package]] 536 | name = "tracing" 537 | version = "0.1.41" 538 | source = "registry+https://github.com/rust-lang/crates.io-index" 539 | checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" 540 | dependencies = [ 541 | "pin-project-lite", 542 | "tracing-attributes", 543 | "tracing-core", 544 | ] 545 | 546 | [[package]] 547 | name = "tracing-attributes" 548 | version = "0.1.28" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" 551 | dependencies = [ 552 | "proc-macro2", 553 | "quote", 554 | "syn", 555 | ] 556 | 557 | [[package]] 558 | name = "tracing-core" 559 | version = "0.1.33" 560 | source = "registry+https://github.com/rust-lang/crates.io-index" 561 | checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" 562 | dependencies = [ 563 | "once_cell", 564 | ] 565 | 566 | [[package]] 567 | name = "tracing-subscriber" 568 | version = "0.3.19" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" 571 | dependencies = [ 572 | "chrono", 573 | "matchers", 574 | "nu-ansi-term 0.46.0", 575 | "once_cell", 576 | "regex", 577 | "sharded-slab", 578 | "thread_local", 579 | "tracing", 580 | "tracing-core", 581 | ] 582 | 583 | [[package]] 584 | name = "unicode-ident" 585 | version = "1.0.18" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 588 | 589 | [[package]] 590 | name = "utf8parse" 591 | version = "0.2.2" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" 594 | 595 | [[package]] 596 | name = "vcpkg" 597 | version = "0.2.15" 598 | source = "registry+https://github.com/rust-lang/crates.io-index" 599 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 600 | 601 | [[package]] 602 | name = "wasi" 603 | version = "0.14.2+wasi-0.2.4" 604 | source = "registry+https://github.com/rust-lang/crates.io-index" 605 | checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" 606 | dependencies = [ 607 | "wit-bindgen-rt", 608 | ] 609 | 610 | [[package]] 611 | name = "wasm-bindgen" 612 | version = "0.2.100" 613 | source = "registry+https://github.com/rust-lang/crates.io-index" 614 | checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" 615 | dependencies = [ 616 | "cfg-if", 617 | "once_cell", 618 | "rustversion", 619 | "wasm-bindgen-macro", 620 | ] 621 | 622 | [[package]] 623 | name = "wasm-bindgen-backend" 624 | version = "0.2.100" 625 | source = "registry+https://github.com/rust-lang/crates.io-index" 626 | checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" 627 | dependencies = [ 628 | "bumpalo", 629 | "log", 630 | "proc-macro2", 631 | "quote", 632 | "syn", 633 | "wasm-bindgen-shared", 634 | ] 635 | 636 | [[package]] 637 | name = "wasm-bindgen-macro" 638 | version = "0.2.100" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" 641 | dependencies = [ 642 | "quote", 643 | "wasm-bindgen-macro-support", 644 | ] 645 | 646 | [[package]] 647 | name = "wasm-bindgen-macro-support" 648 | version = "0.2.100" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" 651 | dependencies = [ 652 | "proc-macro2", 653 | "quote", 654 | "syn", 655 | "wasm-bindgen-backend", 656 | "wasm-bindgen-shared", 657 | ] 658 | 659 | [[package]] 660 | name = "wasm-bindgen-shared" 661 | version = "0.2.100" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" 664 | dependencies = [ 665 | "unicode-ident", 666 | ] 667 | 668 | [[package]] 669 | name = "winapi" 670 | version = "0.3.9" 671 | source = "registry+https://github.com/rust-lang/crates.io-index" 672 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 673 | dependencies = [ 674 | "winapi-i686-pc-windows-gnu", 675 | "winapi-x86_64-pc-windows-gnu", 676 | ] 677 | 678 | [[package]] 679 | name = "winapi-i686-pc-windows-gnu" 680 | version = "0.4.0" 681 | source = "registry+https://github.com/rust-lang/crates.io-index" 682 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 683 | 684 | [[package]] 685 | name = "winapi-x86_64-pc-windows-gnu" 686 | version = "0.4.0" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 689 | 690 | [[package]] 691 | name = "windows-core" 692 | version = "0.52.0" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 695 | dependencies = [ 696 | "windows-targets", 697 | ] 698 | 699 | [[package]] 700 | name = "windows-link" 701 | version = "0.1.1" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" 704 | 705 | [[package]] 706 | name = "windows-sys" 707 | version = "0.52.0" 708 | source = "registry+https://github.com/rust-lang/crates.io-index" 709 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 710 | dependencies = [ 711 | "windows-targets", 712 | ] 713 | 714 | [[package]] 715 | name = "windows-sys" 716 | version = "0.59.0" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 719 | dependencies = [ 720 | "windows-targets", 721 | ] 722 | 723 | [[package]] 724 | name = "windows-targets" 725 | version = "0.52.6" 726 | source = "registry+https://github.com/rust-lang/crates.io-index" 727 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 728 | dependencies = [ 729 | "windows_aarch64_gnullvm", 730 | "windows_aarch64_msvc", 731 | "windows_i686_gnu", 732 | "windows_i686_gnullvm", 733 | "windows_i686_msvc", 734 | "windows_x86_64_gnu", 735 | "windows_x86_64_gnullvm", 736 | "windows_x86_64_msvc", 737 | ] 738 | 739 | [[package]] 740 | name = "windows_aarch64_gnullvm" 741 | version = "0.52.6" 742 | source = "registry+https://github.com/rust-lang/crates.io-index" 743 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 744 | 745 | [[package]] 746 | name = "windows_aarch64_msvc" 747 | version = "0.52.6" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 750 | 751 | [[package]] 752 | name = "windows_i686_gnu" 753 | version = "0.52.6" 754 | source = "registry+https://github.com/rust-lang/crates.io-index" 755 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 756 | 757 | [[package]] 758 | name = "windows_i686_gnullvm" 759 | version = "0.52.6" 760 | source = "registry+https://github.com/rust-lang/crates.io-index" 761 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 762 | 763 | [[package]] 764 | name = "windows_i686_msvc" 765 | version = "0.52.6" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 768 | 769 | [[package]] 770 | name = "windows_x86_64_gnu" 771 | version = "0.52.6" 772 | source = "registry+https://github.com/rust-lang/crates.io-index" 773 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 774 | 775 | [[package]] 776 | name = "windows_x86_64_gnullvm" 777 | version = "0.52.6" 778 | source = "registry+https://github.com/rust-lang/crates.io-index" 779 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 780 | 781 | [[package]] 782 | name = "windows_x86_64_msvc" 783 | version = "0.52.6" 784 | source = "registry+https://github.com/rust-lang/crates.io-index" 785 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 786 | 787 | [[package]] 788 | name = "wit-bindgen-rt" 789 | version = "0.39.0" 790 | source = "registry+https://github.com/rust-lang/crates.io-index" 791 | checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" 792 | dependencies = [ 793 | "bitflags", 794 | ] 795 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pacfiles" 3 | version = "0.2.7" 4 | edition = "2024" 5 | description = "A pacman -F alternative that runs blazingly fast" 6 | license = "GPL-2.0-or-later" 7 | repository = "https://github.com/lilydjwg/pacfiles" 8 | categories = ["command-line-utilities"] 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | 12 | [dependencies] 13 | clap = { version = "4.5.34", features = ["derive"] } 14 | eyre = "0.6.12" 15 | tracing = "0.1.41" 16 | tracing-subscriber = { version = "0.3.19", default-features = false, features = ["env-filter", "fmt", "ansi", "chrono"] } 17 | 18 | compress-tools = "0.15.1" 19 | nu-ansi-term = "0.50.1" 20 | tempfile = "3.19.1" 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | pacfiles 2 | ==== 3 | 4 | pacfiles is a `pacman -F` alternative that runs blazingly fast. It achieves this by using [plocate](https://plocate.sesse.net/) databases. 5 | 6 | Installation 7 | ---- 8 | 9 | It depends on `libarchive`, `pacman` and `plocate`. You can install this with: 10 | 11 | ``` 12 | cargo install pacfiles 13 | ``` 14 | 15 | Usage 16 | ---- 17 | 18 | It has a subset of options from `pacman -F`: 19 | 20 | ``` 21 | A pacman -F alternative that runs blazingly fast 22 | 23 | Usage: pacfiles [OPTIONS] [QUERY]... 24 | 25 | Arguments: 26 | [QUERY]... The query; unlike pacman, globs (*?[]) are supported in non-regex mode 27 | 28 | Options: 29 | -F, --files ignored 30 | -l, --list List the files owned by the queried package 31 | -x, --regex Interpret each query as a POSIX extended regular expression 32 | -q, --quiet Do not output colors and file paths 33 | -y, --refresh... Refresh & rebuild databases; give twice to force 34 | --update-db... rebuild databases only without refreshing; give twice to force 35 | -h, --help Print help 36 | -V, --version Print version 37 | ``` 38 | 39 | It tries to output in the same format as pacman. 40 | 41 | You need to run `pacfiles -Fy` to update its databases. 42 | 43 | Performance 44 | ---- 45 | 46 | Search for a file: 47 | 48 | ``` 49 | >>> time pacman -F vim 50 | extra/gvim 9.1.1165-1 51 | usr/bin/vim 52 | extra/radare2 5.9.8-1 53 | usr/share/doc/radare2/vim 54 | usr/share/radare2/5.9.8/magic/vim 55 | extra/rizin 0.7.4-1 56 | usr/share/rizin/magic/vim 57 | extra/vim 9.1.1165-1 58 | usr/bin/vim 59 | archlinuxcn/gvim-lily 9.1.1163-1 [已安装: 9.1.1144-1] 60 | usr/bin/vim 61 | archlinuxcn/vim-lily 9.1.1163-1 62 | usr/bin/vim 63 | chaotic-aur/cheat 4.4.2-3 64 | usr/share/cheat/cheatsheets/community/vim 65 | chaotic-aur/neovim-drop-in 1-1.1 66 | usr/bin/vim 67 | chaotic-aur/neovim-symlinks 5-1 68 | usr/bin/vim 69 | chaotic-aur/radare2-git 5.9.8.r455.ge75c95a-1 70 | usr/share/doc/radare2/vim 71 | usr/share/radare2/5.9.9/magic/vim 72 | == TIME REPORT FOR pacman -F vim == 73 | User: 3.24s System: 1.17s Total: 4.423s 74 | CPU: 99% Mem: 2935 MiB 75 | 76 | >>> time pacfiles -F vim 77 | extra/gvim 9.1.1165-1 78 | usr/bin/vim 79 | extra/radare2 5.9.8-1 80 | usr/share/doc/radare2/vim 81 | usr/share/radare2/5.9.8/magic/vim 82 | extra/rizin 0.7.4-1 83 | usr/share/rizin/magic/vim 84 | extra/vim 9.1.1165-1 85 | usr/bin/vim 86 | archlinuxcn/gvim-lily 9.1.1163-1 [installed: 9.1.1144-1] 87 | usr/bin/vim 88 | archlinuxcn/vim-lily 9.1.1163-1 89 | usr/bin/vim 90 | chaotic-aur/cheat 4.4.2-3 91 | usr/share/cheat/cheatsheets/community/vim 92 | chaotic-aur/neovim-drop-in 1-1.1 93 | usr/bin/vim 94 | chaotic-aur/neovim-symlinks 5-1 95 | usr/bin/vim 96 | chaotic-aur/radare2-git 5.9.8.r455.ge75c95a-1 97 | usr/share/doc/radare2/vim 98 | usr/share/radare2/5.9.9/magic/vim 99 | == TIME REPORT FOR pacfiles -F vim == 100 | User: 5.09s System: 0.13s Total: 0.378s 101 | CPU: 1383% Mem: 14 MiB 102 | ``` 103 | 104 | List package contents: 105 | 106 | ``` 107 | >>> time pacman -Fl vim >/dev/null 108 | == TIME REPORT FOR pacman -Fl vim > /dev/null == 109 | User: 0.94s System: 0.31s Total: 1.260s 110 | CPU: 99% Mem: 821 MiB 111 | 112 | >>> time pacfiles -Fl vim >/dev/null 113 | == TIME REPORT FOR pacfiles -Fl vim > /dev/null == 114 | User: 0.02s System: 0.02s Total: 0.039s 115 | CPU: 99% Mem: 14 MiB 116 | ``` 117 | -------------------------------------------------------------------------------- /src/build.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 lilydjwg 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | use std::ffi::OsStr; 18 | use std::process::Command; 19 | use std::path::PathBuf; 20 | use std::fs::{File, self}; 21 | use std::os::unix::fs::PermissionsExt; 22 | use std::io::{BufReader, Write, BufWriter, ErrorKind}; 23 | 24 | use eyre::Result; 25 | use tracing::{info, error}; 26 | use compress_tools::ArchiveContents; 27 | 28 | pub fn refresh(force: bool) -> Result<()> { 29 | info!("running pacman command"); 30 | let mut child = Command::new("pacman") 31 | .arg(if force { "-Fyy" } else { "-Fy" }) 32 | .spawn()?; 33 | let st = child.wait()?; 34 | if !st.success() { 35 | return Err(eyre::eyre!("pacman exits with error: {st}")); 36 | } 37 | 38 | update_db(force)?; 39 | Ok(()) 40 | } 41 | 42 | pub fn update_db(force: bool) -> Result<()> { 43 | for entry in std::fs::read_dir("/var/lib/pacman/sync")? { 44 | let entry = entry?; 45 | let path = entry.path(); 46 | 47 | if path.extension() != Some(OsStr::new("files")) { 48 | continue; 49 | } 50 | 51 | process_repo(path, force)?; 52 | } 53 | 54 | Ok(()) 55 | } 56 | 57 | fn process_repo(path: PathBuf, force: bool) -> Result<()> { 58 | let repo_name = path.file_stem().expect("unexpected .files filename") 59 | .to_str().expect("non-utf-8 .files filename?"); 60 | print!("plocate-build {}.pacfiles ...", repo_name); 61 | let _ = std::io::stdout().flush(); 62 | 63 | let target_path = path.with_extension("pacfiles"); 64 | 65 | if !force { 66 | match target_path.metadata() { 67 | Ok(target_stat) => { 68 | let files_mtime = path.metadata()?.modified()?; 69 | if target_stat.modified()? > files_mtime { 70 | println!(" fresh."); 71 | return Ok(()); 72 | } 73 | } 74 | Err(e) if e.kind() == ErrorKind::NotFound => { }, 75 | Err(e) => { return Err(e.into()); } 76 | } 77 | } 78 | 79 | let f = File::open(&path)?; 80 | let f = BufReader::new(f); 81 | let ai = compress_tools::ArchiveIterator::from_read(f)?; 82 | 83 | let tmpfile = tempfile::NamedTempFile::new()?; 84 | 85 | { 86 | let mut f = BufWriter::new(tmpfile.as_file()); 87 | let mut buffer = Vec::new(); 88 | let mut pkg = String::new(); 89 | let mut is_files = false; 90 | 91 | for a in ai { 92 | match a { 93 | ArchiveContents::StartOfEntry(name, _) => { 94 | if !name.ends_with("/files") { 95 | is_files = false; 96 | continue; 97 | } 98 | pkg += name.split_once('/').unwrap().0; 99 | is_files = true; 100 | }, 101 | 102 | ArchiveContents::EndOfEntry => { 103 | match std::str::from_utf8(&buffer) { 104 | Ok(s) => { 105 | output_files(&mut f, &pkg, s)?; 106 | } 107 | Err(e) => { 108 | error!(%pkg, "files content is not utf-8 encoded: {:?}", e); 109 | } 110 | } 111 | buffer.clear(); 112 | pkg.clear(); 113 | }, 114 | 115 | ArchiveContents::DataChunk(data) => { 116 | if is_files { 117 | buffer.extend_from_slice(&data); 118 | } 119 | }, 120 | 121 | ArchiveContents::Err(e) => { 122 | return Err(e.into()); 123 | }, 124 | } 125 | } 126 | } 127 | 128 | info!("calling plocate-build"); 129 | let tmp_path = tmpfile.into_temp_path(); 130 | let mut child = Command::new("plocate-build") 131 | .args(["-p", "-l", "no", 132 | tmp_path.as_os_str().to_str().unwrap(), 133 | target_path.as_os_str().to_str().unwrap(), 134 | ]) 135 | .spawn()?; 136 | let st = child.wait()?; 137 | if !st.success() { 138 | return Err(eyre::eyre!("plocate-build exits with error: {st}")); 139 | } 140 | 141 | let perm = fs::Permissions::from_mode(0o644); 142 | fs::set_permissions(target_path, perm)?; 143 | println!(" done."); 144 | 145 | Ok(()) 146 | } 147 | 148 | fn output_files( 149 | mut f: W, 150 | pkg: &str, 151 | contents: &str, 152 | ) -> Result<()> { 153 | for line in contents.lines().skip(1) { 154 | writeln!(f, "{pkg}/{line}")?; 155 | } 156 | 157 | Ok(()) 158 | } 159 | -------------------------------------------------------------------------------- /src/files.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 lilydjwg 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | use std::process::{Command, Stdio, Child, ChildStdout}; 18 | use std::io::{BufReader, BufRead, Result as IoResult}; 19 | 20 | use tracing::{debug, error}; 21 | 22 | pub struct Plocate { 23 | process: Child, 24 | bufreader: BufReader, 25 | } 26 | 27 | pub struct PackageFile { 28 | line: String, 29 | version_start: usize, 30 | filepath_start: usize, 31 | } 32 | 33 | impl Plocate { 34 | pub fn new(db: &str, pattern: &str, regex: bool, basename: bool) -> IoResult { 35 | debug!("Plocate::new({db}, {pattern}, {regex}, {basename}"); 36 | let mut cmd = Command::new("plocate"); 37 | if regex { 38 | cmd.arg("--regex"); 39 | } 40 | if basename { 41 | cmd.arg("-b"); 42 | } 43 | let mut process = cmd 44 | .args(["-d", db, "-N", "--", pattern]) 45 | .stdout(Stdio::piped()) 46 | .stderr(Stdio::null()) 47 | .spawn()?; 48 | let bufreader = BufReader::new(process.stdout.take().unwrap()); 49 | Ok(Plocate { process, bufreader }) 50 | } 51 | } 52 | 53 | impl Iterator for Plocate { 54 | type Item = IoResult; 55 | fn next(&mut self) -> Option { 56 | let mut line = String::new(); 57 | match self.bufreader.read_line(&mut line) { 58 | Ok(0) => { 59 | match self.process.wait() { 60 | Ok(st) => { 61 | if !st.success() && st.code() != Some(1) { 62 | // exit 1 => not found 63 | error!("plocate exited with error: {}", st); 64 | } 65 | } 66 | Err(e) => { 67 | error!("failed to wait plocate: {:?}", e); 68 | } 69 | } 70 | None 71 | } 72 | Ok(_) => { 73 | if line.ends_with('\n') { 74 | line.pop(); 75 | } 76 | Some(Ok(PackageFile::new(line))) 77 | } 78 | Err(e) => Some(Err(e)), 79 | } 80 | } 81 | } 82 | 83 | impl PackageFile { 84 | pub fn new(line: String) -> Self { 85 | let (pkgpart, _filepath) = line.split_once('/').unwrap(); 86 | let filepath_start = pkgpart.len() + 1; 87 | 88 | debug!("line: {}", line); 89 | let mut it = pkgpart.rsplitn(3, '-'); 90 | it.next().unwrap(); // pkgrel 91 | it.next().unwrap(); // pkgver 92 | let pkgname = it.next().unwrap(); 93 | let version_start = pkgname.len() + 1; 94 | 95 | Self { line, version_start, filepath_start } 96 | } 97 | 98 | pub fn pkgname(&self) -> &str { 99 | &self.line[..self.version_start-1] 100 | } 101 | 102 | pub fn version(&self) -> &str { 103 | &self.line[self.version_start..self.filepath_start-1] 104 | } 105 | 106 | pub fn path(&self) -> &str { 107 | &self.line[self.filepath_start..] 108 | } 109 | } 110 | 111 | #[cfg(test)] 112 | mod test { 113 | #[test] 114 | fn test_package_file() { 115 | let pf = super::PackageFile::new(String::from("vi-1:070224-6/usr/bin/vi")); 116 | assert_eq!(pf.pkgname(), "vi"); 117 | assert_eq!(pf.version(), "1:070224-6"); 118 | assert_eq!(pf.path(), "usr/bin/vi"); 119 | } 120 | } 121 | 122 | pub fn foreach_database(mut f: impl FnMut(String) -> IoResult<()>) -> IoResult<()> { 123 | let output = Command::new("pacman-conf") 124 | .arg("-l") 125 | .stdout(Stdio::piped()) 126 | .output()?; 127 | let repos = String::from_utf8(output.stdout).unwrap(); 128 | for repo in repos.split_terminator('\n') { 129 | let path = format!("/var/lib/pacman/sync/{repo}.pacfiles"); 130 | f(path)?; 131 | } 132 | Ok(()) 133 | } 134 | -------------------------------------------------------------------------------- /src/installed.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 lilydjwg 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | use std::collections::HashMap; 18 | use std::io::Result as IoResult; 19 | 20 | pub struct InstalledPackages { 21 | packages: HashMap, 22 | } 23 | 24 | impl InstalledPackages { 25 | pub fn new() -> IoResult { 26 | let mut packages = HashMap::new(); 27 | for entry in std::fs::read_dir("/var/lib/pacman/local")? { 28 | let entry = entry?; 29 | let path = entry.path(); 30 | 31 | if !path.is_dir() { 32 | continue; 33 | } 34 | 35 | let name = path.file_name().unwrap().to_str().unwrap(); 36 | 37 | let mut it = name.rsplitn(3, '-'); 38 | it.next().unwrap(); // pkgrel 39 | it.next().unwrap(); // pkgver 40 | let pkgname = it.next().unwrap(); 41 | let version = &name[pkgname.len()+1..]; 42 | packages.insert(String::from(pkgname), String::from(version)); 43 | } 44 | Ok(Self { packages }) 45 | } 46 | 47 | pub fn package_version(&self, pkgname: &str) -> Option<&str> { 48 | self.packages.get(pkgname).map(|x| x.as_str()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/list.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 lilydjwg 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | use std::io::{stdout, StdoutLock, Write, Result as IoResult}; 18 | 19 | use nu_ansi_term::{Style, Color}; 20 | 21 | use crate::files; 22 | 23 | pub fn list_packages(packages: &[String], quiet: bool) -> IoResult<()> { 24 | let mut found = false; 25 | for pkg in packages { 26 | found = list_repo_package_files(pkg, quiet)? || found; 27 | } 28 | 29 | if !found { 30 | std::process::exit(1); 31 | } 32 | 33 | Ok(()) 34 | } 35 | 36 | fn list_repo_package_files(pkg: &str, quiet: bool) -> IoResult { 37 | let (repo, pkgname) = if let Some((r, pkgname)) = pkg.split_once('/') { 38 | (Some(r), pkgname) 39 | } else { 40 | (None, pkg) 41 | }; 42 | 43 | let mut found = false; 44 | let pattern = format!("{}-*", pkgname); 45 | let mut stdout = stdout().lock(); 46 | if let Some(repo) = repo { 47 | let path = format!("/var/lib/pacman/sync/{}.pacfiles", repo); 48 | let plocate = files::Plocate::new(&path, &pattern, false, false)?; 49 | found = output_plocate(&mut stdout, plocate, pkgname, quiet)? || found; 50 | } else { 51 | files::foreach_database(|path| { 52 | let plocate = files::Plocate::new(&path, &pattern, false, false)?; 53 | found = output_plocate(&mut stdout, plocate, pkgname, quiet)? || found; 54 | Ok(()) 55 | })?; 56 | } 57 | if !found { 58 | eprintln!("{} package '{}' was not found", 59 | Color::Red.bold().paint("error:"), 60 | pkg, 61 | ); 62 | } 63 | Ok(found) 64 | } 65 | 66 | fn output_plocate( 67 | stdout: &mut StdoutLock, 68 | plocate: files::Plocate, 69 | pkgname: &str, 70 | quiet: bool, 71 | ) -> IoResult { 72 | let mut found = false; 73 | for pf in plocate { 74 | let pf = pf?; 75 | let real_pkgname = pf.pkgname(); 76 | if real_pkgname != pkgname { 77 | continue; 78 | } 79 | let path = pf.path(); 80 | if quiet { 81 | writeln!(stdout, "{}", path)?; 82 | } else { 83 | writeln!(stdout, "{} {}", Style::new().bold().paint(pkgname), path)?; 84 | } 85 | found = true; 86 | } 87 | Ok(found) 88 | } 89 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 lilydjwg 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | use std::io::IsTerminal; 18 | 19 | use tracing_subscriber::EnvFilter; 20 | use clap::{Parser, CommandFactory}; 21 | 22 | mod build; 23 | mod list; 24 | mod files; 25 | mod query_files; 26 | mod installed; 27 | 28 | #[derive(clap::Parser)] 29 | #[command(version, about)] 30 | struct Args { 31 | #[arg(short='F', long)] 32 | /// ignored 33 | files: bool, 34 | 35 | #[arg(short, long)] 36 | /// List the files owned by the queried package. 37 | list: bool, 38 | 39 | #[arg(short='x', long)] 40 | /// Interpret each query as a POSIX extended regular expression. 41 | regex: bool, 42 | 43 | #[arg(short, long)] 44 | /// Do not output colors and file paths 45 | quiet: bool, 46 | 47 | #[arg(short='y', long, action = clap::ArgAction::Count)] 48 | /// Refresh & rebuild databases; give twice to force 49 | refresh: u8, 50 | 51 | #[arg(long, action = clap::ArgAction::Count)] 52 | /// Rebuild databases only without refreshing; give twice to force 53 | update_db: u8, 54 | 55 | #[arg(value_name="QUERY")] 56 | /// The query; unlike pacman, globs (*?[]) are supported in non-regex mode 57 | query: Vec, 58 | } 59 | 60 | fn main() -> eyre::Result<()> { 61 | let filter = EnvFilter::try_from_default_env() 62 | .unwrap_or_else(|_| EnvFilter::from("warn")); 63 | let isatty = std::io::stderr().is_terminal(); 64 | let fmt = tracing_subscriber::fmt::fmt() 65 | .with_writer(std::io::stderr) 66 | .with_env_filter(filter) 67 | .with_ansi(isatty); 68 | if isatty { 69 | fmt.with_timer(tracing_subscriber::fmt::time::ChronoLocal::new( 70 | String::from("%Y-%m-%d %H:%M:%S%.6f %z"))) 71 | .init(); 72 | } else { 73 | fmt.without_time().init(); 74 | } 75 | 76 | let args = Args::parse(); 77 | 78 | if args.refresh > 2 { 79 | Args::command() 80 | .error(clap::error::ErrorKind::InvalidValue, "refresh can give twice at most") 81 | .exit(); 82 | } 83 | if args.update_db > 2 { 84 | Args::command() 85 | .error(clap::error::ErrorKind::InvalidValue, "update-db can give twice at most") 86 | .exit(); 87 | } 88 | 89 | if args.refresh > 0 { 90 | build::refresh(args.refresh == 2)?; 91 | } else if args.update_db > 0 { 92 | build::update_db(args.update_db == 2)?; 93 | } else if args.query.is_empty() { 94 | Args::command() 95 | .error(clap::error::ErrorKind::MissingRequiredArgument, "no query specified") 96 | .exit(); 97 | } else if args.list { 98 | list::list_packages(&args.query, args.quiet)?; 99 | } else { 100 | query_files::query_files(&args.query, args.regex, args.quiet)?; 101 | } 102 | 103 | Ok(()) 104 | } 105 | 106 | -------------------------------------------------------------------------------- /src/query_files.rs: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2025 lilydjwg 2 | // 3 | // This program is free software; you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation; either version 2 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License along 14 | // with this program; if not, write to the Free Software Foundation, Inc., 15 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | use std::io::{stdout, StdoutLock, Write, Result as IoResult}; 18 | use std::path::Path; 19 | use std::borrow::Cow; 20 | 21 | use nu_ansi_term::{Style, Color}; 22 | 23 | use crate::files; 24 | use crate::installed::InstalledPackages; 25 | 26 | pub fn query_files(queries: &[String], regex: bool, quiet: bool) -> IoResult<()> { 27 | let installed = InstalledPackages::new()?; 28 | for query in queries { 29 | if regex { 30 | query_files_regex(query, quiet, &installed)?; 31 | } else { 32 | query_files_pattern(query, quiet, &installed)?; 33 | } 34 | } 35 | Ok(()) 36 | } 37 | 38 | fn query_files_regex( 39 | pattern: &str, 40 | quiet: bool, 41 | installed: &InstalledPackages, 42 | ) -> IoResult<()> { 43 | let mut stdout = stdout().lock(); 44 | let is_fullpath = pattern.contains('/'); 45 | let mut found = false; 46 | files::foreach_database(|path| { 47 | let plocate = files::Plocate::new(&path, pattern, true, !is_fullpath)?; 48 | found = output_plocate( 49 | &mut stdout, 50 | plocate, 51 | Path::new(&path).file_stem().unwrap().to_str().unwrap(), 52 | quiet, 53 | installed, 54 | None, 55 | )? || found; 56 | Ok(()) 57 | })?; 58 | 59 | if !found { 60 | std::process::exit(1); 61 | } 62 | 63 | Ok(()) 64 | } 65 | 66 | fn query_files_pattern( 67 | pattern: &str, 68 | quiet: bool, 69 | installed: &InstalledPackages, 70 | ) -> IoResult<()> { 71 | if pattern.is_empty() { 72 | return Ok(()); 73 | } 74 | 75 | let mut stdout = stdout().lock(); 76 | let is_fullpath = pattern.contains('/'); 77 | let is_glob = pattern.contains(['*', '?', '[', ']']); 78 | let mut validating_path = None; 79 | let mut modified_pattern = String::new(); 80 | let p = if !is_fullpath && !is_glob { 81 | modified_pattern.push('['); 82 | modified_pattern.push(pattern.chars().next().unwrap()); 83 | modified_pattern.push(']'); 84 | modified_pattern.push_str(&pattern[1..]); 85 | modified_pattern.as_str() 86 | } else if is_fullpath { 87 | modified_pattern.push_str("*/"); 88 | if let Some(stripped) = pattern.strip_prefix('/') { 89 | modified_pattern.push_str(stripped); 90 | if !is_glob { 91 | validating_path = Some(stripped); 92 | } 93 | } else { 94 | modified_pattern.push_str(pattern); 95 | if !is_glob { 96 | validating_path = Some(pattern); 97 | } 98 | } 99 | modified_pattern.as_str() 100 | } else { 101 | pattern 102 | }; 103 | let mut found = false; 104 | files::foreach_database(|path| { 105 | let plocate = files::Plocate::new(&path, p, false, !is_fullpath)?; 106 | found = output_plocate( 107 | &mut stdout, 108 | plocate, 109 | Path::new(&path).file_stem().unwrap().to_str().unwrap(), 110 | quiet, 111 | installed, 112 | validating_path, 113 | )? || found; 114 | Ok(()) 115 | })?; 116 | 117 | if !found { 118 | std::process::exit(1); 119 | } 120 | 121 | Ok(()) 122 | } 123 | 124 | fn output_plocate( 125 | stdout: &mut StdoutLock, 126 | plocate: files::Plocate, 127 | repo: &str, 128 | quiet: bool, 129 | installed: &InstalledPackages, 130 | validating_path: Option<&str>, 131 | ) -> IoResult { 132 | let mut last_pkgname = String::new(); 133 | let mut found = false; 134 | for pf in plocate { 135 | let pf = pf?; 136 | let pkgname = pf.pkgname(); 137 | let same_pkgname = last_pkgname == pkgname; 138 | if same_pkgname && quiet { 139 | continue; 140 | } 141 | let path = pf.path(); 142 | if let Some(p) = validating_path { 143 | if !path.starts_with(p) { 144 | continue; 145 | } 146 | } 147 | if quiet { 148 | writeln!(stdout, "{}/{}", repo, pkgname)?; 149 | } else { 150 | let version = pf.version(); 151 | if validating_path.is_some() { 152 | writeln!(stdout, "{} is owned by {}{} {}", 153 | path, 154 | Color::Magenta.bold().paint(format!("{repo}/")), 155 | Style::new().bold().paint(pkgname), 156 | Color::Green.bold().paint(version), 157 | )?; 158 | } else { 159 | if !same_pkgname { 160 | let installed_version = installed.package_version(pkgname); 161 | if let Some(iv) = installed_version { 162 | let installed_text = if iv == version { 163 | Cow::Borrowed("[installed]") 164 | } else { 165 | Cow::Owned(format!("[installed: {iv}]")) 166 | }; 167 | writeln!(stdout, "{}{} {} {}", 168 | Color::Magenta.bold().paint(format!("{repo}/")), 169 | Style::new().bold().paint(pkgname), 170 | Color::Green.bold().paint(version), 171 | Color::Cyan.bold().paint(installed_text), 172 | )?; 173 | } else { 174 | writeln!(stdout, "{}{} {}", 175 | Color::Magenta.bold().paint(format!("{repo}/")), 176 | Style::new().bold().paint(pkgname), 177 | Color::Green.bold().paint(version), 178 | )?; 179 | } 180 | } 181 | writeln!(stdout, " {}", path)?; 182 | } 183 | } 184 | if !same_pkgname { 185 | last_pkgname.clear(); 186 | last_pkgname.push_str(pkgname) 187 | } 188 | found = true; 189 | } 190 | Ok(found) 191 | } 192 | --------------------------------------------------------------------------------