diff --git a/Cargo.toml b/Cargo.toml index 7bccffa..3f7c287 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,3 @@ -cargo-features = ["strip"] [package] name = "gaypk" description = "GayBSD Package Manager" diff --git a/example-package/Package.toml b/example-package/Package.toml index 360233f..d56e0d9 100644 --- a/example-package/Package.toml +++ b/example-package/Package.toml @@ -2,7 +2,6 @@ gaypk-version = 100 name = "example-package" version = "1.0.0" revision = 0 -pubkey = "" scripts=["*.gpksh"] exclude=["scripts", "*.gpksh"] [dependencies] @@ -10,7 +9,7 @@ exclude=["scripts", "*.gpksh"] # GayPK doesn't care about this stuff [locale.en_US] name = "Example Package" -description = "Example Package for testing GayPackage format." +description = "Example Package for testing GayPK format." [locale.tp_XW] name = "" description = "" diff --git a/example-package/root/etc/enby/manuals/example-package.gmi b/example-package/global/etc/enby/manuals/example-package.gmi similarity index 100% rename from example-package/root/etc/enby/manuals/example-package.gmi rename to example-package/global/etc/enby/manuals/example-package.gmi diff --git a/example-package/root/opt/bin/example-package.x86-64.elf b/example-package/package/bin/example-package.x86-64.elf similarity index 100% rename from example-package/root/opt/bin/example-package.x86-64.elf rename to example-package/package/bin/example-package.x86-64.elf diff --git a/example-package/root/opt/etc/etc-file.gpksh b/example-package/package/etc/etc-file.gpksh similarity index 50% rename from example-package/root/opt/etc/etc-file.gpksh rename to example-package/package/etc/etc-file.gpksh index 7706773..8e64fdf 100644 --- a/example-package/root/opt/etc/etc-file.gpksh +++ b/example-package/package/etc/etc-file.gpksh @@ -1,4 +1,7 @@ #!/usr/bin/env fish # shellcheck disable=SC2034 OVERWRITE=false -cat etc-file.txt >> /opt/etc/etc-file.txt \ No newline at end of file +if $RUN + cat etc-file.txt >> /etc/etc-file.txt +end +export RUN=1 \ No newline at end of file diff --git a/example-package/root/opt/etc/etc-file.txt b/example-package/package/etc/etc-file.txt similarity index 100% rename from example-package/root/opt/etc/etc-file.txt rename to example-package/package/etc/etc-file.txt diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..8323034 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,26 @@ +use std::fs::File; +use toml::value::{Array, Table}; +use serde_derive::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug)] +pub(crate) struct Config { + pub(crate) base_package_path: String, + pub(crate) installation_path: String, + pub(crate) key_verification: bool +} +impl Default for Config { + fn default() -> Self { + Config { + base_package_path: "/packages".to_string(), + installation_path: "/var/gaypk/".to_string(), + key_verification: true + } + } +} +pub(crate) fn read_config() -> Config { + toml::from_str("/cfg/gaypk/config.toml").expect("Parse failed!") +} +pub(crate) fn write_config(cfg: Config) { + let file = File::create(crate::config::read_config().installation_path + "config.toml").expect("Failed to read file"); + writeln!(file, toml::to_string_pretty(&cfg).expect("Write failed!")); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e07bf9b..e65108a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod remove; mod repository; mod install; mod package; +mod config; use crate::repository::find_package_in_repositories; @@ -21,7 +22,7 @@ fn main() { let package_name = std::env::args().nth(2).expect("too few arguments!"); // Get the first package name find_package_in_repositories(&package_name, None); // Go through and find the package println!("Reading package list"); - let package_list = sled::open("/var/gaypk/packages").expect("Failed to open package list"); + let package_list = sled::open(crate::config::read_config().installation_path + "packages").expect("Failed to open package list"); if package_list.contains_key(&package_name).expect("Unexpected error") { println!("Package was found in package list, checking for updates"); } diff --git a/src/package.rs b/src/package.rs index 5cbef46..0507923 100644 --- a/src/package.rs +++ b/src/package.rs @@ -9,7 +9,6 @@ pub struct PackageData { pub name: String, pub version: String, pub revision: u64, - pub pubkey: String, pub scripts: Array, pub exclude: Array, pub dependencies: Table diff --git a/src/repository.rs b/src/repository.rs index d047171..85c2d33 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -8,7 +8,7 @@ use std::io::BufRead; pub fn find_package_in_repositories(package: &str, installed: Option, ) -> Option> { let client = reqwest::Client::new(); // The reqwest client which will make GET requests to remove servers. let repo_file = - File::open("/var/gaypk/repositories.list").expect("Failed to open repository list"); // The repositories.list file, which contains a list of all known and trusted repositories. + File::open(crate::config::read_config().installation_path + "repositories.list").expect("Failed to open repository list"); // The repositories.list file, which contains a list of all known and trusted repositories. let mut candidates: HashMap = HashMap::new(); // This map will store a list of the repositories along with the latest version of the package they have. if installed.is_some() {