diff options
| author | rorka900 <rorka900@gmail.com> | 2026-03-23 06:45:05 +0000 |
|---|---|---|
| committer | rorka900 <rorka900@gmail.com> | 2026-03-23 06:45:37 +0000 |
| commit | 8eff76834457baab7dc9e2da9e966111c45787c8 (patch) | |
| tree | 9795fe0dfbac1de202c45d7844fb56621030ac2f /src/config.rs | |
| parent | 3c052d789162be533ab5159bbcb888fc26b01bc5 (diff) | |
| download | ror-8eff76834457baab7dc9e2da9e966111c45787c8.tar.gz ror-8eff76834457baab7dc9e2da9e966111c45787c8.zip | |
feat: add progress bar, fix rootfs creation, and apply FHS layout
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/config.rs b/src/config.rs index d79ad28..6fc440f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,7 +34,7 @@ pub struct Config { impl Config { pub fn load() -> Self { - let path = Path::new("/var/ror/ror.conf"); + let path = Path::new("/etc/ror/ror.conf"); if path.exists() { let content = fs::read_to_string(path).unwrap_or_default(); Self::from_ini(&content).unwrap_or_else(|e| { @@ -49,18 +49,19 @@ impl Config { Config::default() } } + pub fn to_ini(&self) -> Result<String, config::ConfigError> { let mut lines = vec!["[global]".to_string()]; lines.push(format!("ignore_speed = {}", self.global.ignore_speed)); lines.push(format!("strict_gpg = {}", self.global.strict_gpg)); - lines.push("".to_string()); + lines.push(String::new()); for (name, repo) in &self.repositories { lines.push(format!("[repositories.{}]", name)); lines.push(format!("url = \"{}\"", repo.url)); if let Some(m) = &repo.mirror { lines.push(format!("mirror = \"{}\"", m)); } - lines.push("".to_string()); + lines.push(String::new()); } Ok(lines.join("\n")) } @@ -73,16 +74,16 @@ impl Config { } pub fn create_default_config(path: &Path) -> std::io::Result<()> { - let ini = r#"[global] -ignore_speed = false -strict_gpg = false - -[repositories.rorkos] -url = "https: -mirror = "https: -"#; + let ini = concat!( + "[global]\n", + "ignore_speed = false\n", + "strict_gpg = false\n", + "\n", + "[repositories.rorkos]\n", + "url = \"https://github.com/RorkOS/RorkOS_package\"\n", + "mirror = \"https://github.com/rork-os/RorkOS_package\"\n", + ); fs::create_dir_all(path.parent().unwrap())?; fs::write(path, ini) } } - |