feat: new config files
This commit is contained in:
parent
3902a6beaf
commit
d1882114c7
7 changed files with 71 additions and 2 deletions
|
@ -25,3 +25,4 @@ reqwest = { version = "0.11.18", features = ["blocking"] }
|
|||
tar = "0.4.39"
|
||||
humantime = "2.1.0"
|
||||
expanduser = "1.2.2"
|
||||
url = { version = "2.4.0", features = ["serde"] }
|
3
pkgr/skel/etc/pkgr.d/repos.toml
Normal file
3
pkgr/skel/etc/pkgr.d/repos.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
[repo.main]
|
||||
name = "Main"
|
||||
url = "tcp://pkgs.ixvd.net:1050"
|
6
pkgr/skel/etc/pkgr.toml
Normal file
6
pkgr/skel/etc/pkgr.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
build_by_default = false
|
||||
tmp_dir = "/tmp/pkgr"
|
||||
|
||||
[storage]
|
||||
repo_file = "/etc/pkgr.d/repos.toml"
|
||||
data_dir = "/var/lib/pkgr/packages"
|
|
@ -1,4 +1,8 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use storage::Storage;
|
||||
|
||||
mod storage;
|
||||
pub mod repos;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
|
@ -6,13 +10,16 @@ pub struct Config {
|
|||
pub build_by_default: bool,
|
||||
#[serde(default)]
|
||||
pub tmp_dir: Option<String>,
|
||||
#[serde(default)]
|
||||
pub storage: Storage
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Config {
|
||||
Config {
|
||||
build_by_default: false,
|
||||
tmp_dir: Some(String::from("/tmp/pkgr"))
|
||||
tmp_dir: Some(String::from("/tmp/pkgr")),
|
||||
storage: Storage::default()
|
||||
}
|
||||
}
|
||||
}
|
25
pkgr/src/config/repos.rs
Normal file
25
pkgr/src/config/repos.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Repo {
|
||||
#[serde(default)]
|
||||
pub name: String,
|
||||
pub uri: Url
|
||||
}
|
||||
|
||||
impl Default for Repo {
|
||||
fn default() -> Self {
|
||||
Repo {
|
||||
name: String::from("Repo"),
|
||||
uri: Url::parse("tcp://0.0.0.0:0000").unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct RepoFile {
|
||||
pub repos: HashMap<String, Repo>
|
||||
}
|
20
pkgr/src/config/storage.rs
Normal file
20
pkgr/src/config/storage.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Storage {
|
||||
/// Where the repositories are defined.
|
||||
#[serde(default)]
|
||||
pub repo_file: String,
|
||||
/// Where to store pkgs data
|
||||
#[serde(default)]
|
||||
pub data_dir: String
|
||||
}
|
||||
|
||||
impl Default for Storage {
|
||||
fn default() -> Self {
|
||||
Storage {
|
||||
repo_file: String::from("/etc/pkgr.d/repos.toml"),
|
||||
data_dir: String::from("/var/lib/pkgr/packages"),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ use log::{debug, trace};
|
|||
use errors::{BinError, BuildError, InstallError};
|
||||
use manifest::Manifest;
|
||||
use pkgfile::PKGFile;
|
||||
use crate::CONFIG;
|
||||
|
||||
use crate::tmpfs::TempDir;
|
||||
use crate::types::fetch::TryFetch;
|
||||
|
@ -108,11 +109,17 @@ impl PackageInstaller {
|
|||
}
|
||||
}
|
||||
|
||||
match self.install_type {
|
||||
let r = match self.install_type {
|
||||
InstallType::Bin => self.bin()
|
||||
.map_err(|e| InstallError::BinError(e)),
|
||||
InstallType::Build => self.build()
|
||||
.map_err(|e| InstallError::BuildError(e)),
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(e) = r {
|
||||
return Err(e);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue