From 7b63e099ce6f1f5b917fffd5a7f18e403cd8c838 Mon Sep 17 00:00:00 2001 From: weishu Date: Tue, 16 Jan 2024 11:39:15 +0800 Subject: [PATCH] ksud: Fix build for win --- userspace/ksud/Cargo.toml | 4 ++-- userspace/ksud/src/boot_patch.rs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index 4a4f938c..cd5961a8 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -34,6 +34,8 @@ rust-embed = { version = "6", features = [ which = "5" getopts = "0.2" sha256 = "1" +tempdir = "0.3" +chrono = "0.4" [target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies] sys-mount = { git = "https://github.com/tiann/sys-mount", branch = "loopfix" } @@ -44,8 +46,6 @@ procfs = "0.16" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.13" -tempdir = "0.3" -chrono = "0.4" [profile.release] strip = true opt-level = "z" diff --git a/userspace/ksud/src/boot_patch.rs b/userspace/ksud/src/boot_patch.rs index 45ba3144..d07612bc 100644 --- a/userspace/ksud/src/boot_patch.rs +++ b/userspace/ksud/src/boot_patch.rs @@ -1,3 +1,4 @@ +#[cfg(unix)] use std::os::unix::fs::PermissionsExt; use anyhow::bail; @@ -12,6 +13,7 @@ use std::process::Stdio; use crate::utils; +#[cfg(unix)] fn ensure_gki_kernel() -> Result<()> { let version = procfs::sys::kernel::Version::current().with_context(|| "get kernel version failed")?; @@ -59,7 +61,10 @@ pub fn patch( out: Option, magiskboot_path: Option, ) -> Result<()> { - ensure_gki_kernel()?; + if image.is_none() { + #[cfg(unix)] + ensure_gki_kernel()?; + } if kernel.is_some() { ensure!( @@ -121,6 +126,7 @@ pub fn patch( .unwrap_or_else(|| "magiskboot".into()); if !magiskboot.is_executable() { + #[cfg(unix)] std::fs::set_permissions(&magiskboot, std::fs::Permissions::from_mode(0o755)) .with_context(|| "set magiskboot executable failed".to_string())?; }