diff --git a/Cargo.lock b/Cargo.lock index c2c2e7e..5299ad4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -392,7 +392,7 @@ dependencies = [ [[package]] name = "hpk-package" version = "0.1.0" -source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk-package.git#723d697e9085a575c1f6d59baf1e79819452d747" +source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk-package.git#acbdf2d99284b69a48601f3aeb0a56f295872a4c" dependencies = [ "chrono", "deku", diff --git a/src/installer/mod.rs b/src/installer/mod.rs new file mode 100644 index 0000000..3e2a36b --- /dev/null +++ b/src/installer/mod.rs @@ -0,0 +1,63 @@ +use std::{io, path::{PathBuf, Path}, ffi::OsStr, sync::mpsc::Sender}; +pub use error::InstallError; +use hpk_package::{Package, User, Group}; + +pub struct Link { + pub path: PathBuf, + pub target: PathBuf, +} + +pub enum InstallMessage { + FileInstalled(PathBuf), + DirectoryCreated(PathBuf), + LinkCreated(Link), + UserCreated(User), + GroupCreated(Group), + PostInstall(String), +} + +pub struct Installer { + path: PathBuf, + package: Package, + reader: T, +} + +impl Installer { + pub fn new>(path: P, package: Package, reader: T) -> Self { + let path = Path::new(&path).to_path_buf(); + Self { path, package, reader } + } + + pub fn install(&mut self, sender: Sender) -> Result<(), Box> { + unimplemented!(); + } +} + +mod error { + use std::{io, fmt, error::Error}; + + #[derive(Debug)] + pub enum InstallError { + IO(io::Error), + } + + impl fmt::Display for InstallError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:?}") + } + } + + impl Error for InstallError { + fn source(&self) -> Option<&(dyn Error + 'static)> { + match self { + Self::IO(e) => Some(e), + } + } + } + + impl From for InstallError { + fn from(value: io::Error) -> Self { + Self::IO(value) + } + } +} diff --git a/src/lib.rs b/src/lib.rs index b08bd4b..2b62048 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ mod creator; mod db; mod hooks; +mod installer; mod item; mod repository;