fix install over 0.3.5.1

This commit is contained in:
Aiden McClelland
2026-01-26 14:16:11 -07:00
parent b39760d9d7
commit c96a5b7754
8 changed files with 141 additions and 12 deletions

View File

@@ -2,10 +2,12 @@ use std::path::{Path, PathBuf};
use gpt::GptConfig;
use gpt::disk::LogicalBlockSize;
use tokio::process::Command;
use crate::disk::OsPartitionInfo;
use crate::os_install::partition_for;
use crate::prelude::*;
use crate::util::Invoke;
pub async fn partition(
disk_path: &Path,
@@ -113,11 +115,8 @@ pub async fn partition(
// Check if protected partition would be overwritten by OS partitions
if let Some((first_lba, _, ref path)) = protected_partition_info {
// Get the actual end sector of the last OS partition (root = partition 3)
let os_partitions_end_sector = gpt
.partitions()
.get(&3)
.map(|p| p.last_lba)
.unwrap_or(0);
let os_partitions_end_sector =
gpt.partitions().get(&3).map(|p| p.last_lba).unwrap_or(0);
if first_lba <= os_partitions_end_sector {
return Err(Error::new(
eyre!(
@@ -176,6 +175,28 @@ pub async fn partition(
.await
.unwrap()?;
// Re-read partition table and wait for udev to create device nodes
Command::new("vgchange")
.arg("-an")
.invoke(crate::ErrorKind::DiskManagement)
.await
.ok();
Command::new("dmsetup")
.arg("remove_all")
.arg("--force")
.invoke(crate::ErrorKind::DiskManagement)
.await
.ok();
Command::new("blockdev")
.arg("--rereadpt")
.arg(&disk_path)
.invoke(crate::ErrorKind::DiskManagement)
.await?;
Command::new("udevadm")
.arg("settle")
.invoke(crate::ErrorKind::DiskManagement)
.await?;
Ok(OsPartitionInfo {
efi: efi.then(|| partition_for(&disk_path, 1)),
bios: (!efi).then(|| partition_for(&disk_path, 1)),

View File

@@ -2,10 +2,12 @@ use std::path::{Path, PathBuf};
use color_eyre::eyre::eyre;
use mbrman::{CHS, MBR, MBRPartitionEntry};
use tokio::process::Command;
use crate::disk::OsPartitionInfo;
use crate::os_install::partition_for;
use crate::prelude::*;
use crate::util::Invoke;
pub async fn partition(
disk_path: &Path,
@@ -139,6 +141,28 @@ pub async fn partition(
.await
.unwrap()?;
// Re-read partition table and wait for udev to create device nodes
Command::new("vgchange")
.arg("-an")
.invoke(crate::ErrorKind::DiskManagement)
.await
.ok();
Command::new("dmsetup")
.arg("remove_all")
.arg("--force")
.invoke(crate::ErrorKind::DiskManagement)
.await
.ok();
Command::new("blockdev")
.arg("--rereadpt")
.arg(&disk_path)
.invoke(crate::ErrorKind::DiskManagement)
.await?;
Command::new("udevadm")
.arg("settle")
.invoke(crate::ErrorKind::DiskManagement)
.await?;
Ok(OsPartitionInfo {
efi: None,
bios: None,

View File

@@ -490,7 +490,10 @@ pub async fn exit(ctx: SetupContext) -> Result<(), Error> {
None
};
ctx.shutdown.send(shutdown).expect("failed to shutdown");
ctx.shutdown
.send(shutdown)
.map_err(|e| eyre!("failed to shutdown: {e}"))
.log_err();
Ok(())
}
@@ -505,7 +508,8 @@ pub async fn restart(ctx: SetupContext) -> Result<(), Error> {
disk_guid: ctx.disk_guid.get().cloned(),
restart: true,
}))
.expect("failed to shutdown");
.map_err(|e| eyre!("failed to shutdown: {e}"))
.log_err();
Ok(())
}
@@ -520,7 +524,8 @@ pub async fn shutdown(ctx: SetupContext) -> Result<(), Error> {
disk_guid: ctx.disk_guid.get().cloned(),
restart: false,
}))
.expect("failed to shutdown");
.map_err(|e| eyre!("failed to shutdown: {e}"))
.log_err();
Ok(())
}

View File

@@ -168,6 +168,12 @@ impl VersionT for Version {
let tor_keys = previous_tor_keys(&pg).await?;
Command::new("systemctl")
.arg("stop")
.arg("postgresql@*.service")
.invoke(crate::ErrorKind::Database)
.await?;
Ok((account, ssh_keys, cifs, tor_keys))
}
fn up(