From 8030653cc09cbab080eb5adbc39b8d51120a2157 Mon Sep 17 00:00:00 2001 From: Admin Pupkin Date: Wed, 10 Jun 2026 13:02:43 +0300 Subject: [PATCH] cub: fix blake3/sha256 confusion, add DYNAMIC_INIT to custom_script, fix cubl recipe chmod (v6.0 2026) --- local/recipes/dev/cubl/recipe.toml | 2 +- .../system/cub/source/cub-lib/src/cookbook.rs | 26 ++++++++++++++----- .../system/cub/source/cub-lib/src/recipe.rs | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/local/recipes/dev/cubl/recipe.toml b/local/recipes/dev/cubl/recipe.toml index ed68c5843d..55f1c4fab4 100644 --- a/local/recipes/dev/cubl/recipe.toml +++ b/local/recipes/dev/cubl/recipe.toml @@ -12,7 +12,7 @@ cargo build --release --target x86_64-unknown-linux-gnu -p cub-cli mkdir -p "${COOKBOOK_STAGE}/usr/bin" cp target/x86_64-unknown-linux-gnu/release/cub "${COOKBOOK_STAGE}/usr/bin/cub" -chmod +x "${COOKBOOK_STAGE}/usr/bin/cubl" +chmod +x "${COOKBOOK_STAGE}/usr/bin/cub" """ [package] diff --git a/local/recipes/system/cub/source/cub-lib/src/cookbook.rs b/local/recipes/system/cub/source/cub-lib/src/cookbook.rs index 0dbe69482c..2fe4ccf963 100644 --- a/local/recipes/system/cub/source/cub-lib/src/cookbook.rs +++ b/local/recipes/system/cub/source/cub-lib/src/cookbook.rs @@ -134,9 +134,6 @@ fn convert_source(source: &crate::rbpkgbuild::SourceEntry) -> Result { cookbook.tar = Some(source.url.clone()); - if !source.sha256.is_empty() { - cookbook.blake3 = Some(source.sha256.clone()); - } } } @@ -242,7 +239,12 @@ fn prefix_host_deps(deps: &[String]) -> Vec { } fn custom_script(rbpkg: &RbPkgBuild) -> Result { - let mut parts = Vec::new(); + let mut parts = vec!["DYNAMIC_INIT".to_string()]; + + // cookbook_apply_patches is idempotent (skips already-applied patches) + if !rbpkg.patches.files.is_empty() { + parts.push("cookbook_apply_patches".to_string()); + } parts.extend(rbpkg.build.prepare.iter().cloned()); parts.extend(rbpkg.build.build_script.iter().cloned()); @@ -386,7 +388,7 @@ mod tests { } #[test] - fn generates_tar_recipe_with_checksum() { + fn generates_tar_recipe_without_checksum() { let mut pkg = base_pkg(BuildTemplate::Cargo); pkg.source.sources[0] = SourceEntry { source_type: SourceType::Tar, @@ -403,7 +405,9 @@ mod tests { value["source"]["tar"].as_str(), Some("https://example.com/demo.tar.gz") ); - assert_eq!(value["source"]["blake3"].as_str(), Some("abc123deadbeef")); + // SHA256 from AUR is not written to blake3 field — wrong algorithm. + // The cookbook computes BLAKE3 on first fetch. + assert!(value.get("source").unwrap().get("blake3").is_none()); } #[test] @@ -412,6 +416,7 @@ mod tests { let value: toml::Value = toml::from_str(&recipe).expect("parse generated recipe"); let script = value["build"]["script"].as_str().expect("custom script"); + assert!(script.contains("cookbook_apply_patches")); assert!(script.contains("./autogen.sh")); assert!( script.contains("make\n") || script.ends_with("make") || script.contains("make test") @@ -419,6 +424,15 @@ mod tests { assert!(script.contains("make install")); } + #[test] + fn custom_script_omits_patches_when_none_declared() { + let mut pkg = base_pkg(BuildTemplate::Custom); + pkg.patches.files.clear(); + + let recipe = generate_recipe(&pkg).expect("generate recipe"); + assert!(!recipe.contains("cookbook_apply_patches")); + } + #[test] fn omits_test_commands_when_policy_disallows_them() { let mut pkg = base_pkg(BuildTemplate::Custom); diff --git a/local/recipes/system/cub/source/cub-lib/src/recipe.rs b/local/recipes/system/cub/source/cub-lib/src/recipe.rs index f4ea20e67d..a304e5b277 100644 --- a/local/recipes/system/cub/source/cub-lib/src/recipe.rs +++ b/local/recipes/system/cub/source/cub-lib/src/recipe.rs @@ -69,7 +69,7 @@ build() { value["source"]["tar"].as_str(), Some("https://example.com/demo-1.2.3.tar.xz") ); - assert_eq!(value["source"]["blake3"].as_str(), Some("abc123deadbeef")); + assert_eq!(value["source"]["blake3"].as_str(), None); } #[test]