Skip to content

Commit

Permalink
ksud: Fix build for win
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Jan 16, 2024
1 parent aef943e commit 7b63e09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions userspace/ksud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion userspace/ksud/src/boot_patch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;

use anyhow::bail;
Expand All @@ -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")?;
Expand Down Expand Up @@ -59,7 +61,10 @@ pub fn patch(
out: Option<PathBuf>,
magiskboot_path: Option<PathBuf>,
) -> Result<()> {
ensure_gki_kernel()?;
if image.is_none() {
#[cfg(unix)]
ensure_gki_kernel()?;
}

if kernel.is_some() {
ensure!(
Expand Down Expand Up @@ -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())?;
}
Expand Down

0 comments on commit 7b63e09

Please sign in to comment.