1
0
Fork 0
forked from koniifer/ableos

improvements to repbuild

This commit is contained in:
able 2022-07-28 07:07:23 -05:00
parent 59aaa9622b
commit 3a93907251
3 changed files with 80 additions and 0 deletions

BIN
img.ext2 Normal file

Binary file not shown.

50
repbuild/assets/mkfs.sh Normal file
View file

@ -0,0 +1,50 @@
set -eu
root_dir=root
img_file=img.ext2
user="Able"
# Create a test directory to convert to ext2.
mkdir -p "$root_dir"
mkdir -p "$root_dir/boot"
mkdir -p "$root_dir/system"
mkdir -p "$root_dir/system/bins"
mkdir -p "$root_dir/system/configs"
mkdir -p "$root_dir/shared"
mkdir -p "$root_dir/shared/bins"
mkdir -p "$root_dir/shared/configs"
mkdir -p "$root_dir/home"
mkdir -p "$root_dir/home/$user"
mkdir -p "$root_dir/home/$user/.trash"
mkdir -p "$root_dir/home/$user/bins"
mkdir -p "$root_dir/home/$user/configs"
# Build the userland here
mke2fs \
-L '' \
-N 0 \
-O ^64bit \
-d "$root_dir" \
-m 5 \
-r 1 \
-I 128 \
-t ext2 \
"$img_file" \
4M \
;

View file

@ -1,3 +1,6 @@
use std::io::stdin;
use anyhow::{Error, Ok};
use clap::Parser; use clap::Parser;
#[derive(clap::Parser, Debug)] #[derive(clap::Parser, Debug)]
@ -27,6 +30,7 @@ enum Command {
#[clap(long, short)] #[clap(long, short)]
path: Option<String>, path: Option<String>,
}, },
MakeFS {},
} }
#[derive(clap::ArgEnum, Debug, Clone)] #[derive(clap::ArgEnum, Debug, Clone)]
@ -110,7 +114,33 @@ fn main() -> anyhow::Result<()> {
let path = path.unwrap_or_else(|| "./userland/root_fs/mnt".to_string()); let path = path.unwrap_or_else(|| "./userland/root_fs/mnt".to_string());
xshell::cmd!("sudo umount {path}").run()?; xshell::cmd!("sudo umount {path}").run()?;
} }
Command::MakeFS {} => match make_fs() {
Result::Ok(_) => {}
Err(err) => println!("{}", err),
},
} }
Ok(()) Ok(())
} }
pub fn make_fs() -> Result<(), Error> {
xshell::cmd!("sh repbuild/assets/mkfs.sh").run()?;
println!("Make changes in root_fs");
let mut input = String::new();
println!("Press enter when ready:");
stdin().read_line(&mut input).unwrap();
// build
// xshell::cmd!("rm -rf root").run()?;
Ok(())
}
pub fn make_user(user: String) -> Result<(), Error> {
xshell::mkdir_p(user)?;
Ok(())
}