diff options
Diffstat (limited to 'src/pkgtoolkit/install.rs')
| -rw-r--r-- | src/pkgtoolkit/install.rs | 80 |
1 files changed, 22 insertions, 58 deletions
diff --git a/src/pkgtoolkit/install.rs b/src/pkgtoolkit/install.rs index 7ba0598..13929e6 100644 --- a/src/pkgtoolkit/install.rs +++ b/src/pkgtoolkit/install.rs @@ -1,5 +1,4 @@ use crate::cfg::config::Config; -use crate::router::manager::RouterManager; use std::{ fs::{self, Permissions, create_dir_all, set_permissions}, os::unix::fs::PermissionsExt, @@ -33,37 +32,9 @@ pub trait InstallOperations { fn load_manifest(&self) -> Result<PackageManifest, std::io::Error>; fn list_installed_packages() -> Result<Vec<PackageManifest>, std::io::Error>; fn is_installed(&self) -> Result<bool, std::io::Error>; - - /// Installs a package using the specified parameters - /// - /// # Arguments - /// * `pkgname` - Name of the package to install - /// * `source` - Optional source URL or path - /// * `is_path` - Whether the source is a local path - /// * `args` - Additional installation arguments - /// * `router_manager` - Optional router manager for I2P connections - async fn install_package( - pkgname: &str, - source: Option<&str>, - is_path: bool, - args: &RemoteInstallArgs, - router_manager: &RouterManager, - ) -> Result<(), Box<dyn std::error::Error>>; } impl InstallOperations for Package { - async fn install_package( - pkgname: &str, - source: Option<&str>, - is_path: bool, - args: &RemoteInstallArgs, - router_manager: &RouterManager, - ) -> Result<(), Box<dyn std::error::Error>> { - // Implementation of install_package - // TODO: Add actual implementation based on your requirements - Ok(()) - } - /// Recursively collects all files from a directory and its subdirectories /// and returns them as a vector of strings. /// @@ -118,7 +89,7 @@ impl InstallOperations for Package { let is_build_present_and_not_empty = build_meta.is_some(); if is_build_present_and_not_empty { - log::info!( + println!( "Found BUILD file, preparing to build and install package: {}", self.name ); @@ -203,7 +174,7 @@ impl InstallOperations for Package { } } } else { - log::info!( + println!( "No BUILD file or it's empty. Treating as binary package. Installing via INSTALL config or custom script." ); if let Some(ref script) = install_meta.install.custom_script { @@ -211,7 +182,7 @@ impl InstallOperations for Package { } if let Some(ref script) = install_meta.install.custom_script { - log::info!( + println!( "Executing custom install script for {}", install_meta.package.name ); @@ -232,16 +203,16 @@ impl InstallOperations for Package { "Custom script used; file list may be incomplete. Add manual tracking if needed." ); } else { - log::info!( + println!( "No custom script. Running default install hook for {}", install_meta.package.name ); - log::info!("Starting default install process"); + println!("Starting default install process"); let build_dir = Path::new(&config.paths.cache_dir) .join(format!("{}-{}", self.name, self.version)); let dest_path = Path::new(&install_meta.install.path); - log::info!( + println!( "Install path: {:?}, is_dir: {}, ends_with_slash: {}", dest_path, dest_path.is_dir(), @@ -249,7 +220,7 @@ impl InstallOperations for Package { ); if dest_path.is_dir() || dest_path.to_string_lossy().ends_with('/') { - log::info!("Taking multi-binary package path"); + println!("Taking multi-binary package path"); let target_release = build_dir.join("target/release"); if !target_release.exists() { return Err(std::io::Error::other(format!( @@ -271,12 +242,12 @@ impl InstallOperations for Package { && let Ok(metadata) = fs::metadata(&path) { let mode = metadata.permissions().mode(); - log::debug!("Checking file: {:?}, mode: {:o}", path.file_name(), mode); + println!("Checking file: {:?}, mode: {:o}", path.file_name(), mode); if mode & 0o111 != 0 { let file_name = path.file_name().unwrap().to_string_lossy(); let dest_file = dest_path.join(&*file_name); - log::info!( + println!( "Copying executable: {} to {}", file_name, dest_file.display() @@ -290,7 +261,7 @@ impl InstallOperations for Package { copied_files.push(dest_file); } else { - log::debug!( + println!( "File {:?} is not executable (mode: {:o})", path.file_name(), mode @@ -337,7 +308,7 @@ impl InstallOperations for Package { if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); - log::warn!( + println!( "Warning: 'chown' command failed for {} (requires root?):\n{}", file_path.display(), stderr @@ -345,7 +316,7 @@ impl InstallOperations for Package { } } } else { - log::info!("Taking single binary package path"); + println!("Taking single binary package path"); // Single binary package - copy specific file let source_file_name = &self.name; let src_path = build_dir.join(source_file_name); @@ -393,10 +364,7 @@ impl InstallOperations for Package { if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); - log::warn!( - "Warning: 'chown' command failed (requires root?):\n{}", - stderr - ); + println!("Warning: 'chown' command failed:\n{}", stderr); } all_files = install_meta.files; @@ -414,7 +382,7 @@ impl InstallOperations for Package { toml::to_string_pretty(&manifest).map_err(|e| std::io::Error::other(e.to_string()))?; fs::write(&manifest_path, manifest_toml)?; - log::info!( + println!( "Package {} installed successfully. Manifest generated at {:?} with {} files tracked", self.name, manifest_path, @@ -448,10 +416,9 @@ impl InstallOperations for Package { fn uninstall(&self) -> Result<bool, std::io::Error> { let manifest = self.load_manifest()?; - log::info!( + println!( "Uninstalling package {}-{}", - manifest.name, - manifest.version + manifest.name, manifest.version ); let mut removed_files = 0; @@ -464,15 +431,15 @@ impl InstallOperations for Package { match fs::remove_file(path) { Ok(()) => { removed_files += 1; - log::debug!("Removed file: {:?}", path); + println!("Removed file: {:?}", path); } Err(e) => { failed_removals += 1; - log::warn!("Failed to remove file {:?}: {}", path, e); + println!("Failed to remove file {:?}: {}", path, e); } } } else { - log::debug!("File not found, skipping: {:?}", path); + println!("File not found, skipping: {:?}", path); } } @@ -483,15 +450,12 @@ impl InstallOperations for Package { if manifest_path.exists() { fs::remove_file(&manifest_path)?; - log::info!("Removed manifest file: {:?}", manifest_path); + println!("Removed manifest file: {:?}", manifest_path); } - log::info!( + println!( "Package {}-{} uninstalled successfully. Removed {} files, {} failures", - manifest.name, - manifest.version, - removed_files, - failed_removals + manifest.name, manifest.version, removed_files, failed_removals ); Ok(failed_removals == 0) |
