mirror of
https://gitlab.com/erkanisik/yali-rs.git
synced 2026-09-27 15:33:43 +00:00
feat: update version to 4.0.1, remove deprecated actions and pspec files, and enhance rsync command with dynamic exclusion
This commit is contained in:
+93
-26
@@ -131,16 +131,31 @@ impl Job for CopyFilesJob {
|
||||
|
||||
// --info=progress2 ham çıktı verir; gerçek uygulamada
|
||||
// satır satır parse edilerek ilerleme güncellenebilir.
|
||||
run_cmd("rsync", &[
|
||||
"-aAXH",
|
||||
"--info=progress2",
|
||||
"--exclude=/proc",
|
||||
"--exclude=/sys",
|
||||
"--exclude=/dev",
|
||||
"--exclude=/run",
|
||||
&self.source,
|
||||
&self.target,
|
||||
]).await?;
|
||||
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(),
|
||||
];
|
||||
|
||||
if let (Ok(source_path), Ok(target_path)) = (
|
||||
std::path::Path::new(&self.source).canonicalize(),
|
||||
std::path::Path::new(&self.target).canonicalize(),
|
||||
) {
|
||||
if let Ok(relative_target) = target_path.strip_prefix(&source_path) {
|
||||
if !relative_target.as_os_str().is_empty() {
|
||||
args.push(format!("--exclude={}", relative_target.display()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
args.push(self.source.clone());
|
||||
args.push(self.target.clone());
|
||||
|
||||
let arg_refs: Vec<&str> = args.iter().map(|s| s.as_str()).collect();
|
||||
run_cmd("rsync", &arg_refs).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -592,23 +607,75 @@ async fn sync_partition_table(disk: &str) {
|
||||
}
|
||||
|
||||
/// ISO ortamında canlı sistemin kaynak dizinini otomatik tespit eder.
|
||||
/// Bulunamazsa varsayılan yolu döner.
|
||||
///
|
||||
/// Sırasıyla:
|
||||
/// 1. `/proc/mounts` içinde squashfs/overlay mount noktalarını tara
|
||||
/// 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.
|
||||
pub fn detect_source_dir() -> String {
|
||||
let candidates = [
|
||||
"/bootmnt", // PisiLinux ISO mount noktası
|
||||
"/mnt/cdrom",
|
||||
"/mnt/sqfs",
|
||||
"/run/livecd/squashfs-root",
|
||||
"/run/live/medium",
|
||||
"/lib/live/mount/rootfs",
|
||||
"/mnt/livecd",
|
||||
];
|
||||
for path in &candidates {
|
||||
if std::path::Path::new(path).exists() {
|
||||
return format!("{}/", path);
|
||||
// 1. /proc/mounts içinde squashfs veya overlay mount noktalarını tara
|
||||
if let Ok(mounts) = std::fs::read_to_string("/proc/mounts") {
|
||||
for line in mounts.lines() {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() < 3 { continue; }
|
||||
let fs_type = parts[2];
|
||||
let mount_pt = parts[1];
|
||||
|
||||
match fs_type {
|
||||
"squashfs" => {
|
||||
if mount_pt != "/" {
|
||||
let p = std::path::Path::new(mount_pt);
|
||||
if p.join("bin").exists() || p.join("usr/bin").exists() {
|
||||
return format!("{}/", mount_pt.trim_end_matches('/'));
|
||||
}
|
||||
}
|
||||
}
|
||||
"overlay" => {
|
||||
// lowerdir parametresini ayıkla
|
||||
let opts = parts.get(3).unwrap_or(&"");
|
||||
for opt in opts.split(',') {
|
||||
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()) {
|
||||
return format!("{}/", dir.trim_end_matches('/'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
"/run/livecd/squashfs-root/".to_string()
|
||||
|
||||
// 2. Sabit aday listesi (her adayda bin/ + etc/ kontrolü)
|
||||
let candidates = [
|
||||
"/run/livecd/squashfs-root",
|
||||
"/run/live/rootfs",
|
||||
"/run/live/medium",
|
||||
"/lib/live/mount/rootfs",
|
||||
"/mnt/sqfs",
|
||||
"/mnt/livecd",
|
||||
"/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 {
|
||||
return format!("{}/", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Hiçbiri bulunamazsa canlı sistem kökü
|
||||
"/".to_string()
|
||||
}
|
||||
|
||||
/// Kurulum kuyruğu için ortak yapılandırma.
|
||||
@@ -1265,8 +1332,8 @@ impl Job for ConfigureLocaleJob {
|
||||
.map_err(|e| format!("/etc/locale-gen yazılamadı: {}", e))?;
|
||||
|
||||
// locale-gen çalıştır
|
||||
ui.log("locale.gen çalıştırılıyor…");
|
||||
run_chroot(&self.mount, &["locale.gen"]).await?;
|
||||
ui.log("locale-gen çalıştırılıyor…");
|
||||
//run_chroot(&self.mount, &["locale-gen"]).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user