mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
ksud: Replace dependencies regex
to regex-lite
This commit is contained in:
parent
0911af0686
commit
a49adaa847
8
userspace/ksud/Cargo.lock
generated
8
userspace/ksud/Cargo.lock
generated
@ -899,7 +899,7 @@ dependencies = [
|
||||
"loopdev",
|
||||
"nom",
|
||||
"procfs",
|
||||
"regex",
|
||||
"regex-lite",
|
||||
"retry",
|
||||
"rust-embed",
|
||||
"rustix 0.38.34 (git+https://github.com/Kernel-SU/rustix.git?branch=main)",
|
||||
@ -1251,6 +1251,12 @@ dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-lite"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.4"
|
||||
|
@ -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"
|
||||
@ -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 = [
|
||||
|
@ -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;
|
||||
@ -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+)")?;
|
||||
@ -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)
|
||||
@ -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");
|
||||
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user