summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-11-24 23:04:25 +0300
committerNamilskyy <alive6863@gmail.com>2025-11-24 23:06:16 +0300
commit592000eb84dde8b15e776a1abcf72124aa0f200c (patch)
tree06d9164b49f60a4e584392a5b5b652341892371e /src
parent3ca328a876f7f4c8bf94c739d2166a1ad1dfb9bc (diff)
Updated README.md, started writing minimal required functions.
Diffstat (limited to 'src')
-rw-r--r--src/cfg/config.rs73
-rw-r--r--src/cfg/mod.rs1
-rw-r--r--src/i2impl/mi2p.rs0
-rw-r--r--src/i2impl/mod.rs1
-rw-r--r--src/main.rs11
-rw-r--r--src/pkgtoolkit/mod.rs1
-rw-r--r--src/pkgtoolkit/pkgtools.rs17
7 files changed, 104 insertions, 0 deletions
diff --git a/src/cfg/config.rs b/src/cfg/config.rs
new file mode 100644
index 0000000..ee4e3b7
--- /dev/null
+++ b/src/cfg/config.rs
@@ -0,0 +1,73 @@
+use std::fs;
+use std::env;
+use serde::{Deserialize, Serialize};
+use toml;
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "lowercase")]
+pub enum Loglevel {
+ Trace,
+ Debug,
+ Info,
+ Warn,
+ Error
+}
+
+#[derive(Deserialize, Debug, Serialize)]
+pub struct Config {
+ repo: Repo,
+ log: Log,
+ paths: Paths,
+}
+
+#[derive(Deserialize, Debug, Serialize)]
+pub struct Log {
+ logfile: String,
+ loglevel: Loglevel,
+}
+
+#[derive(Deserialize, Debug, Serialize)]
+pub struct Repo {
+ #[serde(rename = "repo_url")]
+ repo_url: String,
+ #[serde(rename = "auto_update")]
+ auto_update: bool,
+}
+
+#[derive(Deserialize, Debug, Serialize)]
+pub struct Paths {
+ #[serde(rename = "cachedir")]
+ cachedir: String,
+ #[serde(rename = "builddir")]
+ builddir: String,
+}
+
+impl Config {
+ pub fn parse() -> Result<Config, toml::de::Error> {
+ let contents = fs::read_to_string("/etc/mesk.toml").unwrap();
+ let result: Config = toml::from_str(&contents)?;
+ Ok(result)
+ }
+
+
+ pub fn default() -> Result<String, toml::ser::Error> {
+ let default: Config = Config {
+ repo: Repo {
+ repo_url: format!("https://mesk.anthrill.i2p/repo/{}/",
+ std::env::consts::ARCH),
+ auto_update: true,
+ },
+ log: Log {
+ logfile: String::from("/var/log/mesk.log"),
+ loglevel: Loglevel::Info,
+ },
+ paths: Paths {
+ cachedir: String::from("/var/cache/mesk"),
+ builddir: String::from("/var/lib/mesk"),
+ },
+ };
+
+ let toml_str = toml::to_string(&default)?;
+ Ok(toml_str)
+ }
+} \ No newline at end of file
diff --git a/src/cfg/mod.rs b/src/cfg/mod.rs
new file mode 100644
index 0000000..b1ca24c
--- /dev/null
+++ b/src/cfg/mod.rs
@@ -0,0 +1 @@
+pub mod config; \ No newline at end of file
diff --git a/src/i2impl/mi2p.rs b/src/i2impl/mi2p.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/i2impl/mi2p.rs
diff --git a/src/i2impl/mod.rs b/src/i2impl/mod.rs
new file mode 100644
index 0000000..4fa58ff
--- /dev/null
+++ b/src/i2impl/mod.rs
@@ -0,0 +1 @@
+pub mod mi2p; \ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..a2ca713
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,11 @@
+mod cfg;
+mod i2impl;
+mod pkgtoolkit;
+
+use crate::cfg::config;
+use crate::pkgtoolkit::pkgtools;
+use crate::i2impl::mi2p;
+
+fn main() {
+ todo!()
+} \ No newline at end of file
diff --git a/src/pkgtoolkit/mod.rs b/src/pkgtoolkit/mod.rs
new file mode 100644
index 0000000..4741892
--- /dev/null
+++ b/src/pkgtoolkit/mod.rs
@@ -0,0 +1 @@
+pub mod pkgtools; \ No newline at end of file
diff --git a/src/pkgtoolkit/pkgtools.rs b/src/pkgtoolkit/pkgtools.rs
new file mode 100644
index 0000000..d124c2b
--- /dev/null
+++ b/src/pkgtoolkit/pkgtools.rs
@@ -0,0 +1,17 @@
+use std::fs::File;
+use tar::Archive;
+
+pub struct Package {
+ BuildScript: String,
+ Name: String,
+ Version: String
+}
+
+impl Package {
+ pub fn build() -> Result<bool, std::io::Error> {
+ todo!();
+ }
+ pub fn install() -> Result<bool, std::io::Error> {
+ todo!();
+ }
+} \ No newline at end of file