feat: add current file tracking during installation and update UI to display it

This commit is contained in:
Erkan IŞIK
2026-06-04 11:52:12 +03:00
parent d7065dcb59
commit 611d6b8cb9
7 changed files with 94 additions and 25 deletions
+1
View File
@@ -90,6 +90,7 @@ finish_title = "Installation Complete"
# ── Execution (extra) ─────────────────────────────────────
install_failed = "Installation failed"
install_done = "Installation complete! Click Next to continue."
install_current_file = "Current file"
retry_install = "Retry"
finish_next = "Finish →"
+1
View File
@@ -89,6 +89,7 @@ finish_title = "Kurulum Tamamlandı"
# ── Execution (ek) ────────────────────────────────────────
install_failed = "Kurulum başarısız"
install_done = "Kurulum tamamlandı! Devam etmek için İleri'ye basın."
install_current_file = "İşlemdeki dosya"
retry_install = "Yeniden Dene"
finish_next = "Tamamlandı →"
+3 -2
View File
@@ -137,11 +137,12 @@ pub fn apply_to_state(af: &AnswerFile, state: &mut crate::installer::GlobalState
let efi_mb = if is_uefi { 512u64 } else { 0 };
let total_mb = info.size_bytes / 1024 / 1024;
// Tavsiye edilen swap: RAM * 1.5, min 512 MB, max 8192 MB
// Swap: RAM * 1.0, min 512 MB, max 2048 MB, ayrıca diskin %10'unu geçmesin
let mut sys = sysinfo::System::new();
sys.refresh_memory();
let ram_mb = sys.total_memory() / 1024 / 1024;
let swap_mb = (ram_mb * 3 / 2).clamp(512, 8192);
let disk_10pct = total_mb / 10;
let swap_mb = ram_mb.clamp(512, 2048).min(disk_10pct);
let overhead = efi_mb + swap_mb + 512;
let root_mb = total_mb.saturating_sub(overhead);
+2
View File
@@ -205,6 +205,7 @@ pub struct GlobalState {
pub available_disks: Vec<DiskInfo>,
pub install_progress: f32,
pub install_log: Vec<String>,
pub install_current_file: Option<String>,
pub demo_mode: bool,
pub is_dark: bool,
pub rescue_mode: bool,
@@ -271,6 +272,7 @@ impl Default for GlobalState {
available_disks: Vec::new(),
install_progress: 0.0,
install_log: Vec::new(),
install_current_file: None,
demo_mode: false,
is_dark: true,
rescue_mode: false,
+67 -17
View File
@@ -129,17 +129,42 @@ impl Job for CopyFilesJob {
async fn run(&self, ui: &UiSender) -> Result<(), String> {
ui.log(format!("rsync {}{}", self.source, self.target));
// --info=progress2 ham çıktı verir; gerçek uygulamada
// satır satır parse edilerek ilerleme güncellenebilir.
let is_root_source = self.source.trim_end_matches('/') == "";
let mut args: Vec<String> = vec![
"-aAXH".to_string(),
"--info=progress2".to_string(),
"--exclude=/proc".to_string(),
"--exclude=/sys".to_string(),
"--exclude=/dev".to_string(),
"--exclude=/run".to_string(),
"--exclude=/proc/**".to_string(),
"--exclude=/sys/**".to_string(),
"--exclude=/dev/**".to_string(),
"--exclude=/run/**".to_string(),
"--exclude=/tmp/**".to_string(),
"--exclude=/var/tmp/**".to_string(),
"--exclude=/var/cache/**".to_string(),
"--exclude=/home/**".to_string(),
"--exclude=/root/**".to_string(),
"--exclude=/lost+found".to_string(),
"--exclude=*.sqfs".to_string(),
];
// Kaynak canlı sistem köküyse ekstra exclude'ler
if is_root_source {
args.extend_from_slice(&[
"--exclude=/bootmnt/**".to_string(),
"--exclude=/ro_branch/**".to_string(),
"--exclude=/mnt/**".to_string(),
"--exclude=/media/**".to_string(),
"--exclude=/var/log/journal/**".to_string(),
"--exclude=/var/lib/pisi/cache/**".to_string(),
"--exclude=/var/lib/pisi/archives/**".to_string(),
"--exclude=/etc/adjtime".to_string(),
"--exclude=/etc/mtab".to_string(),
"--exclude=/etc/resolv.conf".to_string(),
"--exclude=/etc/hostname".to_string(),
"--exclude=/etc/machine-id".to_string(),
]);
}
if let (Ok(source_path), Ok(target_path)) = (
std::path::Path::new(&self.source).canonicalize(),
std::path::Path::new(&self.target).canonicalize(),
@@ -743,6 +768,26 @@ async fn sync_partition_table(disk: &str) {
/// 2. Sabit aday listesini dene (her adayda bin/ + etc/ varlığı aranır)
/// 3. Hiçbiri bulunamazsa `/` (canlı sistem kökü) kullan — rsync
/// zaten /proc /sys /dev /run'u exclude eder.
fn has_root_fs(path: &std::path::Path) -> bool {
(path.join("bin").exists() || path.join("usr/bin").exists()) && path.join("etc").exists()
}
fn is_iso_mount(path: &str) -> bool {
let sqfs_check = [
"pisi/pisi.sqfs",
"live/pisi.sqfs",
"live/filesystem.squashfs",
"casper/filesystem.squashfs",
"live squashfs",
];
for pattern in &sqfs_check {
if std::path::Path::new(path).join(pattern).exists() {
return true;
}
}
false
}
pub fn detect_source_dir() -> String {
// 1. /proc/mounts içinde squashfs veya overlay mount noktalarını tara
if let Ok(mounts) = std::fs::read_to_string("/proc/mounts") {
@@ -756,7 +801,7 @@ pub fn detect_source_dir() -> String {
"squashfs" => {
if mount_pt != "/" {
let p = std::path::Path::new(mount_pt);
if p.join("bin").exists() || p.join("usr/bin").exists() {
if has_root_fs(p) {
return format!("{}/", mount_pt.trim_end_matches('/'));
}
}
@@ -768,7 +813,7 @@ pub fn detect_source_dir() -> String {
if let Some(lower) = opt.strip_prefix("lowerdir=") {
for dir in lower.split(':') {
let p = std::path::Path::new(dir);
if p.exists() && (p.join("bin").exists() || p.join("usr/bin").exists()) {
if p.exists() && has_root_fs(p) {
return format!("{}/", dir.trim_end_matches('/'));
}
}
@@ -781,7 +826,8 @@ pub fn detect_source_dir() -> String {
}
// 2. Sabit aday listesi (her adayda bin/ + etc/ kontrolü)
let candidates = [
// NOT: /bootmnt ISO kökü olabilir; altında pisi.sqfs varsa atlanır.
for path in &[
"/run/livecd/squashfs-root",
"/run/live/rootfs",
"/run/live/medium",
@@ -791,17 +837,17 @@ pub fn detect_source_dir() -> String {
"/mnt/cdrom",
"/bootmnt/live",
"/bootmnt/livecd",
"/bootmnt",
];
for path in &candidates {
] {
let p = std::path::Path::new(path);
if p.exists() {
let has_bin = p.join("bin").exists() || p.join("usr/bin").exists();
let has_etc = p.join("etc").exists();
if has_bin && has_etc {
if p.exists() && has_root_fs(p) {
return format!("{}/", path);
}
}
// 2b. /bootmnt son çare; ama ISO köküyse (pisi.sqfs varsa) atla
let bootmnt = std::path::Path::new("/bootmnt");
if bootmnt.exists() && !is_iso_mount("/bootmnt") && has_root_fs(bootmnt) {
return "/bootmnt/".to_string();
}
// 3. Hiçbiri bulunamazsa canlı sistem kökü
@@ -1712,7 +1758,11 @@ async fn set_password_via_chpasswd(mount: &str, input: &str) -> Result<(), Strin
.map_err(|e| format!("chpasswd başlatılamadı: {}", e))?;
if let Some(mut stdin) = child.stdin.take() {
stdin.write_all(input.as_bytes()).await
let mut data = input.as_bytes().to_vec();
if !data.ends_with(b"\n") {
data.push(b'\n');
}
stdin.write_all(&data).await
.map_err(|e| format!("chpasswd stdin yazma hatası: {}", e))?;
}
+10
View File
@@ -41,6 +41,7 @@ impl InstallerStep for ExecutionStep {
state.install_progress = 0.0;
state.install_log.clear();
state.install_current_file = None;
state.install_log.push(t!("install_starting").to_string());
}
@@ -289,6 +290,15 @@ impl InstallerStep for ExecutionStep {
);
});
if let Some(ref current_file) = state.install_current_file {
ui.add_space(4.0);
ui.label(
egui::RichText::new(format!("{}: {}", t!("install_current_file"), current_file))
.size(12.0)
.color(theme::c_text_dim()),
);
}
ui.add_space(4.0);
ui.add(
egui::ProgressBar::new(state.install_progress)
+6 -2
View File
@@ -39,9 +39,13 @@ impl InstallerStep for FinishStep {
theme::primary_button(&t!("finish_restart"))
.min_size(egui::vec2(200.0, 44.0)),
).clicked() {
let _ = std::process::Command::new("systemctl")
.arg("reboot")
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
std::thread::spawn(|| {
std::thread::sleep(std::time::Duration::from_millis(500));
let _ = std::process::Command::new("reboot")
.arg("-f")
.spawn();
});
}
ui.add_space(12.0);