From f890ebb3c4c8803e3dd4abba66e70657397f8122 Mon Sep 17 00:00:00 2001 From: qvkap Date: Wed, 23 Sep 2026 22:25:25 +0300 Subject: Bumped version to 1.0.3, fixing temporary file persistence via keep(), preventing UsrMerge circular symlink bugs, adding a host fallback for ldconfig, making virtual FS mount failures non-fatal during rootfs build, improving YAML error reporting, normalizing file permissions, and updating dependencies. --- src/rootfs.rs | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) mode change 100755 => 100644 src/rootfs.rs (limited to 'src/rootfs.rs') diff --git a/src/rootfs.rs b/src/rootfs.rs old mode 100755 new mode 100644 index badc595..c53b879 --- a/src/rootfs.rs +++ b/src/rootfs.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use crate::debug; use std::fs; use std::path::Path; use std::os::unix::fs::symlink; @@ -137,7 +138,7 @@ fn download_file_quiet( let size = std::fs::metadata(&src).map_err(|e| e.to_string())?.len(); bytes_expected_global.fetch_add(size, Ordering::Relaxed); let mut tmp_file = NamedTempFile::new().map_err(|e| e.to_string())?; - let file_path = tmp_file.path().to_path_buf(); + let _file_path = tmp_file.path().to_path_buf(); let mut src_file = std::fs::File::open(src).map_err(|e| e.to_string())?; let mut buf = [0u8; 65536]; loop { @@ -151,8 +152,8 @@ fn download_file_quiet( let _ = std::fs::copy(&dict_src, &dict_dst); } bytes_done_global.fetch_add(size, Ordering::Relaxed); - drop(tmp_file); - return Ok((file_path, size)); + let (_, path) = tmp_file.keep().map_err(|e| e.to_string())?; + return Ok((path, size)); } use reqwest::blocking::Client; @@ -177,7 +178,7 @@ fn download_file_quiet( } let mut tmp_file = NamedTempFile::new().map_err(|e| e.to_string())?; - let file_path = tmp_file.path().to_path_buf(); + let _file_path = tmp_file.path().to_path_buf(); let mut hasher = Sha256::new(); let mut buf = [0u8; 65536]; let mut downloaded: u64 = 0; @@ -199,8 +200,8 @@ fn download_file_quiet( } } - drop(tmp_file); - Ok((file_path, downloaded)) + let (_, path) = tmp_file.keep().map_err(|e| e.to_string())?; + Ok((path, downloaded)) } fn render_overall_bar(bytes_done: u64, bytes_expected: u64) { @@ -347,6 +348,7 @@ fn install_from_archive( ) -> Result, String> { let shadow = tempfile::tempdir().map_err(|e| format!("Failed to create temp dir: {}", e))?; let work_dir = shadow.path().join(pkg_name); + fs::create_dir_all(&work_dir).map_err(|e| format!("Failed to create work dir: {}", e))?; let extracted = if pkg_type == "ror" { extract_ror(archive_path, &work_dir) @@ -682,7 +684,27 @@ fn run_ldconfig_in_root(root_dir: &Path) -> Result<(), String> { } else if root_dir.join("usr/sbin/ldconfig").exists() { "/usr/sbin/ldconfig" } else { - return Ok(()); + debug!("Target rootfs lacks ldconfig, attempting host ldconfig -r..."); + let status = std::process::Command::new("ldconfig") + .arg("-r") + .arg(root_dir) + .arg("-C") + .arg("/etc/ld.so.cache") + .status(); + match status { + Ok(s) if s.success() => { + debug!("Host ldconfig -r generated /etc/ld.so.cache successfully"); + return Ok(()); + } + Ok(s) => { + debug!("Host ldconfig -r exited with: {}", s); + return Ok(()); + } + Err(e) => { + debug!("Failed to run host ldconfig: {}", e); + return Ok(()); + } + } }; match unsafe { fork() } { @@ -1044,7 +1066,9 @@ pub fn build_rootfs( println!("\n{} Phase 2: Running install_steps in chroot...", ">>>".cyan().bold()); println!("{} Mounting /dev /proc /sys...", ">>>".cyan()); - mount_virtual_fs(target_dir)?; + if let Err(e) = mount_virtual_fs(target_dir) { + eprintln!("{} Warning: Failed to mount virtual fs: {} (continuing anyway)", "[ror]".yellow(), e); + } let result = run_all_install_steps(&group.packages, &installing, target_dir); -- cgit v1.2.3