fix non-update build-script if build skipped

This commit is contained in:
2026-09-10 18:33:17 +03:00
parent 50bd819dfd
commit 2a14c89f5a

View File

@ -20,6 +20,7 @@ pub fn build(repo: &String, pkgname: &String) {
let full_env = get_install_env(repo, pkgname, &md_path, "build"); 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) { if is_build_up_to_date(&built_md_path, &build_script, &full_env, repo, pkgname) {
update_built_link(&md_path, &built_md_path);
return; return;
} }
@ -27,6 +28,7 @@ pub fn build(repo: &String, pkgname: &String) {
let applied_env = src_dir.join(".aeropkg.install-env"); let applied_env = src_dir.join(".aeropkg.install-env");
if is_source_up_to_date(&applied_build, &applied_env, &build_script, &full_env) { if is_source_up_to_date(&applied_build, &applied_env, &build_script, &full_env) {
update_built_link(&md_path, &built_md_path);
return; return;
} else if applied_build.exists() { } else if applied_build.exists() {
fs::remove_dir_all(&src_dir).unwrap(); 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); run_install_script_hook(repo, "build", &full_env);
fs::create_dir_all(&pkg_dir).ok(); 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(); fs::write(&applied_build, &build_script).unwrap();
update_built_link(&md_path, &built_md_path);
// Очистка и пост-хуки
if full_env.get("save_source").is_none() { if full_env.get("save_source").is_none() {
fs::remove_dir_all(&src_dir).ok(); 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) { fn hook(pkg_dir: &std::path::Path) {
let lib = pkg_dir.join("lib"); let lib = pkg_dir.join("lib");
for d in ["lib64", "lib32"] { for d in ["lib64", "lib32"] {