mirror of
https://github.com/RGBCube/dix
synced 2025-07-28 12:17:45 +00:00
main: remove unnecessary code, cleanup
This commit is contained in:
parent
eee8c920a7
commit
c180c26bf5
1 changed files with 7 additions and 38 deletions
45
src/main.rs
45
src/main.rs
|
@ -1,12 +1,12 @@
|
||||||
mod print;
|
mod print;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use core::str;
|
use core::str;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, warn};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
process::Command,
|
process::Command,
|
||||||
string::{String, ToString},
|
string::ToString,
|
||||||
sync::OnceLock,
|
sync::OnceLock,
|
||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
|
@ -162,7 +162,7 @@ fn main() {
|
||||||
pre.entry(name).or_default().insert(version);
|
pre.entry(name).or_default().insert(version);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("Error parsing package version: {}", e);
|
debug!("Error parsing package version: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ fn main() {
|
||||||
post.entry(name).or_default().insert(version);
|
post.entry(name).or_default().insert(version);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("Error parsing package version: {}", e);
|
debug!("Error parsing package version: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,8 +229,8 @@ fn main() {
|
||||||
(Ok(Ok(pre_size)), Ok(Ok(post_size))) => {
|
(Ok(Ok(pre_size)), Ok(Ok(post_size))) => {
|
||||||
let pre_size = pre_size / 1024 / 1024;
|
let pre_size = pre_size / 1024 / 1024;
|
||||||
let post_size = post_size / 1024 / 1024;
|
let post_size = post_size / 1024 / 1024;
|
||||||
debug!("Pre closure size: {} MiB", pre_size);
|
debug!("Pre closure size: {pre_size} MiB");
|
||||||
debug!("Post closure size: {} MiB", post_size);
|
debug!("Post closure size: {post_size} MiB");
|
||||||
|
|
||||||
println!("{}", "Closure Size:".underline().bold());
|
println!("{}", "Closure Size:".underline().bold());
|
||||||
println!("Before: {pre_size} MiB");
|
println!("Before: {pre_size} MiB");
|
||||||
|
@ -238,7 +238,7 @@ fn main() {
|
||||||
println!("Difference: {} MiB", post_size - pre_size);
|
println!("Difference: {} MiB", post_size - pre_size);
|
||||||
}
|
}
|
||||||
(Ok(Err(e)), _) | (_, Ok(Err(e))) => {
|
(Ok(Err(e)), _) | (_, Ok(Err(e))) => {
|
||||||
error!("Error getting closure size: {}", e);
|
error!("Error getting closure size: {e}");
|
||||||
eprintln!("Error getting closure size: {e}");
|
eprintln!("Error getting closure size: {e}");
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -249,37 +249,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the dependencies of the packages in a closure
|
|
||||||
fn get_dependencies(path: &std::path::Path) -> Result<Vec<String>> {
|
|
||||||
debug!("Getting dependencies from path: {}", path.display());
|
|
||||||
|
|
||||||
// Get the nix store paths using `nix-store --query --requisites <path>`
|
|
||||||
let output = Command::new("nix-store")
|
|
||||||
.arg("--query")
|
|
||||||
.arg("--requisites")
|
|
||||||
.arg(path.join("sw"))
|
|
||||||
.output()?;
|
|
||||||
|
|
||||||
if !output.status.success() {
|
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
||||||
error!("nix-store command failed: {}", stderr);
|
|
||||||
return Err(AppError::CommandFailed {
|
|
||||||
command: "nix-store".to_string(),
|
|
||||||
args: vec![
|
|
||||||
"--query".to_string(),
|
|
||||||
"--requisites".to_string(),
|
|
||||||
path.join("sw").to_string_lossy().to_string(),
|
|
||||||
],
|
|
||||||
message: stderr.to_string(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let list = str::from_utf8(&output.stdout)?;
|
|
||||||
let dependencies: Vec<String> = list.lines().map(str::to_owned).collect();
|
|
||||||
debug!("Found {} dependencies", dependencies.len());
|
|
||||||
Ok(dependencies)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a reference to the compiled regex pattern.
|
// Returns a reference to the compiled regex pattern.
|
||||||
// The regex is compiled only once.
|
// The regex is compiled only once.
|
||||||
fn store_path_regex() -> &'static Regex {
|
fn store_path_regex() -> &'static Regex {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue