From ab2d76656b3a0381b1a38d598a3ee8cc40835436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:02:13 +0800 Subject: [PATCH] ksud: Replace dependencies `regex` to `regex-lite` --- userspace/ksud/Cargo.lock | 8 +++++++- userspace/ksud/Cargo.toml | 2 +- userspace/ksud/src/boot_patch.rs | 9 +++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index 3c64e50cf645..a74965235818 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -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" diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index f85218e05d1e..c01c8b021f82 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -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 = [ diff --git a/userspace/ksud/src/boot_patch.rs b/userspace/ksud/src/boot_patch.rs index fb0c9eaa10fb..29313f1b8d70 100644 --- a/userspace/ksud/src/boot_patch.rs +++ b/userspace/ksud/src/boot_patch.rs @@ -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 { - 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 { } fn parse_kmi_from_kernel(kernel: &PathBuf, workdir: &Path) -> Result { - 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)