forked from AbleOS/ableos
improvements to repbuild
This commit is contained in:
parent
59aaa9622b
commit
3a93907251
50
repbuild/assets/mkfs.sh
Normal file
50
repbuild/assets/mkfs.sh
Normal 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 \
|
||||||
|
;
|
||||||
|
|
|
@ -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(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue