ksud: Fix build for win

This commit is contained in:
weishu
2024-01-16 11:39:15 +08:00
parent aef943ebe3
commit 7b63e099ce
2 changed files with 9 additions and 3 deletions

View File

@@ -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"

View File

@@ -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<PathBuf>,
magiskboot_path: Option<PathBuf>,
) -> Result<()> {
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())?;
}