rb: reapply Red Bear patches on upstream 05bf2eb
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# format_bytes_inner was intentionally inlined as nested fn inner()
|
||||
# inside format_bytes() in lib.rs — RB refactoring, not a bug.
|
||||
src/installer.rs:format_bytes_inner
|
||||
Generated
+425
-376
File diff suppressed because it is too large
Load Diff
+7
-5
@@ -1,9 +1,9 @@
|
||||
[package]
|
||||
name = "redox_installer"
|
||||
version = "0.2.42"
|
||||
version = "0.2.42+rb0.3.1"
|
||||
description = "A Redox filesystem builder"
|
||||
license = "MIT"
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>", "vasilito <adminpupkin@gmail.com>"]
|
||||
repository = "https://gitlab.redox-os.org/redox-os/installer"
|
||||
default-run = "redox_installer"
|
||||
edition = "2021"
|
||||
@@ -34,8 +34,8 @@ pkgar-core = { version = "0.2.2", optional = true }
|
||||
pkgar-keys = { version = "0.2.2", optional = true }
|
||||
rand = { version = "0.9", optional = true }
|
||||
redox-pkg = { version = "0.3.1", features = ["indicatif"], optional = true }
|
||||
redox_syscall = { version = "0.9", optional = true }
|
||||
redoxfs = { version = "0.9.1", optional = true, default-features = false, features = ["std", "log"] }
|
||||
redox_syscall = { path = "../syscall", optional = true }
|
||||
redoxfs = { path = "../redoxfs", optional = true, default-features = false, features = ["std", "log"] }
|
||||
rust-argon2 = { version = "3", optional = true }
|
||||
serde = "1"
|
||||
serde_derive = "1.0"
|
||||
@@ -44,7 +44,7 @@ toml = "0.8"
|
||||
uuid = { version = "1.4", features = ["v4"], optional = true }
|
||||
|
||||
[target.'cfg(target_os = "redox")'.dependencies]
|
||||
libredox = { version = "0.1", optional = true }
|
||||
libredox = { path = "../libredox", optional = true }
|
||||
ring = { version = "=0.17.8", optional = true }
|
||||
|
||||
[features]
|
||||
@@ -72,3 +72,5 @@ fuse = ["redoxfs/fuse"]
|
||||
[patch.crates-io]
|
||||
# https://github.com/briansmith/ring/issues/1999
|
||||
ring = { git = "https://gitlab.redox-os.org/redox-os/ring.git", branch = "redox-0.17.8" }
|
||||
redox_syscall = { path = "../syscall" }
|
||||
libredox = { path = "../libredox" }
|
||||
|
||||
+1
-28
@@ -856,31 +856,4 @@ pub fn install(config: Config, output: impl AsRef<Path>) -> Result<()> {
|
||||
install_inner(config, output.as_ref())
|
||||
}
|
||||
|
||||
/// Convert bytes into readable string
|
||||
pub fn format_bytes(len: u64) -> String {
|
||||
const GB: u64 = 1024 * 1024 * 1024;
|
||||
const MB: u64 = 1024 * 1024;
|
||||
const KB: u64 = 1024;
|
||||
|
||||
if len > GB {
|
||||
format_bytes_inner(len, GB, "GB")
|
||||
} else if len > MB {
|
||||
format_bytes_inner(len, MB, "MB")
|
||||
} else if len > KB {
|
||||
format_bytes_inner(len, KB, "KB")
|
||||
} else {
|
||||
format!("{len} B")
|
||||
}
|
||||
}
|
||||
|
||||
fn format_bytes_inner(len: u64, divisor: u64, suffix: &'static str) -> String {
|
||||
let mut s = format!("{}", len / divisor);
|
||||
if s.len() == 1 {
|
||||
let _ = write!(s, ".{:02}", (len % divisor) / (divisor / 100));
|
||||
} else if s.len() == 2 {
|
||||
let _ = write!(s, ".{:01}", (len % divisor) / (divisor / 10));
|
||||
}
|
||||
|
||||
let _ = write!(s, " {suffix}");
|
||||
s
|
||||
}
|
||||
pub use crate::format_bytes;
|
||||
|
||||
+29
@@ -12,3 +12,32 @@ pub use crate::installer::*;
|
||||
pub use crate::config::file::FileConfig;
|
||||
pub use crate::config::package::PackageConfig;
|
||||
pub use crate::config::Config;
|
||||
|
||||
use core::fmt::Write as _;
|
||||
|
||||
pub fn format_bytes(len: u64) -> String {
|
||||
const GB: u64 = 1024 * 1024 * 1024;
|
||||
const MB: u64 = 1024 * 1024;
|
||||
const KB: u64 = 1024;
|
||||
|
||||
fn inner(len: u64, divisor: u64, suffix: &str) -> String {
|
||||
let mut s = format!("{}", len / divisor);
|
||||
if s.len() == 1 {
|
||||
let _ = write!(s, ".{:02}", (len % divisor) / (divisor / 100));
|
||||
} else if s.len() == 2 {
|
||||
let _ = write!(s, ".{:01}", (len % divisor) / (divisor / 10));
|
||||
}
|
||||
let _ = write!(s, " {suffix}");
|
||||
s
|
||||
}
|
||||
|
||||
if len > GB {
|
||||
inner(len, GB, "GB")
|
||||
} else if len > MB {
|
||||
inner(len, MB, "MB")
|
||||
} else if len > KB {
|
||||
inner(len, KB, "KB")
|
||||
} else {
|
||||
format!("{len} B")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user