Create Installer
struct
This commit is contained in:
parent
a07166375a
commit
ab6e7441f1
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -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",
|
||||
|
63
src/installer/mod.rs
Normal file
63
src/installer/mod.rs
Normal file
@ -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<T: io::Read> {
|
||||
path: PathBuf,
|
||||
package: Package,
|
||||
reader: T,
|
||||
}
|
||||
|
||||
impl<T: io::Read> Installer<T> {
|
||||
pub fn new<P: AsRef<OsStr>>(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<InstallMessage>) -> Result<(), Box<InstallError>> {
|
||||
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<io::Error> for InstallError {
|
||||
fn from(value: io::Error) -> Self {
|
||||
Self::IO(value)
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
mod creator;
|
||||
mod db;
|
||||
mod hooks;
|
||||
mod installer;
|
||||
mod item;
|
||||
mod repository;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user