diff options
| -rw-r--r-- | src/install.rs | 4 | ||||
| -rw-r--r-- | src/resolver.rs | 32 | ||||
| -rw-r--r-- | src/rootfs.rs | 50 |
3 files changed, 62 insertions, 24 deletions
diff --git a/src/install.rs b/src/install.rs index a0cf8f2..160121c 100644 --- a/src/install.rs +++ b/src/install.rs @@ -499,8 +499,6 @@ pub fn find_package_with_repo(pkg_name: &str) -> Option<(PathBuf, String)> { None } - - pub fn resolve_package_name(pkg_name: &str) -> Option<String> { let path = find_package_file(pkg_name)?; let content = fs::read_to_string(path).ok()?; @@ -813,6 +811,8 @@ pub fn install_package_with_result(pkg_name: &str, cfg: &config::Config) -> Resu } } + crate::delete::check_critical_install(pkg_name, &db)?; + let effective_filename = resolve_filename(&pkg, binary); debug!("Effective filename: {}", effective_filename); diff --git a/src/resolver.rs b/src/resolver.rs index 33c67e2..bee1681 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -255,6 +255,38 @@ pub fn check_conflicts(required: &HashSet<String>, installed_db: &InstalledDB) - } } + const STRICT_ROLES: &[&str] = &["init-system", "libc", "core-utils", "udev"]; + for &role in STRICT_ROLES { + let mut providers_in_required = Vec::new(); + for (name, pkg) in &pkg_map { + if pkg.provides.contains(&role.to_string()) { + providers_in_required.push(name.clone()); + } + } + if providers_in_required.len() > 1 { + return Err(format!( + "CRITICAL: multiple packages in the transaction provide '{}': {}. Only one '{}' provider is allowed at once.", + role, providers_in_required.join(", "), role + )); + } + + if let Some(cand) = providers_in_required.first() { + for (inst_name, _) in &installed_db.packages { + if inst_name == cand { + continue; + } + if let Some(inst_pkg) = load_package(inst_name) { + if inst_pkg.provides.contains(&role.to_string()) { + return Err(format!( + "CRITICAL: '{}' provides '{}', but '{}' is already installed and provides it. Multiple '{}' providers violate RorkOS system rules. Use 'ror di {} {}' to replace it atomically.", + cand, role, inst_name, role, inst_name, cand + )); + } + } + } + } + } + let names: Vec<_> = pkg_map.keys().cloned().collect(); for i in 0..names.len() { for j in i + 1..names.len() { diff --git a/src/rootfs.rs b/src/rootfs.rs index c53b879..46025d0 100644 --- a/src/rootfs.rs +++ b/src/rootfs.rs @@ -523,6 +523,15 @@ fn mount_virtual_fs(root_dir: &Path) -> Result<(), String> { MsFlags::MS_BIND | MsFlags::MS_REC, None::<&Path>, ) + .map_err(|e| format!("Failed to bind mount {}: {}", rel, e))?; + + let _ = mount( + None::<&Path>, + &target, + None::<&str>, + MsFlags::MS_PRIVATE | MsFlags::MS_REC, + None::<&Path>, + ); } else { mount( Some(Path::new(src)), @@ -531,8 +540,8 @@ fn mount_virtual_fs(root_dir: &Path) -> Result<(), String> { MsFlags::empty(), None::<&Path>, ) + .map_err(|e| format!("Failed to mount {}: {}", rel, e))?; } - .map_err(|e| format!("Failed to mount {}: {}", rel, e))?; } Ok(()) } @@ -679,32 +688,25 @@ fn run_install_steps_in_chroot( } fn run_ldconfig_in_root(root_dir: &Path) -> Result<(), String> { + let status = std::process::Command::new("ldconfig") + .arg("-r") + .arg(root_dir) + .arg("-C") + .arg("/etc/ld.so.cache") + .status(); + if let Ok(s) = status { + if s.success() { + debug!("Host ldconfig -r generated /etc/ld.so.cache successfully"); + return Ok(()); + } + } + let ldconfig_path = if root_dir.join("sbin/ldconfig").exists() { "/sbin/ldconfig" } else if root_dir.join("usr/sbin/ldconfig").exists() { "/usr/sbin/ldconfig" } else { - 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(()); - } - } + return Err("No ldconfig available".to_string()); }; match unsafe { fork() } { @@ -756,6 +758,10 @@ fn run_all_install_steps( .map(|s| s.to_string()) .collect(); + if steps_pkgs.is_empty() { + return Ok(()); + } + let mut pb = ProgressBar::new(steps_pkgs.len().max(1), "Running install steps..."); let (shell, subcmd) = find_working_shell(target_dir) |