mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-23 21:34:18 +08:00
Merge branch 'diff-update' into 'master'
Update pkg, implement REPO_BINARY auto update See merge request redox-os/redox!1989
This commit is contained in:
commit
226c5c88aa
218
Cargo.lock
generated
218
Cargo.lock
generated
@ -36,15 +36,6 @@ dependencies = [
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.100"
|
||||
@ -57,35 +48,12 @@ version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
@ -94,31 +62,17 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||
|
||||
[[package]]
|
||||
name = "blake3"
|
||||
version = "0.3.8"
|
||||
version = "1.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3"
|
||||
checksum = "2468ef7d57b3fb7e16b576e8377cdbde2320c60e1491e961d11da40fc4f02a2d"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec 0.5.2",
|
||||
"arrayvec",
|
||||
"cc",
|
||||
"cfg-if 0.1.10",
|
||||
"constant_time_eq 0.1.5",
|
||||
"crypto-mac",
|
||||
"digest 0.9.0",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blake3"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec 0.7.6",
|
||||
"cc",
|
||||
"cfg-if 1.0.4",
|
||||
"constant_time_eq 0.3.1",
|
||||
"cfg-if",
|
||||
"constant_time_eq",
|
||||
"cpufeatures",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -185,12 +139,6 @@ dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
@ -203,7 +151,7 @@ version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"cipher",
|
||||
"cpufeatures",
|
||||
]
|
||||
@ -219,21 +167,6 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags 1.3.2",
|
||||
"strsim 0.8.0",
|
||||
"textwrap",
|
||||
"unicode-width 0.1.14",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.8.1"
|
||||
@ -241,7 +174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"itoa",
|
||||
"rustversion",
|
||||
"ryu",
|
||||
@ -250,15 +183,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
|
||||
checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
@ -275,7 +202,7 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -322,23 +249,13 @@ dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "4.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"curve25519-dalek-derive",
|
||||
"fiat-crypto",
|
||||
@ -378,7 +295,7 @@ dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim 0.11.1",
|
||||
"strsim",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@ -393,15 +310,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@ -439,7 +347,7 @@ version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e73e0fee365832cd9b9a53ea62f944cc0d7a4c71f2b9c96a28fc74749517afa"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"bitflags",
|
||||
"chacha20",
|
||||
"curve25519-dalek",
|
||||
"generic-array",
|
||||
@ -515,7 +423,7 @@ version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
]
|
||||
@ -526,7 +434,7 @@ version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
]
|
||||
@ -567,15 +475,6 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
@ -681,7 +580,7 @@ version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"bitflags",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
]
|
||||
@ -701,6 +600,15 @@ dependencies = [
|
||||
"hashbrown 0.15.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lzma-rust2"
|
||||
version = "0.16.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47bb1e988e6fb779cf720ad431242d3f03167c1b3f2b1aae7f1a94b2495b36ae"
|
||||
dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
@ -789,13 +697,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pkgar"
|
||||
version = "0.1.19"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgar.git#e265d32cc0bb149a9574d4500e5409cbb8b662d5"
|
||||
version = "0.2.1"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgar.git#b544d6b6612b58524de2ea9d857c5a349f1c99e2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"blake3 0.3.8",
|
||||
"blake3",
|
||||
"bytemuck",
|
||||
"clap",
|
||||
"lzma-rust2",
|
||||
"pkgar-core",
|
||||
"pkgar-keys",
|
||||
"thiserror 2.0.17",
|
||||
@ -803,22 +710,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "pkgar-core"
|
||||
version = "0.1.19"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgar.git#e265d32cc0bb149a9574d4500e5409cbb8b662d5"
|
||||
version = "0.2.1"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgar.git#b544d6b6612b58524de2ea9d857c5a349f1c99e2"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"blake3 0.3.8",
|
||||
"bitflags",
|
||||
"blake3",
|
||||
"bytemuck",
|
||||
"dryoc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkgar-keys"
|
||||
version = "0.1.19"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgar.git#e265d32cc0bb149a9574d4500e5409cbb8b662d5"
|
||||
version = "0.2.1"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgar.git#b544d6b6612b58524de2ea9d857c5a349f1c99e2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"dirs",
|
||||
"hex",
|
||||
"lazy_static",
|
||||
@ -863,7 +768,7 @@ version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"indoc",
|
||||
@ -878,16 +783,6 @@ dependencies = [
|
||||
"unicode-width 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.13.0"
|
||||
@ -900,10 +795,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox-pkg"
|
||||
version = "0.2.9"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgutils.git#cbf88111fab76b8bfd688f144f7cc000408b180e"
|
||||
version = "0.3.0"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/pkgutils.git#80e0196ef0ef940ca2b243d3c10ffecbd37f11cc"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
"ignore",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@ -917,7 +812,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi-to-tui",
|
||||
"anyhow",
|
||||
"blake3 1.5.3",
|
||||
"blake3",
|
||||
"globset",
|
||||
"ignore",
|
||||
"libc",
|
||||
@ -957,7 +852,7 @@ version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1109,9 +1004,9 @@ version = "0.10.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.10.7",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1153,12 +1048,6 @@ dependencies = [
|
||||
"vte",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
@ -1214,15 +1103,6 @@ dependencies = [
|
||||
"numtoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width 0.1.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
@ -1310,7 +1190,7 @@ version = "1.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.4",
|
||||
"cfg-if",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
@ -1355,12 +1235,6 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
|
||||
@ -31,8 +31,7 @@ tui = ["ratatui", "ansi-to-tui", "strip-ansi-escapes"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
# blake3 1.5.4 is incompatible with 0.3 dependency from pkgar
|
||||
blake3 = "=1.5.3"
|
||||
blake3 = "1"
|
||||
globset = "0.4"
|
||||
libc = "0.2"
|
||||
ignore = "0.4"
|
||||
|
||||
@ -1631,8 +1631,8 @@ fn run_tui_cook(
|
||||
kill_everything();
|
||||
}
|
||||
|
||||
fetcher_handle.join().unwrap();
|
||||
cooker_handle.join().unwrap();
|
||||
let _ = fetcher_handle.join();
|
||||
let _ = cooker_handle.join();
|
||||
|
||||
Ok(app.dump_logs_on_exit)
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@ use cookbook::cook::ident::{get_ident, init_ident};
|
||||
use cookbook::cook::{fetch, package as cook_package};
|
||||
use cookbook::recipe::CookRecipe;
|
||||
use cookbook::web::{CliWebConfig, generate_web};
|
||||
use pkg::package::{Repository, SourceIdentifier};
|
||||
use pkg::{Package, PackageName, recipes};
|
||||
use pkg::{Repository, SourceIdentifier};
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// avoid confusion with build.rs
|
||||
pub mod cook_build;
|
||||
pub mod fetch;
|
||||
pub mod fetch_repo;
|
||||
pub mod fs;
|
||||
pub mod ident;
|
||||
pub mod package;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use pkg::package::PackageError;
|
||||
use pkg::PackageError;
|
||||
use pkg::{Package, PackageName};
|
||||
|
||||
use crate::config::CookConfig;
|
||||
@ -555,14 +555,7 @@ fn build_deps_dir(
|
||||
&tags_dir,
|
||||
&dep_pkgars
|
||||
.iter()
|
||||
.map(|(name, _)| {
|
||||
// TODO: without_host should just return as_str
|
||||
if name.is_host() {
|
||||
&name.as_str()["host:".len()..]
|
||||
} else {
|
||||
name.as_str()
|
||||
}
|
||||
})
|
||||
.map(|(name, _)| name.without_host())
|
||||
.collect(),
|
||||
)?
|
||||
{
|
||||
@ -588,7 +581,7 @@ fn build_deps_dir(
|
||||
|
||||
let pkey_path = "build/id_ed25519.pub.toml";
|
||||
for (name, archive_path) in dep_pkgars {
|
||||
let tag_file = tags_dir.join(name.without_host().as_str());
|
||||
let tag_file = tags_dir.join(name.without_prefix());
|
||||
fs::write(&tag_file, "")
|
||||
.map_err(|e| format!("failed to write tag file {}: {:?}", tag_file.display(), e))?;
|
||||
pkgar::extract(pkey_path, &archive_path, deps_dir_tmp.to_str().unwrap()).map_err(
|
||||
@ -665,7 +658,7 @@ pub fn build_remote(
|
||||
cook_config: &CookConfig,
|
||||
) -> Result<(Vec<PathBuf>, BTreeSet<PackageName>), String> {
|
||||
let source_toml = target_dir.join("source.toml");
|
||||
let source_pubkey = target_dir.join("id_ed25519.pub.toml");
|
||||
let source_pubkey = "build/remotes/pub_key_static.redox-os.org.toml";
|
||||
|
||||
let packages = recipe.get_packages_list();
|
||||
for (i, package) in packages.into_iter().enumerate() {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
use pkg::package::SourceIdentifier;
|
||||
|
||||
use crate::REMOTE_PKG_SOURCE;
|
||||
use crate::config::translate_mirror;
|
||||
use crate::cook::fetch_repo;
|
||||
use crate::cook::fetch_repo::PlainPtyCallback;
|
||||
use crate::cook::fs::*;
|
||||
use crate::cook::package::get_package_name;
|
||||
use crate::cook::package::package_source_paths;
|
||||
@ -12,11 +11,15 @@ use crate::log_to_pty;
|
||||
use crate::recipe::BuildKind;
|
||||
use crate::recipe::CookRecipe;
|
||||
use crate::{blake3, recipe::SourceRecipe};
|
||||
use pkg::SourceIdentifier;
|
||||
use pkg::net_backend::DownloadBackendWriter;
|
||||
use std::cell::RefCell;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub(crate) fn get_blake3(path: &PathBuf, show_progress: bool) -> Result<String, String> {
|
||||
if show_progress {
|
||||
@ -507,34 +510,16 @@ pub(crate) fn fetch_cargo(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_remote_url(name: &str, ext: &str) -> String {
|
||||
return format!(
|
||||
"{}/{}/{}.{}",
|
||||
REMOTE_PKG_SOURCE,
|
||||
redoxer::target(),
|
||||
name,
|
||||
ext
|
||||
);
|
||||
}
|
||||
|
||||
fn get_pubkey_url() -> String {
|
||||
return format!("{}/id_ed25519.pub.toml", REMOTE_PKG_SOURCE);
|
||||
}
|
||||
|
||||
pub fn fetch_remote(
|
||||
recipe_dir: &Path,
|
||||
recipe: &CookRecipe,
|
||||
offline_mode: bool,
|
||||
logger: &PtyOut,
|
||||
) -> Result<(), String> {
|
||||
let (mut manager, repository) = fetch_repo::get_binary_repo();
|
||||
let target_dir = create_target_dir(recipe_dir, recipe.target)?;
|
||||
let source_pubkey = target_dir.join("id_ed25519.pub.toml");
|
||||
if !offline_mode {
|
||||
download_wget(&get_pubkey_url(), &source_pubkey, logger)?;
|
||||
} else {
|
||||
offline_check_exists(&source_pubkey)?;
|
||||
}
|
||||
|
||||
let writer = logger.as_ref().unwrap().1.try_clone().unwrap();
|
||||
manager.set_callback(Rc::new(RefCell::new(PlainPtyCallback::new(writer))));
|
||||
let packages = recipe.recipe.get_packages_list();
|
||||
|
||||
let name = recipe_dir
|
||||
@ -546,15 +531,47 @@ pub fn fetch_remote(
|
||||
for package in packages {
|
||||
let (_, source_pkgar, source_toml) = package_source_paths(package, &target_dir);
|
||||
let source_name = get_package_name(name, package);
|
||||
let Some(repo_blake3) = repository.packages.get(&source_name) else {
|
||||
return Err(format!(
|
||||
"Package {source_name} does not exist in server repository"
|
||||
));
|
||||
};
|
||||
|
||||
if !offline_mode {
|
||||
//TODO: Check freshness
|
||||
download_wget(
|
||||
&get_remote_url(&source_name, "pkgar"),
|
||||
&source_pkgar,
|
||||
logger,
|
||||
)?;
|
||||
download_wget(&get_remote_url(&source_name, "toml"), &source_toml, logger)?;
|
||||
if source_toml.is_file() {
|
||||
let pkg_toml = read_source_toml(&source_toml)?;
|
||||
if &pkg_toml.blake3 != repo_blake3 {
|
||||
log_to_pty!(logger, "DEBUG: Updating source binaries");
|
||||
remove_all(&source_toml)?;
|
||||
if source_pkgar.is_file() {
|
||||
remove_all(&source_pkgar)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !source_toml.is_file() {
|
||||
{
|
||||
let toml_file = File::create(&source_toml)
|
||||
.map_err(|e| format!("Unable to create source.toml: {e:?}"))?;
|
||||
let mut writer = DownloadBackendWriter::ToFile(toml_file);
|
||||
manager
|
||||
.download(&format!("{}.toml", &source_name), None, &mut writer)
|
||||
.map_err(|e| format!("Unable to download source.toml: {e:?}"))?;
|
||||
}
|
||||
let pkg_toml = read_source_toml(&source_toml)?;
|
||||
let pkgar_file = File::create(&source_pkgar)
|
||||
.map_err(|e| format!("Unable to create source.pkgar: {e:?}"))?;
|
||||
let mut writer = DownloadBackendWriter::ToFile(pkgar_file);
|
||||
manager
|
||||
.download(
|
||||
&format!("{}.pkgar", &source_name),
|
||||
Some(pkg_toml.network_size),
|
||||
&mut writer,
|
||||
)
|
||||
.map_err(|e| format!("Unable to download source.pkgar: {e:?}"))?;
|
||||
}
|
||||
|
||||
// manager.download(file, 0, dest)
|
||||
} else {
|
||||
offline_check_exists(&source_pkgar)?;
|
||||
offline_check_exists(&source_toml)?;
|
||||
@ -562,14 +579,7 @@ pub fn fetch_remote(
|
||||
|
||||
// guaranteed to exist once
|
||||
if package.is_none() {
|
||||
let mut file = File::open(&source_toml)
|
||||
.map_err(|e| format!("Unable to open source.toml: {e:?}"))?;
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)
|
||||
.map_err(|e| format!("Unable to read source.toml: {e:?}"))?;
|
||||
|
||||
let pkg_toml = pkg::Package::from_toml(&contents)
|
||||
.map_err(|e| format!("Unable to parse source.toml: {e:?}"))?;
|
||||
let pkg_toml = read_source_toml(&source_toml)?;
|
||||
|
||||
fetch_apply_source_info_from_remote(
|
||||
recipe,
|
||||
@ -586,6 +596,17 @@ pub fn fetch_remote(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_source_toml(source_toml: &Path) -> Result<pkg::Package, String> {
|
||||
let mut file =
|
||||
File::open(source_toml).map_err(|e| format!("Unable to open source.toml: {e:?}"))?;
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)
|
||||
.map_err(|e| format!("Unable to read source.toml: {e:?}"))?;
|
||||
let pkg_toml = pkg::Package::from_toml(&contents)
|
||||
.map_err(|e| format!("Unable to parse source.toml: {e:?}"))?;
|
||||
Ok(pkg_toml)
|
||||
}
|
||||
|
||||
pub(crate) fn fetch_is_patches_newer(
|
||||
recipe_dir: &Path,
|
||||
patches: &Vec<String>,
|
||||
@ -657,7 +678,7 @@ pub(crate) fn fetch_apply_source_info(
|
||||
source_identifier: String,
|
||||
) -> Result<(), String> {
|
||||
let ident = crate::cook::ident::get_ident();
|
||||
let info = pkg::package::SourceIdentifier {
|
||||
let info = SourceIdentifier {
|
||||
commit_identifier: ident.commit.to_string(),
|
||||
time_identifier: ident.time.to_string(),
|
||||
source_identifier: source_identifier,
|
||||
@ -668,7 +689,7 @@ pub(crate) fn fetch_apply_source_info(
|
||||
|
||||
pub(crate) fn fetch_apply_source_info_from_remote(
|
||||
recipe: &CookRecipe,
|
||||
info: &pkg::package::SourceIdentifier,
|
||||
info: &SourceIdentifier,
|
||||
) -> Result<(), String> {
|
||||
let target_dir = create_target_dir(&recipe.dir, recipe.target)?;
|
||||
let source_toml_path = target_dir.join("source_info.toml");
|
||||
|
||||
204
src/cook/fetch_repo.rs
Normal file
204
src/cook/fetch_repo.rs
Normal file
@ -0,0 +1,204 @@
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
io::{PipeWriter, Write},
|
||||
path::{Path, PathBuf},
|
||||
rc::Rc,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use pkg::{
|
||||
PackageName, RemotePackage, RepoManager, Repository,
|
||||
callback::{Callback, SilentCallback},
|
||||
net_backend::{CurlBackend, DownloadBackend},
|
||||
};
|
||||
|
||||
// TODO: This is a workaround, but as long as whole
|
||||
// fetch operation is in single thread, this is ok
|
||||
thread_local! {
|
||||
static BINARY_REPO: RefCell<Option<(RepoManager, Repository)>> = RefCell::new(None);
|
||||
}
|
||||
|
||||
fn load_cached_repo(path: &Path) -> Option<Repository> {
|
||||
let metadata = std::fs::metadata(path).ok()?;
|
||||
|
||||
if !crate::config::get_config().cook.offline {
|
||||
let yesterday = std::time::SystemTime::now().checked_sub(Duration::from_secs(24 * 3600))?;
|
||||
if metadata.modified().ok()? < yesterday {
|
||||
// stale cache
|
||||
let _ = std::fs::remove_file(path);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
let toml_str = std::fs::read_to_string(path).ok()?;
|
||||
Repository::from_toml(&toml_str).ok()
|
||||
}
|
||||
|
||||
fn init_binary_repo() -> (RepoManager, Repository) {
|
||||
let callback = Rc::new(RefCell::new(SilentCallback::new()));
|
||||
let download_backend = CurlBackend::new().expect("Curl not found");
|
||||
let mut repo = RepoManager::new(callback, Box::new(download_backend));
|
||||
|
||||
repo.add_remote(crate::REMOTE_PKG_SOURCE, redoxer::target())
|
||||
.expect("Unable to add remote");
|
||||
|
||||
let repo_path = PathBuf::from("build/remotes");
|
||||
repo.set_download_path(repo_path.clone());
|
||||
repo.sync_keys().expect("Unable to sync keys");
|
||||
|
||||
let repo_toml = load_cached_repo(&repo_path.join("repo.toml")).unwrap_or_else(|| {
|
||||
let (toml_str, _) = repo
|
||||
.get_package_toml(&PackageName::new("repo").unwrap())
|
||||
.expect("Failed to fetch repo.toml");
|
||||
Repository::from_toml(&toml_str).expect("Fetched repo.toml is invalid")
|
||||
});
|
||||
|
||||
(repo, repo_toml)
|
||||
}
|
||||
|
||||
pub fn get_binary_repo() -> (RepoManager, Repository) {
|
||||
BINARY_REPO.with(|cell| {
|
||||
let mut opt = cell.borrow_mut();
|
||||
if opt.is_none() {
|
||||
*opt = Some(init_binary_repo());
|
||||
}
|
||||
let (repo, repo_toml) = opt.as_ref().unwrap();
|
||||
((*repo).clone(), repo_toml.clone())
|
||||
})
|
||||
}
|
||||
|
||||
pub struct PlainPtyCallback {
|
||||
size: u64,
|
||||
unknown_size: bool,
|
||||
pos: u64,
|
||||
fetch_processed: usize,
|
||||
fetch_total: usize,
|
||||
interactive: bool,
|
||||
download_file: Option<String>,
|
||||
pty: PipeWriter,
|
||||
}
|
||||
|
||||
impl PlainPtyCallback {
|
||||
pub fn new(pty: PipeWriter) -> Self {
|
||||
Self {
|
||||
size: 0,
|
||||
unknown_size: false,
|
||||
pos: 0,
|
||||
fetch_processed: 0,
|
||||
fetch_total: 0,
|
||||
interactive: false,
|
||||
download_file: None,
|
||||
pty,
|
||||
}
|
||||
}
|
||||
|
||||
/// Set if user require to agree on terminal
|
||||
pub fn set_interactive(&mut self, enabled: bool) {
|
||||
self.interactive = enabled;
|
||||
}
|
||||
|
||||
fn flush(&self) {
|
||||
let _ = std::io::stderr().flush();
|
||||
}
|
||||
|
||||
pub fn format_size(bytes: u64) -> String {
|
||||
if bytes == 0 {
|
||||
return "0 B".to_string();
|
||||
}
|
||||
const UNITS: [&str; 5] = ["B", "KiB", "MiB", "GiB", "TiB"];
|
||||
let i = (bytes as f64).log(1024.0).floor() as usize;
|
||||
let size = bytes as f64 / 1024.0_f64.powi(i as i32);
|
||||
format!("{:.2} {}", size, UNITS[i])
|
||||
}
|
||||
|
||||
fn downloading_str(&self) -> &'static str {
|
||||
"Downloading"
|
||||
}
|
||||
}
|
||||
|
||||
const RESET_LINE: &str = "\r\x1b[2K";
|
||||
|
||||
impl Callback for PlainPtyCallback {
|
||||
fn fetch_start(&mut self, initial_count: usize) {
|
||||
self.fetch_total = 0;
|
||||
self.fetch_processed = 0;
|
||||
self.fetch_package_increment(0, initial_count);
|
||||
}
|
||||
|
||||
fn fetch_package_name(&mut self, pkg_name: &PackageName) {
|
||||
// resuming after fetch_package_increment
|
||||
let _ = write!(&self.pty, " {}", pkg_name.as_str());
|
||||
self.flush();
|
||||
}
|
||||
|
||||
fn fetch_package_increment(&mut self, added_processed: usize, added_count: usize) {
|
||||
self.fetch_processed += added_processed;
|
||||
self.fetch_total += added_count;
|
||||
|
||||
let _ = write!(
|
||||
&self.pty,
|
||||
"{RESET_LINE}Fetching: [{}/{}]",
|
||||
self.fetch_processed, self.fetch_total
|
||||
);
|
||||
self.flush();
|
||||
}
|
||||
|
||||
fn fetch_end(&mut self) {
|
||||
if self.fetch_processed == self.fetch_total {
|
||||
let _ = writeln!(&self.pty, "{RESET_LINE}Fetch complete.");
|
||||
} else {
|
||||
let _ = writeln!(&self.pty, "{RESET_LINE}Fetch incomplete.");
|
||||
}
|
||||
}
|
||||
|
||||
fn download_start(&mut self, length: u64, file: &str) {
|
||||
self.size = length;
|
||||
self.unknown_size = length == 0;
|
||||
self.pos = 0;
|
||||
if !self.unknown_size {
|
||||
let _ = write!(&self.pty, "{RESET_LINE}{} {file}", self.downloading_str());
|
||||
self.download_file = Some(file.to_string());
|
||||
self.flush();
|
||||
}
|
||||
}
|
||||
|
||||
fn download_increment(&mut self, downloaded: u64) {
|
||||
self.pos += downloaded;
|
||||
if self.unknown_size {
|
||||
self.size += downloaded;
|
||||
}
|
||||
if self.unknown_size {
|
||||
return;
|
||||
}
|
||||
|
||||
// keep using MB for consistency
|
||||
let pos_mb = self.pos as f64 / 1_048_576.0;
|
||||
let size_mb = self.size as f64 / 1_048_576.0;
|
||||
let file_name = self
|
||||
.download_file
|
||||
.as_ref()
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("");
|
||||
let _ = write!(
|
||||
&self.pty,
|
||||
"{RESET_LINE}{} {} [{:.2} MB / {:.2} MB]",
|
||||
self.downloading_str(),
|
||||
file_name,
|
||||
pos_mb,
|
||||
size_mb
|
||||
);
|
||||
self.flush();
|
||||
}
|
||||
|
||||
fn download_end(&mut self) {
|
||||
if !self.unknown_size {
|
||||
let _ = writeln!(&self.pty, "");
|
||||
self.download_file = None;
|
||||
}
|
||||
}
|
||||
|
||||
fn install_extract(&mut self, remote_pkg: &RemotePackage) {
|
||||
let _ = writeln!(&self.pty, "Extracting {}...", remote_pkg.package.name);
|
||||
self.flush();
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use pkg::{Package, PackageName};
|
||||
use pkg::{Package, PackageName, PackagePrefix};
|
||||
|
||||
use crate::{
|
||||
blake3::hash_to_hex,
|
||||
@ -79,7 +79,7 @@ pub fn package(
|
||||
}
|
||||
|
||||
let deps = if package.is_some() {
|
||||
BTreeSet::from([name.without_host()])
|
||||
BTreeSet::from([name.with_prefix(PackagePrefix::Any)])
|
||||
} else {
|
||||
auto_deps.clone()
|
||||
};
|
||||
@ -155,7 +155,7 @@ pub fn package_toml(
|
||||
let ident_source = fetch::fetch_get_source_info(recipe)?;
|
||||
|
||||
let package = Package {
|
||||
name: recipe.name.without_host(),
|
||||
name: recipe.name.with_prefix(PackagePrefix::Any),
|
||||
version: package_version(&recipe.recipe),
|
||||
target: recipe.target.to_string(),
|
||||
blake3: hash,
|
||||
|
||||
@ -5,7 +5,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use pkg::{PackageName, package::PackageError, recipes};
|
||||
use pkg::{PackageError, PackageName, recipes};
|
||||
use regex::Regex;
|
||||
use serde::{
|
||||
Deserialize, Serialize,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user