From 2a14c89f5a66a8d27119b6c308450d46cd395225 Mon Sep 17 00:00:00 2001 From: TraceLumen Date: Thu, 10 Sep 2026 18:33:17 +0300 Subject: [PATCH] fix non-update build-script if build skipped --- src/commands/run/build.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/commands/run/build.rs b/src/commands/run/build.rs index e403d85..d345b45 100644 --- a/src/commands/run/build.rs +++ b/src/commands/run/build.rs @@ -20,6 +20,7 @@ pub fn build(repo: &String, pkgname: &String) { let full_env = get_install_env(repo, pkgname, &md_path, "build"); if is_build_up_to_date(&built_md_path, &build_script, &full_env, repo, pkgname) { + update_built_link(&md_path, &built_md_path); return; } @@ -27,6 +28,7 @@ pub fn build(repo: &String, pkgname: &String) { let applied_env = src_dir.join(".aeropkg.install-env"); if is_source_up_to_date(&applied_build, &applied_env, &build_script, &full_env) { + update_built_link(&md_path, &built_md_path); return; } else if applied_build.exists() { fs::remove_dir_all(&src_dir).unwrap(); @@ -40,12 +42,9 @@ pub fn build(repo: &String, pkgname: &String) { run_install_script_hook(repo, "build", &full_env); fs::create_dir_all(&pkg_dir).ok(); - let _ = fs::remove_file(&built_md_path); - fs::hard_link(&md_path, &built_md_path) - .unwrap_or_else(|e| panic!("Failed to link build script: {}", e)); fs::write(&applied_build, &build_script).unwrap(); + update_built_link(&md_path, &built_md_path); - // Очистка и пост-хуки if full_env.get("save_source").is_none() { fs::remove_dir_all(&src_dir).ok(); } @@ -59,6 +58,13 @@ pub fn build(repo: &String, pkgname: &String) { } } +fn update_built_link(src: &std::path::Path, dest: &std::path::Path) { + let _ = fs::remove_file(dest); + if let Err(e) = fs::hard_link(src, dest) { + eprintln!("Warning: Failed to update build-script.md link: {}", e); + } +} + fn hook(pkg_dir: &std::path::Path) { let lib = pkg_dir.join("lib"); for d in ["lib64", "lib32"] {