cub: fix blake3/sha256 confusion, add DYNAMIC_INIT to custom_script, fix cubl recipe chmod (v6.0 2026)

This commit is contained in:
2026-06-10 13:02:43 +03:00
parent e82a86e440
commit 8030653cc0
3 changed files with 22 additions and 8 deletions
+1 -1
View File
@@ -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]
@@ -134,9 +134,6 @@ fn convert_source(source: &crate::rbpkgbuild::SourceEntry) -> Result<CookbookSou
}
SourceType::Tar => {
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<String> {
}
fn custom_script(rbpkg: &RbPkgBuild) -> Result<String, CubError> {
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);
@@ -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]