added iso gui option
This commit is contained in:
parent
e794bef718
commit
5c4945de60
4 changed files with 39 additions and 6 deletions
|
@ -3,7 +3,11 @@ use clap::{arg, command};
|
|||
pub fn get_args() -> clap::ArgMatches {
|
||||
command!()
|
||||
.about("navOS Installer")
|
||||
.subcommand(command!("create-iso").about("Create a new installation medium ISO"))
|
||||
.subcommand(
|
||||
command!("create-iso")
|
||||
.about("Create a new installation medium ISO")
|
||||
.arg(arg!(--without_gui "Create ISO with just terminal")),
|
||||
)
|
||||
.subcommand(
|
||||
command!()
|
||||
.name("install")
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use crate::{install::str_vec, is_root, run_command};
|
||||
use crate::{
|
||||
install::{str_vec, uncomment_tag},
|
||||
is_root, run_command,
|
||||
};
|
||||
|
||||
// TODO : Make GUI in install medium optional with arg `--with-gui`
|
||||
pub fn create_iso() {
|
||||
pub fn create_iso(without_gui: bool) {
|
||||
if !is_root() {
|
||||
eprintln!("Error: You need root to create an ISO");
|
||||
std::process::exit(1);
|
||||
|
@ -12,6 +14,13 @@ pub fn create_iso() {
|
|||
run_command(&cmd, None, false);
|
||||
}
|
||||
|
||||
if without_gui {
|
||||
std::fs::remove_file("./iso/airootfs/etc/systemd/system/display-manager.service").unwrap();
|
||||
} else {
|
||||
println!("Adding GUI packages");
|
||||
uncomment_tag("#gui: ", "./iso/packages.x86_64");
|
||||
}
|
||||
|
||||
std::fs::create_dir_all("./work").unwrap();
|
||||
|
||||
let mount_cmd = str_vec(vec![
|
||||
|
|
|
@ -54,6 +54,25 @@ pub fn uncomment_first_value_of(value: &str, file: &str) {
|
|||
std::fs::write(file, new).unwrap();
|
||||
}
|
||||
|
||||
pub fn uncomment_tag(tag: &str, file: &str) {
|
||||
// read in the file
|
||||
let content = std::fs::read_to_string(file).unwrap();
|
||||
let mut new = String::new();
|
||||
|
||||
// search for the first instance of `value` in the file
|
||||
// uncomment the '#' symbol if there is one
|
||||
for line in content.lines() {
|
||||
if line.starts_with(tag) {
|
||||
new.push_str(&format!("{}\n", line.trim_start_matches(tag)));
|
||||
} else {
|
||||
new.push_str(&format!("{line}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// write back
|
||||
std::fs::write(file, new).unwrap();
|
||||
}
|
||||
|
||||
pub fn install(conf: InstallConfig) {
|
||||
// Drive Setup
|
||||
format_drives(&conf.drive, conf.general.encryption);
|
||||
|
|
|
@ -76,8 +76,9 @@ fn main() {
|
|||
let args = args::get_args();
|
||||
|
||||
match args.subcommand() {
|
||||
Some(("create-iso", _)) => {
|
||||
create_iso();
|
||||
Some(("create-iso", iso_args)) => {
|
||||
let without_gui = iso_args.get_flag("without_gui");
|
||||
create_iso(without_gui);
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some(("create-tar", _)) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue