Basestrap kernel and stuff

This commit is contained in:
kira committed 2026-11-08 00:16:17 +01:00
1 parent 279bd30463
commit 029df21d3e
2 files changed
+56 -10

No files matched your search

+9
View File
@@ -139,6 +139,15 @@ pub fn basestrap_dinit(root_dir: &str) -> Result<(), ExecCommandError> {
) )
} }
pub fn basestrap(root_dir: &str, pkg_list: &[&str]) -> Result<(), ExecCommandError> {
let mut args: Vec<&str> = vec![root_dir];
args.extend(pkg_list);
exec_command(
"basestrap",
&args,
)
}
/// Executes parted command with given arguments /// Executes parted command with given arguments
fn exec_parted(args: &Vec<&str>) -> Result<String, ExecCommandError> { fn exec_parted(args: &Vec<&str>) -> Result<String, ExecCommandError> {
exec_command_out("parted", args) exec_command_out("parted", args)
+47 -10
View File
@@ -41,6 +41,19 @@ use rust_i18n::t;
const EFI_BOOT_MOUNT_POINT: &str = "/beefi"; const EFI_BOOT_MOUNT_POINT: &str = "/beefi";
const MNT_DIR: &str = "/mnt/inst_root"; const MNT_DIR: &str = "/mnt/inst_root";
const ROOT_PARTLABEL_DEV: &str = "/dev/disk/by-partlabel/bee-root"; const ROOT_PARTLABEL_DEV: &str = "/dev/disk/by-partlabel/bee-root";
///
/// List of packages for desktop (elogind-dinit no need for headles system)
///
const PKG_LIST_DESKTOP: [&str; 8] = [
"elogind-dinit",
"linux-kira-lts",
"linux-firmware",
"bcachefs-tools",
"xfsprogs",
"exfatprogs",
"f2fs-tools",
"hive-up",
];
/// Creates new GPT table and partitions from PartLayout /// Creates new GPT table and partitions from PartLayout
pub fn create_partitions(part_layout: &PartLayout) -> Result<(), ExecCommandError> { pub fn create_partitions(part_layout: &PartLayout) -> Result<(), ExecCommandError> {
@@ -79,6 +92,7 @@ pub fn bcachefs_init(
std::fs::create_dir_all(format!("{}{}", mnt_dir, EFI_BOOT_MOUNT_POINT))?; std::fs::create_dir_all(format!("{}{}", mnt_dir, EFI_BOOT_MOUNT_POINT))?;
// create subvolumes // create subvolumes
log::info!("Creating subvolumes...");
for vol_name in ["/home", "/usr", "/var", "/var/tmp"] { for vol_name in ["/home", "/usr", "/var", "/var/tmp"] {
let vol_path = format!("{}{}", mnt_dir, vol_name); let vol_path = format!("{}{}", mnt_dir, vol_name);
kira_system::bcachefs_create_subvolume(vol_path.as_str())?; kira_system::bcachefs_create_subvolume(vol_path.as_str())?;
@@ -87,7 +101,6 @@ pub fn bcachefs_init(
Ok(()) Ok(())
} }
pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandError> { pub fn init_disk(part_layout: &PartLayout, mnt_dir: &str) -> Result<(), ExecCommandError> {
let mnt_path = Path::new(mnt_dir); let mnt_path = Path::new(mnt_dir);
log::info!("Cheking is MNT path exists: {}", mnt_dir); log::info!("Cheking is MNT path exists: {}", mnt_dir);
@@ -181,18 +194,20 @@ pub fn mount_and_init_root(
mnt_dir: &str, mnt_dir: &str,
) -> Result<(), ExecCommandError> { ) -> Result<(), ExecCommandError> {
// init root // init root
let root_part = part_layout.get_part(PartRole::ROOT).expect("Root partition must be present!"); let root_part = part_layout
.get_part(PartRole::ROOT)
.expect("Root partition must be present!");
log::info!("Mount and init root partition."); log::info!("Mount and init root partition.");
if let FSType::BCACHEFS(bcache_prop) = root_part.fs_type { if let FSType::BCACHEFS(bcache_prop) = root_part.fs_type {
bcachefs_init(ROOT_PARTLABEL_DEV, mnt_dir, bcache_prop.password.clone())?; bcachefs_init(ROOT_PARTLABEL_DEV, mnt_dir, bcache_prop.password.clone())?;
} } else {
else { return Err(ExecCommandError::Other(format!(
return Err(ExecCommandError::Other(format!("Unexpected root partition type: {}", root_part.fs_type))); "Unexpected root partition type: {}",
root_part.fs_type
)));
} }
Ok(()) Ok(())
} }
async fn init_disk_async(part_layout: PartLayout, mnt_dir: String) -> Result<(), ExecCommandError> { async fn init_disk_async(part_layout: PartLayout, mnt_dir: String) -> Result<(), ExecCommandError> {
@@ -200,16 +215,26 @@ async fn init_disk_async(part_layout: PartLayout, mnt_dir: String) -> Result<(),
blocking::unblock(move || init_disk(&part_layout, &mnt_dir)).await blocking::unblock(move || init_disk(&part_layout, &mnt_dir)).await
} }
async fn mount_and_init_root_async(part_layout: PartLayout, mnt_dir: String) -> Result<(), ExecCommandError> { async fn mount_and_init_root_async(
part_layout: PartLayout,
mnt_dir: String,
) -> Result<(), ExecCommandError> {
use blocking; use blocking;
blocking::unblock(move || mount_and_init_root(&part_layout, &mnt_dir)).await blocking::unblock(move || mount_and_init_root(&part_layout, &mnt_dir)).await
} }
async fn install_base_async(mnt_dir: String) -> Result<(), ExecCommandError> { async fn install_base_async(mnt_dir: String) -> Result<(), ExecCommandError> {
use blocking; use blocking;
log::info!("Installing base system...");
blocking::unblock(move || kira_system::basestrap_dinit(&mnt_dir)).await blocking::unblock(move || kira_system::basestrap_dinit(&mnt_dir)).await
} }
async fn install_system_async(mnt_dir: String) -> Result<(), ExecCommandError> {
use blocking;
log::info!("Installing base system...");
blocking::unblock(move || kira_system::basestrap(&mnt_dir, &PKG_LIST_DESKTOP)).await
}
fn do_install( fn do_install(
k_config: KiraConfig, k_config: KiraConfig,
) -> impl futures::Stream<Item = Result<(f32, String), ExecCommandError>> { ) -> impl futures::Stream<Item = Result<(f32, String), ExecCommandError>> {
@@ -247,7 +272,19 @@ fn do_install(
let res = install_base_async(MNT_DIR.into()).await; let res = install_base_async(MNT_DIR.into()).await;
let res_err = res.is_err(); let res_err = res.is_err();
output output
.send(res.map(|_| (10.0f32, "Some other stuff".into()))) .send(res.map(|_| (10.0f32, "Installing system".into())))
.await
.unwrap();
if res_err {
return;
}
// installing system
let res = install_system_async(MNT_DIR.into()).await;
let res_err = res.is_err();
output
.send(res.map(|_| (20.0f32, "Some other stuff".into())))
.await .await
.unwrap(); .unwrap();
@@ -259,7 +296,7 @@ fn do_install(
// if output.send(res).await.is_err() { // if output.send(res).await.is_err() {
// return; // Exit early if UI is gone // return; // Exit early if UI is gone
// } // }
// Optional: Send completion or error state here // Optional: Send completion or error state here
// output.send(Message::WorkFailed).await.ok(); // output.send(Message::WorkFailed).await.ok();
}, },