diff options
Diffstat (limited to 'src/pkgtoolkit')
| -rw-r--r-- | src/pkgtoolkit/build.rs | 8 | ||||
| -rw-r--r-- | src/pkgtoolkit/install.rs | 44 | ||||
| -rw-r--r-- | src/pkgtoolkit/types.rs | 5 |
3 files changed, 50 insertions, 7 deletions
diff --git a/src/pkgtoolkit/build.rs b/src/pkgtoolkit/build.rs index 8c5119c..8a46809 100644 --- a/src/pkgtoolkit/build.rs +++ b/src/pkgtoolkit/build.rs @@ -145,10 +145,10 @@ impl BuildOperations for Package { search_dir.join(pattern).to_string_lossy().into_owned() }; - let entries = glob(&glob_pattern) + let mut entries = glob(&glob_pattern) .map_err(|e| std::io::Error::other(format!("Invalid glob pattern: {}", e)))?; - for entry in entries { + if let Some(entry) = entries.next() { let path = entry.map_err(|e| std::io::Error::other(format!("Glob error: {}", e)))?; return Ok(Some(path)); @@ -237,7 +237,7 @@ impl BuildOperations for Package { match build_meta.build_system { BuildSystems::Make => { let found = self - .find_makefile(&build_meta, &build_dir) + .find_makefile(build_meta, &build_dir) .map_err(|e| { std::io::Error::other(format!("Failed to search for Makefile: {}", e)) })? @@ -261,7 +261,7 @@ impl BuildOperations for Package { } BuildSystems::CMake => { let found = self - .find_makefile(&build_meta, &build_dir) + .find_makefile(build_meta, &build_dir) .map_err(|e| { std::io::Error::other(format!("Failed to search for CMakeLists: {}", e)) })? diff --git a/src/pkgtoolkit/install.rs b/src/pkgtoolkit/install.rs index 4eeff2f..7ba0598 100644 --- a/src/pkgtoolkit/install.rs +++ b/src/pkgtoolkit/install.rs @@ -1,17 +1,31 @@ use crate::cfg::config::Config; +use crate::router::manager::RouterManager; use std::{ fs::{self, Permissions, create_dir_all, set_permissions}, os::unix::fs::PermissionsExt, - path::{Path, StripPrefixError}, + path::Path, + path::StripPrefixError, process::Command, }; +/// Arguments for remote package installation +#[derive(Clone)] +pub struct RemoteInstallArgs { + /// Install binary package + pub bin: bool, + /// Use non-I2P mirror + pub http: bool, + /// Clean cache before install + pub clean: bool, +} + use toml; use super::archive::ArchiveOperations; use super::build::BuildOperations; use super::types::{Package, PackageManifest}; +#[allow(dead_code)] pub trait InstallOperations { fn collect_files_from_dir(root: &Path, base: &Path) -> Result<Vec<String>, std::io::Error>; fn install(&mut self) -> Result<bool, std::io::Error>; @@ -19,9 +33,37 @@ 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. /// diff --git a/src/pkgtoolkit/types.rs b/src/pkgtoolkit/types.rs index 0439175..9d8f915 100644 --- a/src/pkgtoolkit/types.rs +++ b/src/pkgtoolkit/types.rs @@ -1,8 +1,9 @@ use serde::{Deserialize, Serialize}; use std::fmt; -#[derive(Serialize, Debug, Deserialize, Clone, PartialEq)] +#[derive(Serialize, Debug, Deserialize, Clone, PartialEq, Default)] pub enum Archs { + #[default] X86_64, Aarch64, X86, @@ -10,7 +11,7 @@ pub enum Archs { ArmV8, } -#[derive(Serialize, Debug, Deserialize, Clone)] +#[derive(Serialize, Debug, Deserialize, Clone, Default)] pub struct Package { pub name: String, pub version: String, |
