Skip to content

Commit

Permalink
ksud: Replace dependencies regex to regex-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
chise0713 authored and yujincheng08 committed Jul 26, 2024
1 parent 0911af0 commit a49adaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 7 additions & 1 deletion userspace/ksud/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion userspace/ksud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ log = "0.4"
env_logger = { version = "0.11", default-features = false }
serde = { version = "1" }
serde_json = "1"
regex = "1"
encoding_rs = "0.8"
retry = "2"
humansize = "2"
Expand All @@ -46,6 +45,7 @@ sha1 = "0.10"
tempdir = "0.3"
chrono = "0.4"
hole-punch = { git = "https://github.com/tiann/hole-punch" }
regex-lite = "0.1.6"

[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
rustix = { git = "https://github.com/Kernel-SU/rustix.git", branch = "main", features = [
Expand Down
9 changes: 5 additions & 4 deletions userspace/ksud/src/boot_patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use anyhow::bail;
use anyhow::ensure;
use anyhow::Context;
use anyhow::Result;
use regex_lite::Regex;
use which::which;

use crate::defs;
Expand All @@ -27,7 +28,6 @@ fn ensure_gki_kernel() -> Result<()> {

#[cfg(target_os = "android")]
pub fn get_kernel_version() -> Result<(i32, i32, i32)> {
use regex::Regex;
let uname = rustix::system::uname();
let version = uname.release().to_string_lossy();
let re = Regex::new(r"(\d+)\.(\d+)\.(\d+)")?;
Expand All @@ -52,7 +52,6 @@ pub fn get_kernel_version() -> Result<(i32, i32, i32)> {

#[cfg(target_os = "android")]
fn parse_kmi(version: &str) -> Result<String> {
use regex::Regex;
let re = Regex::new(r"(.* )?(\d+\.\d+)(\S+)?(android\d+)(.*)")?;
let cap = re
.captures(version)
Expand Down Expand Up @@ -98,7 +97,6 @@ pub fn get_current_kmi() -> Result<String> {
}

fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result<String> {
use regex::Regex;
use std::fs::{copy, File};
use std::io::{BufReader, Read};
let kernel_path = workdir.join("kernel");
Expand Down Expand Up @@ -146,7 +144,10 @@ fn parse_kmi_from_boot(magiskboot: &Path, image: &PathBuf, workdir: &Path) -> Re
.context("Failed to execute magiskboot command")?;

if !status.success() {
bail!("magiskboot unpack failed with status: {:?}", status.code().unwrap());
bail!(
"magiskboot unpack failed with status: {:?}",
status.code().unwrap()
);
}

parse_kmi_from_kernel(&image_path, workdir)
Expand Down

0 comments on commit a49adaa

Please sign in to comment.