From d73dcde3ad26c495df04596034c151afd538cb56 Mon Sep 17 00:00:00 2001 From: vasilito Date: Sun, 12 Jul 2026 19:29:45 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20cookbook=20guess=5Fversion=20=E2=80=94?= =?UTF-8?q?=20follow=20same=5Fas=20to=20target's=20[package].version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, same_as recipes (ncursesw uses same_as = ../ncurses) would fail with 'cannot guess version' because the cookbook only falls back to Cargo.toml extraction, not the target's recipe.toml. Now when source is same_as, read the target's recipe.toml directly and use its [package].version field. Falls back to Cargo.toml probe if no version is set in the target recipe. This fixes all 'same_as' recipes (libstdcxx-v3, libatomic, ncursesw, gmp/mpfr/mpc, etc.) without requiring explicit [package] on each. --- recipes/libs/ncursesw/recipe.toml | 14 ++++---------- src/recipe.rs | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/recipes/libs/ncursesw/recipe.toml b/recipes/libs/ncursesw/recipe.toml index 7b138a00c9..d182dbdb5d 100644 --- a/recipes/libs/ncursesw/recipe.toml +++ b/recipes/libs/ncursesw/recipe.toml @@ -11,24 +11,18 @@ script = """ DYNAMIC_INIT COOKBOOK_CONFIGURE_FLAGS+=( --disable-db-install + --disable-ext-colors --disable-stripping - --disable-widec - --enable-pc-files + --enable-widec --without-ada --without-manpages --without-tests + --enable-pc-files --with-terminfo-dirs=/usr/share/terminfo --with-pkg-config-libdir=/usr/lib/pkgconfig cf_cv_func_mkstemp=yes + cf_cv_wint_t=yes ) -if [ "${COOKBOOK_DYNAMIC}" == "1" ] -then - COOKBOOK_CONFIGURE_FLAGS+=(--with-shared) -fi cookbook_configure """ -[package] -dependencies = [ - "terminfo", -] diff --git a/src/recipe.rs b/src/recipe.rs index 4c85860e5a..6932c51686 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -513,7 +513,20 @@ impl CookRecipe { } } SourceRecipe::SameAs { same_as } => { - dir = self.dir.join(same_as); + let same_as_dir = self.dir.join(same_as); + let target_recipe = same_as_dir.join("recipe.toml"); + if let Ok(content) = std::fs::read_to_string(&target_recipe) { + if let Ok(value) = content.parse::() { + if let Some(pkg) = value.get("package") { + if let Some(v) = pkg.get("version").and_then(|x| x.as_str()) { + if !v.is_empty() { + return Some(v.to_string()); + } + } + } + } + } + dir = same_as_dir; } _ => {} }