diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-18 00:23:13 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-18 00:23:13 +0800 |
| commit | e938129acc6231b2224db793c7aa9d6f95f7d0bf (patch) | |
| tree | d1e32095b761ccf50a58b5c59979fc0bcb0ca4b8 /.run/src/bin | |
| parent | 615b6c8964025f26856ce78af362d596c9f03593 (diff) | |
chore(package-all): replace system tar with native Rust extraction
Diffstat (limited to '.run/src/bin')
| -rw-r--r-- | .run/src/bin/package-all.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/.run/src/bin/package-all.rs b/.run/src/bin/package-all.rs index 1f1f50d..5d7cbbb 100644 --- a/.run/src/bin/package-all.rs +++ b/.run/src/bin/package-all.rs @@ -1,6 +1,8 @@ use std::path::{Path, PathBuf}; +use flate2::read::GzDecoder; use serde::Deserialize; +use tar::Archive; use tools::{ dependency_order::find_workspace_root, eprintln_cargo_style, println_cargo_style, run_cmd_capture_with_dir, wprintln_cargo_style, @@ -230,20 +232,18 @@ fn main() { std::fs::create_dir_all(&target_dir) .unwrap_or_else(|e| panic!("failed to create {}: {e}", target_dir.display())); - // Extract using tar + gzip - let extract_cmd = format!( - "tar -xzf \"{}\" -C \"{}\"", - path.display(), - target_dir.display() - ); - let extract_ok = std::process::Command::new("sh") - .arg("-c") - .arg(&extract_cmd) - .status() - .expect("failed to run tar"); - - if !extract_ok.success() { - eprintln_cargo_style!("Failed to extract {}", fname); + // Extract using flate2 + tar (cross-platform) + let file = match std::fs::File::open(&path) { + Ok(f) => f, + Err(e) => { + eprintln_cargo_style!("Failed to open {}: {e}", path.display()); + continue; + } + }; + let decoder = GzDecoder::new(file); + let mut archive = Archive::new(decoder); + if let Err(e) = archive.unpack(&target_dir) { + eprintln_cargo_style!("Failed to extract {}: {e}", fname); continue; } |
